ROS Tutorial
Follow the official ROS 2 tutorial path in a C++-first format: CLI tools, packages.
01Configuring the ROS EnvironmentConfiguring the ROS Environment Set up shell sourcing, middleware variables, and a repeatable terminal workflow so every ROS command points at the intended installation and workspace. These lessons follow the official ROS 2 beginner tool flow so the codequizbeginner
Configuring the ROS Environment Set up shell sourcing, middleware variables, and a repeatable terminal workflow so every ROS command points at the intended installation and workspace. These lessons follow the official ROS 2 beginner tool flow so the
source /opt/ros/kilted/setup.bash
printenv | grep -E "ROS|RMW"
# after building your own workspace
source ~/robot_ws/install/setup.bash
# optional: isolate one lab group from another
export ROS_DOMAIN_ID=7A key idea in Configuring the ROS Environment is:
A strong way to practice Configuring the ROS Environment is to:
Why does Configuring the ROS Environment matter in ROS?
02Using turtlesim, ros2, and rqtUsing turtlesim, ros2, and rqt Use the tutorial tools to watch a small ROS graph come alive, then inspect it from both the command line and GUI tooling. These lessons follow the official ROS 2 beginner tool flow so the live graph. Built from: Using tcodequizbeginner
Using turtlesim, ros2, and rqt Use the tutorial tools to watch a small ROS graph come alive, then inspect it from both the command line and GUI tooling. These lessons follow the official ROS 2 beginner tool flow so the live graph. Built from: Using t
ros2 run turtlesim turtlesim_node
ros2 run turtlesim turtle_teleop_key
ros2 node list
ros2 topic list
ros2 interface show geometry_msgs/msg/TwistA key idea in Using turtlesim, ros2, and rqt is:
A strong way to practice Using turtlesim, ros2, and rqt is to:
Why does Using turtlesim, ros2, and rqt matter in ROS?
03Understanding Nodes and TopicsUnderstanding Nodes and Topics Learn what nodes own in the graph and how topics carry streaming robot data between them. These lessons follow the official ROS 2 beginner tool flow so the live graph. Built from: Understanding nodes, Understanding topicodequizbeginner
Understanding Nodes and Topics Learn what nodes own in the graph and how topics carry streaming robot data between them. These lessons follow the official ROS 2 beginner tool flow so the live graph. Built from: Understanding nodes, Understanding topi
ros2 node list
ros2 node info /turtlesim
ros2 topic list
ros2 topic info /turtle1/pose
ros2 topic echo /turtle1/pose
ros2 topic hz /turtle1/poseA key idea in Understanding Nodes and Topics is:
A strong way to practice Understanding Nodes and Topics is to:
Why does Understanding Nodes and Topics matter in ROS?
04Understanding Services and ParametersUnderstanding Services and Parameters Study short request-response behavior and runtime configuration so control and tuning choices remain explicit. These lessons follow the official ROS 2 beginner tool flow so the live graph. Built from: Understandicodequizbeginner
Understanding Services and Parameters Study short request-response behavior and runtime configuration so control and tuning choices remain explicit. These lessons follow the official ROS 2 beginner tool flow so the live graph. Built from: Understandi
ros2 service list
ros2 service type /clear
ros2 service call /clear std_srvs/srv/Empty "{}"
ros2 param list /turtlesim
ros2 param describe /turtlesim background_b
ros2 param set /turtlesim background_b 220A key idea in Understanding Services and Parameters is:
A strong way to practice Understanding Services and Parameters is to:
Why does Understanding Services and Parameters matter in ROS?
05Understanding Actions and LogsUnderstanding Actions and Logs Use actions for goal-oriented work and logs for observability so longer-running robot tasks remain explainable. These lessons follow the official ROS 2 beginner tool flow so the live graph. Built from: Understanding actcodequizbeginner
Understanding Actions and Logs Use actions for goal-oriented work and logs for observability so longer-running robot tasks remain explainable. These lessons follow the official ROS 2 beginner tool flow so the live graph. Built from: Understanding act
ros2 action list
ros2 action info /turtle1/rotate_absolute
ros2 action send_goal /turtle1/rotate_absolute turtlesim/action/RotateAbsolute "{theta: 1.57}"
ros2 run turtlesim turtlesim_node --ros-args --log-level debug
ros2 run rqt_console rqt_consoleA key idea in Understanding Actions and Logs is:
A strong way to practice Understanding Actions and Logs is to:
Why does Understanding Actions and Logs matter in ROS?
06Launching NodesLaunching Nodes Start multiple nodes as one repeatable unit and inspect what actually came up. These lessons follow the official ROS 2 beginner tool flow so the live graph. Built from: Launching nodes. Lab note: ROS work spans shell commands, launch codequizbeginner
Launching Nodes Start multiple nodes as one repeatable unit and inspect what actually came up. These lessons follow the official ROS 2 beginner tool flow so the live graph. Built from: Launching nodes. Lab note: ROS work spans shell commands, launch
ros2 launch demo_nodes_cpp topics_talker_listener.launch.py
ros2 node list
ros2 topic listA key idea in Launching Nodes is:
A strong way to practice Launching Nodes is to:
Why does Launching Nodes matter in ROS?
07Recording and Playing Back DataRecording and Playing Back Data Capture live message traffic with rosbag2, inspect what you recorded, and replay it to reproduce behavior without hardware in the loop. These lessons follow the official ROS 2 beginner tool flow so the live graph. Builcodequizbeginner
Recording and Playing Back Data Capture live message traffic with rosbag2, inspect what you recorded, and replay it to reproduce behavior without hardware in the loop. These lessons follow the official ROS 2 beginner tool flow so the live graph. Buil
ros2 bag record /turtle1/cmd_vel /turtle1/pose
# stop recording after a short run
ros2 bag info rosbag2_*
ros2 bag play rosbag2_*A key idea in Recording and Playing Back Data is:
A strong way to practice Recording and Playing Back Data is to:
Why does Recording and Playing Back Data matter in ROS?
08Diagnosing the Graph with ros2doctorDiagnosing the Graph with ros2doctor Use the built-in health checks and quick graph inspection tools before diving into deeper debugging. These lessons follow the official ROS 2 beginner tool flow so the live graph. Built from: Using ros2doctor to idcodequizbeginner
Diagnosing the Graph with ros2doctor Use the built-in health checks and quick graph inspection tools before diving into deeper debugging. These lessons follow the official ROS 2 beginner tool flow so the live graph. Built from: Using ros2doctor to id
ros2 doctor --report
ros2 pkg list
ros2 interface listA key idea in Diagnosing the Graph with ros2doctor is:
A strong way to practice Diagnosing the Graph with ros2doctor is to:
Why does Diagnosing the Graph with ros2doctor matter in ROS?
09Using colcon and Creating a WorkspaceUsing colcon and Creating a Workspace Build a workspace with colcon, understand the build output directories, and keep source code organized where ROS tooling expects it. This module turns CLI understanding into real C++ package work so the course becodequizbeginner
Using colcon and Creating a Workspace Build a workspace with colcon, understand the build output directories, and keep source code organized where ROS tooling expects it. This module turns CLI understanding into real C++ package work so the course be
mkdir -p ~/robot_ws/src
cd ~/robot_ws
colcon build --symlink-install
source install/setup.bashA key idea in Using colcon and Creating a Workspace is:
A strong way to practice Using colcon and Creating a Workspace is to:
Why does Using colcon and Creating a Workspace matter in ROS?
10Creating a PackageCreating a Package Generate a new ROS package, inspect its metadata, and connect the package structure to long-term maintainability. This module turns CLI understanding into real C++ package work so the course becomes. Built from: Creating a package.codequizbeginner
Creating a Package Generate a new ROS package, inspect its metadata, and connect the package structure to long-term maintainability. This module turns CLI understanding into real C++ package work so the course becomes. Built from: Creating a package.
cd ~/robot_ws/src
ros2 pkg create learning_cpp --build-type ament_cmake --dependencies rclcpp std_msgs
cd ~/robot_ws
colcon build --packages-select learning_cppA key idea in Creating a Package is:
A strong way to practice Creating a Package is to:
Why does Creating a Package matter in ROS?
11Writing a Publisher and Subscriber in C++Writing a Publisher and Subscriber in C++ Build the first topic-driven C++ nodes so publishing, subscribing, and callback flow become concrete in code. This module turns CLI understanding into real C++ package work so the course becomes. Built from: codequizbeginner
Writing a Publisher and Subscriber in C++ Build the first topic-driven C++ nodes so publishing, subscribing, and callback flow become concrete in code. This module turns CLI understanding into real C++ package work so the course becomes. Built from:
# inside your package source and CMake files
colcon build --packages-select learning_cpp
source install/setup.bash
ros2 run learning_cpp talker
ros2 run learning_cpp listenerA key idea in Writing a Publisher and Subscriber in C++ is:
A strong way to practice Writing a Publisher and Subscriber in C++ is to:
Why does Writing a Publisher and Subscriber in C++ matter in ROS?
12Writing a Service and Client in C++Writing a Service and Client in C++ Implement a short request-response path in C++ and compare it with topic-based communication. This module turns CLI understanding into real C++ package work so the course becomes. Built from: Writing a simple servicodequizbeginner
Writing a Service and Client in C++ Implement a short request-response path in C++ and compare it with topic-based communication. This module turns CLI understanding into real C++ package work so the course becomes. Built from: Writing a simple servi
colcon build --packages-select learning_cpp
source install/setup.bash
ros2 run learning_cpp server
ros2 run learning_cpp client 4 8A key idea in Writing a Service and Client in C++ is:
A strong way to practice Writing a Service and Client in C++ is to:
Why does Writing a Service and Client in C++ matter in ROS?
13Creating Custom msg, srv, and Action InterfacesCreating Custom msg, srv, and Action Interfaces Define your own interfaces so packages can share contracts that match the robot domain instead of forcing awkward reuse. This module turns CLI understanding into real C++ package work so the course becocodequizintermediate
Creating Custom msg, srv, and Action Interfaces Define your own interfaces so packages can share contracts that match the robot domain instead of forcing awkward reuse. This module turns CLI understanding into real C++ package work so the course beco
# msg/SensorHealth.msg
string label
float64 reading
# action/Fibonacci.action
int32 order
---
int32[] sequence
---
int32[] partial_sequenceA key idea in Creating Custom msg, srv, and Action Interfaces is:
A strong way to practice Creating Custom msg, srv, and Action Interfaces is to:
Why does Creating Custom msg, srv, and Action Interfaces matter in ROS?
14Using Parameters in a Class and Creating Plugins in C++Using Parameters in a Class and Creating Plugins in C++ Connect runtime configuration to a C++ node class and learn how plugin metadata lets ROS tools load new behavior dynamically. This module turns CLI understanding into real C++ package work so thcodequizintermediate
Using Parameters in a Class and Creating Plugins in C++ Connect runtime configuration to a C++ node class and learn how plugin metadata lets ROS tools load new behavior dynamically. This module turns CLI understanding into real C++ package work so th
declare_parameter("max_speed", 0.5);
double max_speed = get_parameter("max_speed").as_double();
# plugin_description.xml
<library path="lib/libmy_plugin">
<class type="my_pkg::Plugin" base_class_type="rviz_common::Display"/>
</library>A key idea in Using Parameters in a Class and Creating Plugins in C++ is:
A strong way to practice Using Parameters in a Class and Creating Plugins in C++ is to:
Why does Using Parameters in a Class and Creating Plugins in C++ matter in ROS?
15Managing Dependencies with rosdepManaging Dependencies with rosdep Resolve external dependencies from package metadata so machines can reproduce the same setup without manual guesswork. These lessons move into the intermediate ROS runtime layer where dependencies, actions, compositicodequizintermediate
Managing Dependencies with rosdep Resolve external dependencies from package metadata so machines can reproduce the same setup without manual guesswork. These lessons move into the intermediate ROS runtime layer where dependencies, actions, compositi
cd ~/robot_ws
rosdep install --from-paths src --ignore-src -r -yA key idea in Managing Dependencies with rosdep is:
A strong way to practice Managing Dependencies with rosdep is to:
Why does Managing Dependencies with rosdep matter in ROS?
16Building Action Servers and Clients in C++Building Action Servers and Clients in C++ Define a long-running task contract and implement the client and server sides in C++ with feedback and cancellation. These lessons move into the intermediate ROS runtime layer where dependencies, actions, cocodequizintermediate
Building Action Servers and Clients in C++ Define a long-running task contract and implement the client and server sides in C++ with feedback and cancellation. These lessons move into the intermediate ROS runtime layer where dependencies, actions, co
colcon build --packages-select learning_cpp
source install/setup.bash
ros2 run learning_cpp fibonacci_action_server
ros2 run learning_cpp fibonacci_action_clientA key idea in Building Action Servers and Clients in C++ is:
A strong way to practice Building Action Servers and Clients in C++ is to:
Why does Building Action Servers and Clients in C++ matter in ROS?
17Writing a Composable Node in C++Writing a Composable Node in C++ Turn a node into a component that can be loaded into a shared process when that deployment tradeoff makes sense. These lessons move into the intermediate ROS runtime layer where dependencies, actions, composition, andcodequizintermediate
Writing a Composable Node in C++ Turn a node into a component that can be loaded into a shared process when that deployment tradeoff makes sense. These lessons move into the intermediate ROS runtime layer where dependencies, actions, composition, and
#include <rclcpp_components/register_node_macro.hpp>
RCLCPP_COMPONENTS_REGISTER_NODE(demo_nodes_cpp::Talker)A key idea in Writing a Composable Node in C++ is:
A strong way to practice Writing a Composable Node in C++ is to:
Why does Writing a Composable Node in C++ matter in ROS?
18Composing Multiple Nodes and Using Node InterfacesComposing Multiple Nodes and Using Node Interfaces Place several components in one process and use node interfaces when reusable infrastructure code should depend on less than a full node type. These lessons move into the intermediate ROS runtime laycodequizintermediate
Composing Multiple Nodes and Using Node Interfaces Place several components in one process and use node interfaces when reusable infrastructure code should depend on less than a full node type. These lessons move into the intermediate ROS runtime lay
ros2 run composition manual_composition
ros2 component list
auto logging = node_like.get_node_logging_interface();A key idea in Composing Multiple Nodes and Using Node Interfaces is:
A strong way to practice Composing Multiple Nodes and Using Node Interfaces is to:
Why does Composing Multiple Nodes and Using Node Interfaces matter in ROS?
19Publishing from YAML and Monitoring Parameter ChangesPublishing from YAML and Monitoring Parameter Changes Use file-driven configuration and parameter callbacks so runtime behavior stays reviewable and adjustable. These lessons move into the intermediate ROS runtime layer where dependencies, actions, ccodequizintermediate
Publishing from YAML and Monitoring Parameter Changes Use file-driven configuration and parameter callbacks so runtime behavior stays reviewable and adjustable. These lessons move into the intermediate ROS runtime layer where dependencies, actions, c
controller:
ros__parameters:
max_speed: 0.45
publish_rate: 20.0
on_set_parameters_callback(handle_parameter_changes);A key idea in Publishing from YAML and Monitoring Parameter Changes is:
A strong way to practice Publishing from YAML and Monitoring Parameter Changes is to:
Why does Publishing from YAML and Monitoring Parameter Changes matter in ROS?
20Launch Architecture: Packages, Substitutions, and Event HandlersLaunch Architecture: Packages, Substitutions, and Event Handlers Package launch assets properly and use substitutions and event handlers to keep bringup flexible without turning it into chaos. These lessons move into the intermediate ROS runtime layecodequizintermediate
Launch Architecture: Packages, Substitutions, and Event Handlers Package launch assets properly and use substitutions and event handlers to keep bringup flexible without turning it into chaos. These lessons move into the intermediate ROS runtime laye
from launch.actions import DeclareLaunchArgument, RegisterEventHandler
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import NodeA key idea in Launch Architecture: Packages, Substitutions, and Event Handlers is:
A strong way to practice Launch Architecture: Packages, Substitutions, and Event Handlers is to:
Why does Launch Architecture: Packages, Substitutions, and Event Handlers matter in ROS?
21Managing Large Launch ProjectsManaging Large Launch Projects Split bringup into smaller launch units so larger robot systems remain readable, reviewable, and changeable. This part of the course is about orchestration: larger bringup flows, frame reasoning, and. Built from: Managicodequizintermediate
Managing Large Launch Projects Split bringup into smaller launch units so larger robot systems remain readable, reviewable, and changeable. This part of the course is about orchestration: larger bringup flows, frame reasoning, and. Built from: Managi
robot_bringup/
launch/
sensors.launch.py
control.launch.py
navigation.launch.py
robot.launch.pyA key idea in Managing Large Launch Projects is:
A strong way to practice Managing Large Launch Projects is to:
Why does Managing Large Launch Projects matter in ROS?
22Introducing tf2 and Static TransformsIntroducing tf2 and Static Transforms Build the mental model for coordinate frames and publish a fixed relationship between two frames so the tree becomes tangible. This part of the course is about orchestration: larger bringup flows, frame reasoningcodequizintermediate
Introducing tf2 and Static Transforms Build the mental model for coordinate frames and publish a fixed relationship between two frames so the tree becomes tangible. This part of the course is about orchestration: larger bringup flows, frame reasoning
ros2 run tf2_ros static_transform_publisher 0 0 0 0 0 0 base_link laser_frame
ros2 run tf2_tools view_framesA key idea in Introducing tf2 and Static Transforms is:
A strong way to practice Introducing tf2 and Static Transforms is to:
Why does Introducing tf2 and Static Transforms matter in ROS?
23Broadcasters, Listeners, Time, Quaternions, and tf2 DebuggingBroadcasters, Listeners, Time, Quaternions, and tf2 Debugging Publish dynamic transforms from C++, consume them safely, reason about rotation and time, and use debugging tools when the frame tree goes wrong. This part of the course is about orchestracodequizintermediate
Broadcasters, Listeners, Time, Quaternions, and tf2 Debugging Publish dynamic transforms from C++, consume them safely, reason about rotation and time, and use debugging tools when the frame tree goes wrong. This part of the course is about orchestra
auto transform = buffer_->lookupTransform("map", "base_link", tf2::TimePointZero);
ros2 run tf2_ros tf2_echo map base_link
ros2 run tf2_tools view_framesA key idea in Broadcasters, Listeners, Time, Quaternions, and tf2 Debugging is:
A strong way to practice Broadcasters, Listeners, Time, Quaternions, and tf2 Debugging is to:
Why does Broadcasters, Listeners, Time, Quaternions, and tf2 Debugging matter in ROS?
24URDF from Links and Joints to XacroURDF from Links and Joints to Xacro Describe a robot with links, joints, visuals, collisions, and reusable Xacro structure so the rest of the stack has a coherent model to rely on. This part of the course is about orchestration: larger bringup flows,codequizadvanced
URDF from Links and Joints to Xacro Describe a robot with links, joints, visuals, collisions, and reusable Xacro structure so the rest of the stack has a coherent model to rely on. This part of the course is about orchestration: larger bringup flows,
<robot name="learning_bot">
<link name="base_link"/>
<joint name="laser_joint" type="fixed"/>
<link name="laser_link"/>
</robot>A key idea in URDF from Links and Joints to Xacro is:
A strong way to practice URDF from Links and Joints to Xacro is to:
Why does URDF from Links and Joints to Xacro matter in ROS?
25robot_state_publisher and RVizrobot_state_publisher and RViz Feed a robot description into robot_state_publisher and visualize the result in RViz so frame and model assumptions become visible. This part of the course is about orchestration: larger bringup flows, frame reasoning, codequizadvanced
robot_state_publisher and RViz Feed a robot description into robot_state_publisher and visualize the result in RViz so frame and model assumptions become visible. This part of the course is about orchestration: larger bringup flows, frame reasoning,
ros2 run robot_state_publisher robot_state_publisher <path-to-urdf>
rviz2A key idea in robot_state_publisher and RViz is:
A strong way to practice robot_state_publisher and RViz is to:
Why does robot_state_publisher and RViz matter in ROS?
26Testing with CLI, GTest, and launch_testingTesting with CLI, GTest, and launch_testing Run tests from the workspace, add focused C++ unit tests, and use launch-based integration tests when node interactions matter. The last module compresses the advanced ROS tutorial themes into production hacodequizadvanced
Testing with CLI, GTest, and launch_testing Run tests from the workspace, add focused C++ unit tests, and use launch-based integration tests when node interactions matter. The last module compresses the advanced ROS tutorial themes into production ha
colcon test --packages-select learning_cpp
colcon test-result --verbose
ament_add_gtest(test_controller test/test_controller.cpp)A key idea in Testing with CLI, GTest, and launch_testing is:
A strong way to practice Testing with CLI, GTest, and launch_testing is to:
Why does Testing with CLI, GTest, and launch_testing matter in ROS?
27Topic Statistics and Custom AllocatorsTopic Statistics and Custom Allocators Measure message behavior with topic statistics and understand why memory allocation strategy can matter in tighter runtime loops. The last module compresses the advanced ROS tutorial themes into production habitcodequizadvanced
Topic Statistics and Custom Allocators Measure message behavior with topic statistics and understand why memory allocation strategy can matter in tighter runtime loops. The last module compresses the advanced ROS tutorial themes into production habit
options.topic_stats_options.state = rclcpp::TopicStatisticsState::Enable;
using VoidAlloc = std::allocator<void>;
rclcpp::PublisherOptionsWithAllocator<VoidAlloc> pub_options;A key idea in Topic Statistics and Custom Allocators is:
A strong way to practice Topic Statistics and Custom Allocators is to:
Why does Topic Statistics and Custom Allocators matter in ROS?
28Recording and Reading rosbag2 Data in C++Recording and Reading rosbag2 Data in C++ Move from CLI bag usage to programmatic bag writing and reading so data workflows can become part of your own tools. The last module compresses the advanced ROS tutorial themes into production habits around tcodequizadvanced
Recording and Reading rosbag2 Data in C++ Move from CLI bag usage to programmatic bag writing and reading so data workflows can become part of your own tools. The last module compresses the advanced ROS tutorial themes into production habits around t
#include <rosbag2_cpp/writer.hpp>
#include <rosbag2_cpp/reader.hpp>
rosbag2_cpp::Writer writer;
rosbag2_cpp::Reader reader;A key idea in Recording and Reading rosbag2 Data in C++ is:
A strong way to practice Recording and Reading rosbag2 Data in C++ is to:
Why does Recording and Reading rosbag2 Data in C++ matter in ROS?
29Tracing, Simulators, and SecurityTracing, Simulators, and Security Use tracing to inspect runtime timing, understand how simulators fit the broader ROS path, and set up the basics of secure communication. The last module compresses the advanced ROS tutorial themes into production hacodequizadvanced
Tracing, Simulators, and Security Use tracing to inspect runtime timing, understand how simulators fit the broader ROS path, and set up the basics of secure communication. The last module compresses the advanced ROS tutorial themes into production ha
ros2 trace
export ROS_SECURITY_ENABLE=true
export ROS_SECURITY_STRATEGY=Enforce
export ROS_SECURITY_KEYSTORE=~/security/demo_keystoreA key idea in Tracing, Simulators, and Security is:
A strong way to practice Tracing, Simulators, and Security is to:
Why does Tracing, Simulators, and Security matter in ROS?
30QoS, Managed Lifecycles, Intra-Process Communication, and Real-Time PatternsQoS, Managed Lifecycles, Intra-Process Communication, and Real-Time Patterns Finish with the runtime policies that shape deployable robot software: QoS, lifecycle state, intra-process delivery, timing discipline, and deeper introspection habits. The codequizadvanced
QoS, Managed Lifecycles, Intra-Process Communication, and Real-Time Patterns Finish with the runtime policies that shape deployable robot software: QoS, lifecycle state, intra-process delivery, timing discipline, and deeper introspection habits. The
rclcpp::QoS qos(rclcpp::KeepLast(10));
qos.best_effort().durability_volatile();
class ManagedNode : public rclcpp_lifecycle::LifecycleNode {};A key idea in QoS, Managed Lifecycles, Intra-Process Communication, and Real-Time Patterns is:
A strong way to practice QoS, Managed Lifecycles, Intra-Process Communication, and Real-Time Patterns is to:
Why does QoS, Managed Lifecycles, Intra-Process Communication, and Real-Time Patterns matter in ROS?