Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
ROS 2 from Scratch
ROS 2 from Scratch

ROS 2 from Scratch: Get started with ROS 2 and create robotics applications with Python and C++

Arrow left icon
Profile Icon Edouard Renard
Arrow right icon
Free Trial
Paperback Nov 2024 380 pages 1st Edition
eBook
Can$12.99 Can$40.99
Paperback
Can$50.99
Subscription
Free Trial
Arrow left icon
Profile Icon Edouard Renard
Arrow right icon
Free Trial
Paperback Nov 2024 380 pages 1st Edition
eBook
Can$12.99 Can$40.99
Paperback
Can$50.99
Subscription
Free Trial
eBook
Can$12.99 Can$40.99
Paperback
Can$50.99
Subscription
Free Trial

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

ROS 2 from Scratch

Introduction to ROS 2 – What Is ROS 2?

Robot Operating System (ROS) can be confusing, as evidenced by its name. It’s difficult to know what it is exactly, what it contains, and what it does. Also, why do you even need ROS, and when should you use it?

Before getting started, it is okay to be confused—most people are. Although ROS is one of the best tools to learn and develop robotics applications, it also comes with a steep learning curve, with the first roadblock being understanding what it is.

In this quick first chapter, I will explain the terminology we will use throughout this book. You will then see why ROS exists, and what problems it can solve for you. After that, we will dive a bit deeper into the four pillars of ROS to understand what it is. You will also see a few examples of when and when not to use it.

By the end of this chapter, you will have a better understanding of the global picture behind ROS and be clear of the most common confusions...

Terminology

You might have seen the terms ROS, ROS 1, ROS 2, and other kinds of variations (with or without a space), which can be confusing.

Let’s clear this up now:

  • ROS 1 is (was) the first version of ROS
  • ROS 2 is the second and newer version of ROS and will be the focus of this book

In this book, I will use the following convention:

  • ROS: When talking about general ROS concepts, philosophy, and so on
  • ROS 1: When talking specifically about the first version of ROS. However, this will be quite rare since the focus here is on ROS 2
  • ROS 2: When talking about the second version of ROS

Note

I may sometimes write ROS or ROS 2 interchangeably since we won’t be focusing on ROS 1 here.

It’s not impossible that, in the future (when ROS 1 has completely disappeared), the name ROS 2 becomes ROS again. If you’ve heard about Angular, it started as AngularJS, after which they released Angular2, and then a few years later...

What is ROS, when should we use it, and why?

Before we start understanding what ROS is, let’s understand why we would need it.

Why ROS?

Let’s start with a big problem that occurs often in robotics.

Imagine that you just got a new project at your job, and you have to develop a robotics application, or you are doing a new research thesis. One very important thing to take into account is that in real life, any project or thesis will have a specific duration, from a few months to a few years.

Now, what will happen?

You start to design the robotics system you need for your project and soon realize that it will take a lot of time to develop the robot because all the existing solutions you found don’t match what you need. After a few weeks, you finalize the specifications, and you start building your robot. A few months in, you’re still developing the basic software for wheel control and navigation. You underestimated how much time it would take...

ROS 1 versus ROS 2

To be clear, this book is all about ROS 2, not ROS 1. You will start learning ROS 2 from zero experience. This section is probably the only time I will be talking that much about ROS 1.

A quick story of ROS, and how we got to ROS 2

ROS 1 (originally called ROS) was first developed in 2007. It quickly gained popularity and grew exponentially in the following years.

In 2014, the ROS 2 project was announced. Simply put, ROS 1 was a bit too limited for industrial applications (lack of real-time support, safety, and so on) and was only used in research/education. To solve this problem, the developers decided to make ROS more “industrial friendly,” as well as make it better, thanks to all the lessons learned from the beginning of ROS.

Now, why create ROS 2 and not just continue ROS with some new changes? Well, the changes were too big, and they would have completely broken compatibility with older versions. Thus, it was decided to create a completely...

Prerequisites for starting with ROS 2

To get started with ROS and this book, there are a few things you need to know.

Knowledge prerequisites

It is best that you have some knowledge of the following:

  • Linux command line: Since we’ll be using Ubuntu, being familiar with Linux is mandatory. You don’t need to be an expert—you just need to know the basics. Many tools in ROS 2 involve the command line, so knowing how to open a Terminal and write basic commands will help you tremendously.
  • Python programming: The two most common languages for ROS are Python and C++. Python is easier to get started with and allows you to prototype things faster. Hence, this is the language we will use for all detailed explanations. You need to know Python basics, and object-oriented programming (OOP) is a good plus as ROS 2 is heavily using OOP everywhere.
  • Optional: C++ programming. Even if the focus of the book is on Python, I still wanted to include C++ code for...

How to follow this book

The book is divided into three parts, including 14 chapters.

Each chapter can be followed individually, although for one chapter, you need the knowledge from all previous chapters.

If you got this book because you just want to get started from scratch, then it’s simple: follow the book in the order it’s been written. I have designed it specifically so that you learn the concepts one step at a time without having to think about what directions you should take.

