Skip to content
  • Home
  • About the Blog
  • About the Author
  • Sitemap

Abdur Rosyid's Blog

Just a few notes on mechanical engineering and robotics

ROS2 vs ROS1 Packages

July 8, 2021 by Abdur Rosyid

ROS2 build system is colcon. In ROS1, the build system is catkin.

What is the difference between ROS1 and ROS2 packages? In ROS1, you can mix C++ and Python nodes in a single package. In ROS2, as a standard practice, you either make a C++ package or a Python package. [Although as a non-standard practice, it is possible in ROS2 to create C++ and Python nodes in a single package]. This difference can be observed from two sides below.

CLI commands to create a package

To create a ROS1 package, the CLI command is:

cd ~/catkin_ws/src
catkin_create_pkg [PACKAGE_NAME] roscpp rospy [OTHER_DEPENDENCY_PACKAGES]

To create a C++ package in ROS2, the CLI command is:

cd ~/ros2_ws/src
ros2 pkg create [PACKAGE_NAME] --build-type ament_cmake --dependencies rclcpp std_msgs [OTHER_DEPENDENCY_PACKAGES] 

To create a Python package in ROS2, the CLI command is:

cd ~/ros2_ws/src
ros2 pkg create [PACKAGE_NAME] --build-type ament_python --dependencies rclpy std_msgs [OTHER_DEPENDENCY_PACKAGES]

Structure of the “src” folder in the overlay workspace

The “src” folder in a ROS1 workspace looks like this:

workspace_folder:
|--src
   |--package
      |--CMakeLists.txt
      |--package.xml
      |--src
         |--node_file_1.cpp
         |--node_file_2.cpp
      |--include
      |--script
         |--node_file_1.py
         |--node_file_2.py
      |--

In the workspace structure above, “package” contains both C++ and Python source codes. Typically, the C++ source codes are located inside the “src” and “include” folders, whereas the Python source codes are located inside the “script” folder. The package.xml and CMakeLists.txt files configure both the C++ and Python packages.

The “src” folder in a ROS2 workspace looks like this:

workspace_folder:
|--src
   |--package_1
      |--CMakeLists.txt
      |--package.xml
      |--src
         |--node_file.cpp
      |--include
      |--
   |--package_2
      |--setup.py
      |--setup.cfg
      |--package.xml
      |--package_2
         |--__init__.py
         |--node_file.py
      |--resource
         |--package_2
      |--test
         |--test_copyright.py
         |--test_flake8.py
         |--test_pep257.py

In the workspace structure above, package_1 is the source folder of a C++ package whereas package_2 is the source folder of a Python package. Each of the packages is either a C++ package or a Python package.

Post navigation

Previous Post:

ROS2 vs ROS1 Overlay Workspace

Next Post:

Creating Packages in ROS2

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • STEM 101
  • Robotics
  • Kinematics
  • Dynamics
  • Control
  • Robot Operating System (ROS)
  • Robot Operating System (ROS2)
  • Software Development
  • Mechanics of Materials
  • Finite Element Analysis
  • Fluid Mechanics
  • Thermodynamics

Recent Posts

  • Pull Request on Github
  • Basics of Git and Github
  • Conda vs Docker
  • A Conda Cheat Sheet
  • Installing NVIDIA GPU Driver on Ubuntu

Archives

  • June 2025
  • July 2021
  • June 2021
  • March 2021
  • September 2020
  • April 2020
  • January 2015
  • April 2014
  • March 2014
  • March 2012
  • February 2012
  • June 2011
  • March 2008
© 2026 Abdur Rosyid's Blog | WordPress Theme by Superbthemes