Udemy
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Modern C++ for ROS 2 Engineers: Ownership, Threads, Latency
New

Modern C++ for ROS 2 Engineers: Ownership, Threads, Latency

Write safer, faster rclcpp nodes: count copies, catch races with sanitizers, measure latency, and test it.
Last updated 11/2026
English
English

What you'll learn

  • Write an rclcpp node with visible ownership: RAII, const, unique_ptr and shared_ptr, no raw new or delete.
  • Count hidden copies and allocations with a counting type, and see intra-process zero-copy in a real run.
  • Catch a use-after-free with AddressSanitizer and a data race with ThreadSanitizer, then fix it with a mutex, an atomic or a queue.
  • Choose callback styles, executors and callback groups, and see what really runs at once.
  • Use templates, concepts, constexpr and std::span so mistakes show up at compile time.
  • Measure callback latency as percentiles, find the hot function with callgrind, and remove an allocation from the hot path.
  • Write GoogleTest cases that fail on a real boundary bug, and rerun every lab from one scoreboard script.
  • Know the limits: timings are noisy, and none of this makes a node hard real time.

Course content

6 sections • 20 lectures • 2h 17m total length
  • 1.1 What you build, and the first bug the machine finds6:27
  • 1.2 Set up the tools, and make verify mean it6:37
  • 1.3 A node done right: RAII, const, no raw new6:13
  • 1.4 Param structs, optional, and variant6:12

Requirements

  • Basic C++ (functions, classes, vectors) and a Linux terminal.
  • g++ with C++20, valgrind and GoogleTest installed; ROS 2 Jazzy with rclcpp and colcon for the node labs (lecture 1.2 checks all of it).
  • About 4 GB of free memory; no robot or GPU needed.

Description

This course contains the use of artificial intelligence. The narration is a synthetic voice; the code, terminal output and numbers on screen are real runs on one laptop, recorded once and shown as they happened, including the failures.

20 lectures, about 137 minutes. You learn the C++ that matters inside a ROS 2 node by running it: every lecture has a small lab with a check script that compiles and runs real code and ends in PASS or FAIL, and the narration explains the code that is on screen.

What you do: write a node with clear ownership instead of raw new and delete; count copies and allocations with a counting type instead of guessing; see intra-process zero-copy change a pointer; catch a use-after-free with AddressSanitizer and a data race with ThreadSanitizer and fix both; use templates, concepts, constexpr and std::span to move mistakes to compile time; measure callback latency with percentiles, find a hot function with callgrind and remove an allocation from a hot path; write GoogleTest cases that go red on a real boundary bug; finish with a scoreboard that reruns a lab from every part.

The course is honest about limits: counts such as allocations and copies are exact, but timings come from one laptop and are noisy, and nothing here makes your node hard real time. The last lecture says plainly what a green table does not prove and what to learn next, such as a PREEMPT_RT kernel.

What this course does not cover: a full robot, navigation, simulation, hardware, or hard real-time guarantees. You need Linux, a terminal, g++ with C++20, valgrind and GoogleTest, and ROS 2 Jazzy with rclcpp and colcon for the node labs. You should already know basic C++ syntax.

Who this course is for:

  • ROS 2 users who write C++ nodes and want them safer and faster.
  • Robotics students moving from Python to C++ who want practice with ownership, threads and tests.
  • Engineers who want sanitizers and measurements as a daily habit, not a one-off.