Then, as you progress, feel free to come back to any chapter to clear up doubts. I encourage you to do that. The first time you learn about a concept, you don’t necessarily grasp all the subtleties. As you continue with this book and use the concept along with other new concepts, you often have ‘epiphany moments’, when everything clicks together.

If you already know some ROS 2 basics (or you’ve already read this book), then feel free to jump to any chapter...

Summary

In this introductory chapter, we cleared up some of the most common confusion points regarding ROS: its name, what it is and isn’t, when to use it, and why. You also learned more about the different ROS versions (ROS 1 and ROS 2), and you learned what kind of prerequisites you need to get started with ROS 2.

You should now have a better understanding of the big picture, and even if everything still seems a bit confusing, don’t worry too much—it will all make sense when you use the ROS 2 concepts and code with them.

Now, to be able to use ROS 2, we need to install it. This will be the focus of the next chapter and will help you get your environment 100% ready for ROS 2.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Build a strong foundation in ROS 2 and instill confidence for future robotics projects
  • Leverage best practices to create scalable ROS 2 applications with Python and C++
  • Follow a step-by-step process to create and simulate a custom robot using ROS 2
  • Purchase of the print or Kindle book includes a free PDF eBook

Description

ROS 2 from Scratch, written by the cofounder of a robotics company with years of experience in teaching and engineering, will equip you with the skills necessary to develop cutting-edge robotic systems efficiently. This book will help you understand why you should use Robot Operating System (ROS), clarifying what ROS is and isn’t. It focuses on applied learning—no unnecessary filler, no abstract theory, and no abrupt leaps into complex topics. You’ll discover how to install ROS 2, set up your environment, and explore concepts through hands-on experiments, as well as create a ROS 2 application for a custom robot. The chapters expand upon core concepts such as nodes, communication via topics, client-server interactions with services, complex behaviors using actions, runtime configurations with parameters, and seamless node orchestration via launch files. Each concept is clearly explained with the help of real-life analogies and practical examples, using Python and C++. The book will also guide you through creating a real-world project that incorporates TFs, URDF, RViz, and Gazebo. By the end of this book, you’ll be able to create new software for any robot in no time and easily join existing projects for new job roles, research endeavors, and beyond.

Who is this book for?

This book is for engineers, researchers, teachers, students, and hobbyists eager to learn ROS 2 from scratch and build real-world robotics applications efficiently. If you’re struggling to get started with ROS 2 or find existing tutorials overwhelming, then this book is for you. This book teaches you all the basics you need to create your own ROS 2 apps, without prior ROS knowledge. Basic Linux command line and Python programming skills (C++ optional for following the C++ code examples) are necessary.

What you will learn

  • Understand what ROS 2 is, when to use it, and how to use it
  • Write ROS 2 programs using nodes, topics, services, actions, and custom interfaces
  • Scale your application with parameters and launch files
  • Get a complete overview of how TFs work for any ROS-powered robot
  • Create a robot model (with URDF) and visualize TFs on RViz
  • Adapt the URDF to spawn and control your robot in the Gazebo simulator

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Nov 22, 2024
Length: 380 pages
Edition : 1st
Language : English
ISBN-13 : 9781835881408
Category :
Concepts :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Nov 22, 2024
Length: 380 pages
Edition : 1st
Language : English
ISBN-13 : 9781835881408
Category :
Concepts :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just Can$6 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just Can$6 each
Feature tick icon Exclusive print discounts
Banner background image

Table of Contents

19 Chapters
Part 1:Getting Started with ROS 2 Chevron down icon Chevron up icon
Chapter 1: Introduction to ROS 2 – What Is ROS 2? Chevron down icon Chevron up icon
Chapter 2: Installing and Setting Up ROS 2 Chevron down icon Chevron up icon
Chapter 3: Uncovering ROS 2 Core Concepts Chevron down icon Chevron up icon
Part 2: Developing with ROS 2 – Python and C++ Chevron down icon Chevron up icon
Chapter 4: Writing and Building a ROS 2 Node Chevron down icon Chevron up icon
Chapter 5: Topics – Sending and Receiving Messages between Nodes Chevron down icon Chevron up icon
Chapter 6: Services – Client/Server Interaction between Nodes Chevron down icon Chevron up icon
Chapter 7: Actions – When Services Are Not Enough Chevron down icon Chevron up icon
Chapter 8: Parameters – Making Nodes More Dynamic Chevron down icon Chevron up icon
Chapter 9: Launch Files – Starting All Your Nodes at Once Chevron down icon Chevron up icon
Part 3: Creating and Simulating a Custom Robot with ROS 2 Chevron down icon Chevron up icon
Chapter 10: Discovering TFs with RViz Chevron down icon Chevron up icon
Chapter 11: Creating a URDF for a Robot Chevron down icon Chevron up icon
Chapter 12: Publishing TFs and Packaging the URDF Chevron down icon Chevron up icon
Chapter 13: Simulating a Robot in Gazebo Chevron down icon Chevron up icon
Chapter 14: Going Further – What To Do Next Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.