Udemy
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Behavior Trees for Robots: ROS 2, Nav2, C++ and Python
New
1 students

Behavior Trees for Robots: ROS 2, Nav2, C++ and Python

Build, test and debug robot missions with BehaviorTree.CPP, py_trees and Nav2. Every lecture has a runnable lab.
Last updated 10/2026
English
English

What you'll learn

  • Explain ticks, SUCCESS, FAILURE and RUNNING, and predict what a tree does before you run it.
  • Write and debug behavior trees in C++ with BehaviorTree.CPP and in Python with py_trees.
  • Build recovery, guards, timeouts and cleanup, and measure them with seeded fault injection.
  • Run trees inside ROS 2 nodes, including action clients that cancel correctly on halt.
  • Read, edit and extend Nav2's navigation behavior tree in a TurtleBot3 simulation.
  • Test and gate a robot mission in CI so a regression fails the build.

Course content

7 sections • 43 lectures • 2h 36m total length
  • 1.1 How to follow this course4:02
  • 1.2 A mission as a state machine, then as a behavior tree3:44
  • 1.3 Ticks and statuses3:25
  • 1.4 The building blocks: sequence, fallback, decorators3:46
  • 1.5 Reading a tree: XML and ASCII3:51

Requirements

  • Python, and the ability to read C++ for Section 2 (you do not need to be an expert).
  • Basic ROS 2: what a node, a topic, a service and an action are.
  • Ubuntu 24.04 with ROS 2 Jazzy. No GPU, no robot and no hardware are needed.
  • About 10 GB of free disk for the packages and the simulation.

Description

This course contains the use of artificial intelligence.

A behavior tree is how a robot's decisions are written down so you can read them, test them and change them. This course teaches them with two libraries, BehaviorTree.CPP in C++ and py_trees in Python, and then puts them inside ROS 2 and Nav2 in a simulated TurtleBot3.

Every one of the 43 lectures has a folder you can run: the code from the video, a broken copy with one classic mistake, a script that passes only when the fixed version works and the broken one is caught, and the numbers the lecture quotes. If a number is in the video, the code that produced it is in the folder.

What you will do

- Compare the same mission as a flat state machine and as a tree, and see where each one costs you.
- Learn ticks, statuses, sequences, fallbacks, decorators and parallel nodes by running them.
- Write trees in C++ with BehaviorTree.CPP: ports, the blackboard, running actions, halting, subtrees, XML.
- Write trees in Python with py_trees: behaviours, blackboard, memory, decorators, visitors, unit tests.
- Build recovery, guards, timeouts and cleanup, and measure them over seeded fault-injection runs.
- Run trees inside ROS 2 nodes: topics, services, action clients that cancel on halt, mock servers, launch tests.
- Read and edit Nav2's own navigation tree, load a custom plugin, and measure navigation with and without recovery in simulation.
- Finish with a mission, a regression suite, a CI gate and a capstone you can show.

How the course is built

Each lecture is about 3 to 4 minutes, 2.6 hours in total. The narration is a synthetic voice, and the pictures are generated from the real runs: the tree colours follow a recorded tick trace, and the code and terminal output on screen are the code and output that ran. Every lecture's folder is attached to that lecture as its own zip, each section has a PDF of notes, and the full course is one zip in lecture 1.1.

What this course does not cover

No real robot and no hardware. No MoveIt. No Groot editor. No reinforcement learning or perception. Results come from small simulations and mock worlds with stated fault models, so they show how the trees behave in those setups, not how your robot will perform. It is not an introduction to programming or to ROS 2.

You need Ubuntu 24.04 with ROS 2 Jazzy, Python, and the ability to read C++ for Section 2. No GPU is needed. Lecture 1.1 and the setup and verify scripts show exactly how to check your machine.

Who this course is for:

  • Robotics software engineers and students who use ROS 2 and want to organise robot behavior properly.
  • Developers who have met Nav2's behavior trees and want to understand and change them.
  • Engineers preparing for robotics roles that ask about behavior trees and system integration.
  • Not for complete beginners to programming or to ROS 2.