ROS 2 LearningJune 02, 20248 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!

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

Share :

Quick answer

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

Quick Answer

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

Who This Is For

  • ROS 2 Learner
  • Robotics Student
  • Software Developer

What You Will Learn

Introduction

ROS 2 is an open-source framework on which a huge number of people are working. To make all the work from these contributors useful, development standards are introduced. People who are just starting out have to follow procedures that make things confusing and hard . For example

  • Every change needs to be build before running
  • A lot of files are auto generated and you find them usless and confusing
  • Colcon build has to be in workspace root; otherwise, other wise things do not work.

Starting Point

  • No understanding of fies in a ROS 2 package
  • Confused by auto generated structure in a package
  • Cannot decide between Python and C++ package

Learning Outcomes

  • When to use CPP Package and when to use Python Package
  • Comfortable with CmakeLists and setup.py
  • Clear about structure generated by Colcon build

What are the requirements of installing ROS 2

Ubuntu Specific Compatibility

ROS 2 versions have specific documentation pages,like this one is for ros2 humble . ROS 2 distributions are closely tied to specific Ubuntu versions. This ensures that developers have a stable and consistent environment, as the underlying libraries and tools provided by Ubuntu are version-specific and tested for compatibility with ROS 2.The tight coupling between ROS 2 versions and Ubuntu ensures that the dependencies and libraries used by ROS 2 are stable and tested. This minimises compatibility issues and provides a consistent development environment. Article image Although this can be taken care of through Docker or virtual machines,. Let's discuss the architecture of ROS 2 development.

What are ROS 2 Workspaces and packages?

Workspace : System-level isolation

A workspace in ROS 2 is a directory where you can create, build, and manage your ROS 2 projects. It serves as an isolated environment where all the necessary files and dependencies for your projects are stored. Workspaces provide a structured way to organise your projects. They help manage different versions of packages, dependencies, and configurations, ensuring that your development environment remains clean and manageable. Workspace is simply a directory on your computer before a package and colcon building. You create it with below commands

mkdir -p ~/ros2_ws/src
cd ~/ros2_ws
colcon build

This colcon build in ros2_ws creates the following directories ( independent of location;starters make this mistake a lotand every where they have below mentioned directors):

ros2_ws
|-- build # Stores intermediate build files and compilation artifacts.
|-- log # Stores log files generated during the build and run processes.
|-- install # Contains the final built executables, scripts, and resources ready for deployment.
`-- src # Contains the source code of your ROS 2 packages.

Package : Development level isolation

Packages are the fundamental units of software in ROS 2. They contain nodes, libraries, datasets, configuration files, and more, all bundled together to perform specific tasks.Packages modularize the code, making it easier to develop, share, and maintain. They encapsulate functionality and dependencies, allowing developers to reuse and build upon existing work. They are created inside of src directory of workspace hrough below mentioned commands respectively

ros2_ws
|-- build
|-- log
|-- install
`-- src
    |-- ros2_cpp_pkg
 |-- ros2_py_pkg

C++ Package

  • Creation command
ros2 pkg create --build-type ament_cmake ros2_cpp_pkg
  • File Structure Generated
ros2_cpp_pkg
|-- CMakeLists.txt
|-- include
|   `-- ros2_cpp_pkg
|-- package.xml
`-- src

Python Package

  • Creation command
ros2 pkg create --build-type ament_python ros2_py_pkg
  • File Structure Generated
ros2_py_pkg
|-- package.xml
|-- resource
|   `-- ros2_py_pkg
|-- ros2_py_pkg
|   `-- __init__.py
|-- setup.cfg
|-- setup.py
`-- test
 |-- test_copyright.py
 |-- test_flake8.py
 `-- test_pep257.py

Important files and thier purpose

  • CMakeLists.txt : This file tells ROS 2 how to build your package.
  • package.xml : This file contains metadata about your package like dependencies and version.
  • src/main.cpp : This is where you write the main logic for your node.
  • include/package_name/header.hpp : This file holds function declarations and class definitions.
  • setup.py : This file is used to configure the installation of your package.
  • package.xml : This file contains metadata about your package like dependencies and version.
  • node_name.py : This script contains the main logic for your ROS 2 node.

Why we have these auto generated files ?

