ROS 2 LearningAugust 14, 20257 min read

How to Start with ROS 2

Learn how to start with ROS 2 the right way. Build C++ skills, understand core ROS 2 tools, and deploy your first node using a practical learning roadmap.

How to Start with ROS 2

Share :

Quick answer

Learn how to start with ROS 2 the right way. Build C++ skills, understand core ROS 2 tools, and deploy your first node using a practical learning roadmap.

Quick Answer

Learn how to start with ROS 2 the right way. Build C++ skills, understand core ROS 2 tools, and deploy your first node using a practical learning roadmap.

Who This Is For

  • ROS 2 Learner
  • Robotics Student
  • Software Developer

What You Will Learn

  • What ROS 2 means in practical robotics.
  • How this topic connects to real robot projects.
  • What to learn or build next after this article.

A Foundational Roadmap for Mastering ROS 2

If you've decided to dive into ROS 2 (Robot Operating System 2), the learning curve might hit you like a brick wall. You're expected to understand C++, a new build system (ament), and a messaging architecture-all at once. On top of that, most tutorials assume you already know how to work with terminals and Linux systems. That's why it's important to follow a clear plan on how to start with ROS 2-one that builds your foundation step by step instead of overwhelming you from the start. Instead of randomly jumping from tutorial to tutorial, what you need is astructured roadmap. A plan that separates the core skills you need and helps you master them in the right sequence. This blog will walk you through theexact steps to start learning ROS 2 the right way.

Phase 1: C++ Foundation - Before ROS 2

Why Start with C++?

ROS 2 is built primarily in C++. That means if you don't understand C++, your ability to read, write, or debug ROS 2 nodes will be limited. By first mastering the language outside of the ROS ecosystem, you isolate your variables: when your code fails, it's not because of ROS-it's just the C++.

Step 1: Write Single-File C++ Programs

Start with classic programs like:

cpp
#include <iostream>
using namespace std;
int main() {
    cout << "Hello, ROS 2!" << endl;
    return 0;
}

Compile with:

bash
g++ hello.cpp -o hello
./hello

This helps you build a mental model of how code turns into an executable. No build system. No packages. Just logic.

Step 2: Move to Multi-File Projects

Split your code into:

  • main.cpp
  • MotorController.cpp
  • MotorController.hpp Compile like this:
bash
g++ main.cpp MotorController.cpp -o robot_program

Learning this prepares you for the modular programming structure used in ROS 2 packages, which follow a similar convention.

Phase 2: Software Engineering with CMake

Step 1: Learn Modern CMake

CMake is the underlying build system of ROS 2 (ament_cmake). Here's a minimal CMakeLists.txt to compile your multi-file project:

cmake
cmake_minimum_required(VERSION 3.10)
project(my_robot)
add_executable(robot_node main.cpp MotorController.cpp)

Use this to generate your build:

bash
mkdir build && cd build
cmake ..
make

Understanding this prepares you for more advanced ament_cmake-based ROS 2 projects.

Structure your code into libraries such as:

  • libMotorDriver
  • libSensorFusion
  • libPowerManagement Then, link them to your executable:
cmake
add_library(motor_driver MotorDriver.cpp)
target_link_libraries(robot_node motor_driver)

Thismodular approach mirrors how ROS 2 breaks complex systems into nodes and packages.

Step 3: Add Unit Tests

Integrate GoogleTest:

cmake
enable_testing()
add_executable(test_motor test_motor.cpp)
target_link_libraries(test_motor motor_driver gtest_main)
add_test(NAME MotorTest COMMAND test_motor)

By learning how to test your logic before touching ROS 2, you eliminate guesswork later when debugging robotic behaviors.

Phase 3: Command Line + ROS 2 Concepts

Become Fluent with the Terminal

If you're not comfortable using commands like cd, mkdir, source, or export, you'll struggle in ROS 2. These are essential for setting up and managing workspaces, launching nodes, and inspecting running systems. Linux Journey offers a beginner-friendly CLI learning path.

Phase 4: First Steps Inside the ROS 2 Ecosystem

Understanding ROS 2 Communication: Topics, Nodes, and Messages

Create two workspaces:

  • colcon_ws_A -> with a talker node
  • colcon_ws_B -> with a listener node In your talker node:
cpp
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr publisher_;
publisher_ = this->create_publisher<std_msgs::msg::String>("chatter", 10);

In the listener node, subscribe to chatter. Use the CLI to monitor:

bash
ros2 topic echo /chatter
rqt_graph

This phase teaches how nodespublish and subscribe to topics, which forms the backbone of ROS 2 communication.

Phase 5: C++ + ROS 2 Integration

Step 1: Use Gazebo Simulation

Launch TurtleBot3 simulation:

bash
export TURTLEBOT3_MODEL=burger
ros2 launch turtlebot3_gazebo turtlebot3_world.launch.py

Publish a command:

bash
ros2 topic pub /cmd_vel geometry_msgs/Twist "{linear: {x: 0.1}, angular: {z: 0.1}}"

By interacting with /scan, /odom, and /cmd_vel, you see how simulation and ROS 2 are integrated. Explore simulation-ready TurtleBot3 packages for practical applications.

Step 2: Embed Your C++ Library Inside a ROS 2 Node

Let's say you built a libSensorFusion in Phase 2. Now:

  1. Create a ROS 2 package:
bash
ros2 pkg create --build-type ament_cmake sensor_node
  1. Copy your .cpp and .hpp into the src directory.
  2. Update CMakeLists.txt:
