ROS2 vs ROS1 Packages
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.