Auto-generating files reduce boilerplate code, minimise errors, and save development time, allowing developers to focus on core functionality. The most important thing is that it ensures consistency, and that is a need in an open-source framework. It allows developers to focus on the core functionality rather than repetitive setup tasks. While many files are auto-generated, they can often be customised to suit specific needs. When you are starting out , only few files will be going to make sense . Do not worry about other files .

How to decide between creating a C++ or Python package.

If you are just starting out and not comfortable with C++ and Cmakelists then just go with python. C++ is a compiled language and generally offers better performance compared to Python.

  • Real-time systems, high-frequency data processing, or computationally intensive tasks such as image processing and control loops.
  • Direct interaction with sensors, actuators, or other hardware components.
  • Embedded systems or applications with strict memory constraints Python is an interpreted language, known for its simplicity and ease of use.
  • Prototyping, scripting, and projects where development speed and ease of iteration are more critical than raw performance.
  • Applications that require integration with machine learning models, data analysis, or web interfaces.
  • Educational purposes, learning ROS 2, or when leveraging existing Python-based ROS 2 packages and tutorials is easier.

When to Have Both C++ and Python Nodes in One Package

Some projects benefit from the strengths of both languages.

  • Applications that require high-performance nodes for critical tasks (C++) and flexible, easy-to-develop nodes for less critical or high-level logic (Python).
  • Large projects with distinct components, such as a robotics system with high-performance motion control (C++) and a high-level decision-making layer (Python).
  • Integrating a C++ library for sensor data processing with a Python-based machine learning model for decision making.

Why we perform colcon build ?

It is a recommended command-line tool used to build and test ROS 2 python , cpp packages. You move into your root of workspace and run colcon build to perform following tasks.

  • Identifies the build types (ament_cmake for C++ and ament_python for Python) and uses appropriate build tools (CMake for C++ and setuptools for Python) . Allows for building both C++ and Python packages in the same workspace seamlessly.
  • it handles dependencies for both package.xml and CMakeLists.txt (for C++) or setup.py (for Python)
  • It compiles executables for C++ nodes and installed Python scripts for Python nodes which are placed in the install directory. Ensures that all nodes are available for execution regardless of the language they are written in.

Summary

Starting with ROS 2 can seem daunting due to its structured development environment and the array of auto-generated files. However, understanding the purpose of workspaces and packages and knowing when to use C++ or Python will significantly ease your journey. Focus on the core files like and,setup.py, and remember that thecolcon build process is essential for integrating your code. With patience and practice, you'll become comfortable with these concepts and be well-equipped to build robust robotics applications. Embrace the learning curve, and you'll soon find ROS 2 a powerful and flexible tool for your robotics projects.

FAQ Section

  • What is a workspace in ROS 2? - A workspace is a directory structure where ROS 2 projects are created, built, and managed, providing an isolated environment for development.
  • Why are ROS 2 versions specific to Ubuntu? - ROS 2 versions are tied to specific Ubuntu versions to ensure stability and compatibility with the underlying libraries and tools.
  • What is colcon build? - It is a command-line tool used to build, test, and package ROS 2 projects, offering advanced features like parallel builds and sophisticated dependency management.
  • Why are many files in ROS 2 auto-generated? - Auto-generating files reduces boilerplate code, minimizes errors, and saves development time, allowing developers to focus on core functionality.
  • How do you decide between a C++ or Python package in ROS 2? - Choose C++ for performance-critical applications and Python for rapid development and flexibility. A hybrid approach can also be beneficial in some cases.
  • What tools are available for ROS 2 development? - Key tools include RViz for visualization, Gazebo for simulation, and rqt for creating graphical interfaces.

Quiz

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 Finish Your First ROS Robotics Project
  • How to Start with ROS 2

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 Finish Your First ROS Robotics Project
  • How to Start with ROS 2
  • ROS 2 Foundation Path

FAQ

Is How to Start Developing in ROS 2: A Beginner-Friendly Guide 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 Developing in ROS 2: A Beginner-Friendly Guide 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 Finish Your First ROS Robotics Project
Jul 24, 2025|8 min read

How to Finish Your First ROS Robotics Project

Struggling to finish your first ROS 2 project? This step by step guide helps you go from hardware setup to obstacle avoidance using micro ROS and ESP32.

Read more