Leanpub Header

Skip to main content

A very informal journey through ROS 2

patterns, anti-patterns, frameworks and best practices

This book takes you through the most common patterns and frameworks used by developers while creating software based on ROS 2. It's not a programming guide guiding you through the basic APIs, but is meant to help you organizing complex architectural patterns in robotics. It is written with an informal tone that will hopefully keep you entertained.

Minimum price

$12.99

$18.99

You pay

$18.99

Author earns

$15.19
$

...Or Buy With Credits!

You can get credits with a paid monthly or annual Reader Membership, or you can buy them here.
PDF
339
Readers
About

About

About the Book

A very informal journey through the new edition of the Robot Operative System: ROS 2. This book will bring you through the most common patterns and frameworks used by software engineers while creating software based on this framework. It will try to do that with an informal tone that hopefully won't make you fall asleep in the process.

Author

About the Author

Marco Matteo Bassa

Hi, I'm Marco, a robotics engineer with over 10 years of experience in programming fancy robotic systems. I've been working in multiple startups, where I learned (made) lots of the mistakes one can do while programming a robot. I'm currently leading a team of robotics developers at Idealworks. I believe robotics to be the funniest area a software developer can work in, and that, to some extent, it can be explained without the need for strict formalism and boring books. I hope you'll prove me right! :)

Contents

Table of Contents

  • 1 Introduction
    • 1.1 ROS 2
    • 1.2 Why this book?
    • 1.3 How and when to read this book
  • 2 The Node
    • 2.1 How to (properly) instantiate it
      • 2.1.1 Components and when to use them
    • 2.2 The Node types
      • 2.2.1 Managed Nodes
      • 2.2.2 Custom base nodes
    • 2.3 Using nodes in the interfaces
      • 2.3.1 Generic node interfaces
      • 2.3.2 Subordinate nodes
  • 3 Callbacks and Executors
    • 3.1 The callback
    • 3.2 The executors
      • 3.2.1 Types of executors
      • 3.2.2 Managing executors
    • 3.3 The callback groups
    • 3.4 Avoiding Multithreading
      • 3.4.1 Additional executors
      • 3.4.2 Taking messages
    • 3.5 Deterministic execution
      • 3.5.1 WaitSet
      • 3.5.2 Micro-ROS and the rclc Executor
  • 4 Interfaces
    • 4.1 Internal interfaces
    • 4.2 Policies
      • 4.2.1 Profiles
      • 4.2.2 Compatibility of policies
      • 4.2.3 Parametrizing the QOS settings
      • 4.2.4 Requirements for sharing memory
    • 4.3 Topics
      • 4.3.1 Specifying the desired Qos profiles
      • 4.3.2 When should you use a Topic interface?
      • 4.3.3 Naming your topic
      • 4.3.4 Namespaces
      • 4.3.5 Lazy publishers and subscribers
    • 4.4 Services
      • 4.4.1 Services in ROS1
      • 4.4.2 Services in ROS 2
      • 4.4.3 Services introspection
      • 4.4.4 When should you use a service?
    • 4.5 Actions
    • 4.6 Standard and custom interfaces
    • 4.7 Type adaptation
      • 4.7.1 Advantages of type adaptation
      • 4.7.2 Mixing types and type negotiation
  • 5 Tasks organization
    • 5.1 Sequential code
    • 5.2 State machines
    • 5.3 Behavior trees
      • 5.3.1 How do BTs work?
      • 5.3.2 Behavior trees in ROS 2
    • 5.4 Higher levels of tasks organization and task planning
      • 5.4.1 FlexBE
      • 5.4.2 Skiros2
      • 5.4.3 Task planning: Plansys2
    • 5.5 Which framework is the right one for my project?
  • 6 Integrating controllers in ROS 2
    • 6.1 The biggest enemy of a controller: delays
      • 6.1.1 Sources of delays
      • 6.1.2 Making your system deterministic
      • 6.1.3 Do you need determinism?
    • 6.2 ROS 2 control
    • 6.3 Domain-specific control frameworks
      • 6.3.1 Nav2
      • 6.3.2 MoveIt2
  • 7 Testing your code
    • 7.1 Unit testing
      • 7.1.1 GTests in ROS 2
      • 7.1.2 Unittest and Pytest in ROS 2
      • 7.1.3 Rtest
    • 7.2 Component tests
      • 7.2.1 Python component tests
      • 7.2.2 C++ component tests
    • 7.3 Integration tests
    • 7.4 Simulation based tests
      • 7.4.1 Simulators in ROS 2
    • 7.5 Testing on the hardware
  • 8 Parameters management
    • 8.1 Where are parameters loaded?
      • 8.1.1 How are parameters accessed from the code?
      • 8.1.2 Parameters description
    • 8.2 Dynamic parameters updates
      • 8.2.1 Parameters without declaration
    • 8.3 Default parameters are evil
    • 8.4 Defining parameter layers
      • 8.4.1 An example
    • 8.5 Too many parameters?
    • 8.6 Storing parameters programmatically
  • 9 Logging messages
    • 9.1 Logging a message
      • 9.1.1 Choosing the severity level
      • 9.1.2 Available macros
    • 9.2 Enabling and disabling log functionalities
      • 9.2.1 Logging channels, options, and environment variables
      • 9.2.2 Different types of loggers
      • 9.2.3 Changing the log severity level at runtime
  • 10 Building you stack
    • 10.1 Dependency management
      • 10.1.1 Maintenance status
      • 10.1.2 Dependency chain
    • 10.2 Building your code
      • 10.2.1 Modern CMake for ROS 2 by examples
      • 10.2.2 Useful Colcon commands
      • 10.2.3 Bazel and ROS 2
    • 10.3 Docker and ROS 2
  • 11 Conclusions
    • 11.1 Feedback please
    • 11.2 Final tips
  • 12 Solutions
    • 12.1 Chapter 2
    • 12.2 Chapter 3
    • 12.3 Chapter 4
    • 12.4 Chapter 5
    • 12.5 Chapter 9

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub