Related tech arcicles
ROS1 vs ROS2, Practical Overview For ROS Developers - The Robotics Back-End
Summary
1.The ROS API – rclcpp, rclpy
In ROS1, for Cpp you use roscpp, and for Python, rospy. Both libraries are completely independent and built from scratch. It means that the API is not necessarily the same between roscpp and rospy, and some features are developed for one, and not the other. (Really bad!)
ROS2 has more layers. There is only one base library, named rcl, and implemented in C. This is the foundation which contains all of the ROS2 core features.
You won’t use the rcl library directly in your programs. You’ll use another client library built on top of rcl. For example: rclcpp for Cpp, rclpy for Python.
What’s great about it? Well any new functionality only needs to be implemented with rcl. Then, the client libraries on top of rcl just need to provide the binding.
For you, as a developer, it means that:
- The API between rclcpp and rclpy will be much more similar than the API between roscpp and rospy.
- It will be easier to create and use other language client libraries, for example rclnodejs, rcljava, etc. No need to reinvent the wheel, you just need to make a C binding with rcl. And all clients in all languages will have a similar API.
- When a new core feature is released, it will be available sooner in different languages, so you won’t have to wait too much.
2. No more ROS master
One thing you’ve learned with ROS1: always start a ROS master before you run a node. The ROS1 master will act as a DNS server for your nodes, so they can retrieve each other.
In ROS2, no more ROS master! This is no more a centralized system. Each node has the capacity to discover other nodes. You can simply start a node without having to worry if you have a master running or not.
This change is great because it allows you to create a fully distributed system. Each node is independent and not tight to a global master.
When creating a multi-machine ROS2 application, you won’t have to define one machine as the “master”. Each machine will be independent and able to start on its own, connect and disconnect with each other, with less setup than in ROS1.
3. Building your nodes
The build system in ROS1 is catkin. You use “catkin_make” or “catkin build” in order to build and install your packages.
In ROS2, no more catkin. Ament is the new building system, and on top of that you get the colcon command line tool.
To compile, you’ll use the command “colcon build” in your ROS2 workspace.
4...