cmake
add_library(sensor_fusion src/SensorFusion.cpp)
add_executable(sensor_node src/sensor_node.cpp)
target_link_libraries(sensor_node sensor_fusion)
  1. Use your class inside the node:
cpp
#include "SensorFusion.hpp"
auto filtered = sensor_fusion.process(raw_imu_data);

This structure separates yourcore logic from ROS-specific code. It's easier to debug, extend, and test.

Learning Path Chart

Here's how your progression should look:

  • Phase
  • Skills Gained
  • Tools Used C++ BasicsSyntax, classes, filesg++, terminalBuild SystemsModular code, CMakeCMake, GoogleTestROS 2 IntroTopics, CLI, multi-node architectureros2 CLI, colcon, rqtSimulationReal-time robot interactionGazebo, TurtleBot3IntegrationPackage creation, abstractionROS 2 packages, libraries

ROS 2 the Right Way

By following this roadmap, you're not just learning commands-you're learning software development for robotics. You'll no longer get stuck wondering, "Is the issue in my C++ code, or is ROS 2 acting weird?" You'll know where to look. This learning sequence reflects how real mobile robotics engineers at Robotisim train beginners-from C++ to deployment on real robots. Their structured Mobile Robotics Engineering course is built around how to start with ROS 2 the right way, turning this roadmap into a practical, hands-on experience that builds real skills.

Final Thoughts

If you start with tutorials without foundational skills, every error feels like magic. But if you follow the step-by-step roadmap above-starting with C++, mastering CMake, and finally entering ROS 2 with clarity-you'll build working robots, not frustration. This is how to start with ROS 2 in a way that actually works-by focusing on fundamentals before diving into complexity. The ROS 2 documentation, ROS Answers, and Robotisim's Learning Path will make a lot more sense once you have this grounding. So take a step back, breathe, and build each layer properly. You're not late to ROS 2. You just needed a better map.

Practical Example

A practical way to use this article is to connect the concept to a small robot workflow: identify the input, the processing step, and the output you expect from the robot. If the article involves ROS 2, test the idea in a small workspace or simulation before applying it to a larger robot project.

Common Mistakes

  • Trying to memorize the term without connecting it to a robot behavior.
  • Skipping the prerequisite concepts that make the workflow easier to debug.
  • Copying commands or code without checking what each node, topic, file, or parameter is responsible for.
  • Treating one tutorial as a complete roadmap instead of linking it to the next concept.

How This Connects to Other Topics

  • 3D Printing Robotics Hardware for an Autonomous Robot Build
  • How to Collect Raw Sensor Data for Robotics with ROS 2
  • How to Add Custom Libraries to a ROS 2 Python Package
  • How to Start Developing in ROS 2: A Beginner-Friendly Guide
  • How to Finish Your First ROS Robotics Project

Learn Next

  • 3D Printing Robotics Hardware for an Autonomous Robot Build
  • How to Collect Raw Sensor Data for Robotics with ROS 2
  • How to Add Custom Libraries to a ROS 2 Python Package
  • How to Start Developing in ROS 2: A Beginner-Friendly Guide
  • How to Finish Your First ROS Robotics Project
  • ROS 2 Foundation Path

FAQ

Is How to Start with ROS 2 suitable for beginners?

Yes. The article is written to make the concept easier to understand, while still connecting it to practical robotics work.

What should I learn before this topic?

Start with the prerequisite ideas listed in the article, then connect them to a small project or simulation so the concept becomes concrete.

How does this topic connect to real robots?

It helps you understand how software, sensors, control, simulation, or career decisions show up in practical robot development.

What should I do after reading this article?

Pick one related concept from the Learn Next section and build a small example that uses it.

Can I learn this through Robotisim?

Yes. Robotisim connects these concepts to structured learning paths and project-based robotics practice.

Final Summary

How to Start with ROS 2 is part of the broader ROS 2 Learning learning path. The key is to understand the concept, connect it to a real robot workflow, and then practice it through a focused project instead of learning it in isolation.

Connected learning path

This article supports ROS 2 Foundation Path, especially ROS 2.

Learn with Robotisim

Start learning ROS 2 step by step inside Robotisim.

Explore the academy

Learn next

3D Printing Robotics Hardware for an Autonomous Robot Build
Jun 03, 2025|7 min read

3D Printing Robotics Hardware for an Autonomous Robot Build

Discover how to 3D print robotics hardware for building autonomous robots. Learn key steps from assembly to motion control with ROS 2

Read more
How to Collect Raw Sensor Data for Robotics with ROS 2
Jun 05, 2025|7 min read

How to Collect Raw Sensor Data for Robotics with ROS 2

Learn to integrate sensors with ROS 2 and collect raw sensor data for robotics. Guide on real time data processing and sensor fusion for autonomous robots.

Read more
How to Add Custom Libraries to a ROS 2 Python Package
Jun 02, 2024|6 min read

How to Add Custom Libraries to a ROS 2 Python Package

Learn to create custom libraries for ROS 2 Python packages. Enhance your robotics projects with reusable code and improve your development workflow!

Read more
How to Start Developing in ROS 2: A Beginner-Friendly Guide
Jun 02, 2024|8 min read

How to Start Developing in ROS 2: A Beginner-Friendly Guide

Begin your ROS 2 development journey with our guide. Learn key concepts and setup for creating effective robotics applications in no time!

Read more