ROS1 vs ROS2 Comprehensive Comparison (1)
Basic Architecture and Concepts
Feature | ROS1 | ROS2 |
---|---|---|
Communication Middleware | Custom TCPROS/UDPROS | DDS (Data Distribution Service) |
Master Node | Required (roscore ) |
No master needed (distributed discovery) |
Operating Systems | Primary: Ubuntu Linux Limited: Windows, macOS |
Full support for Linux, Windows, macOS |
Real-time Support | Limited | Improved with DDS and QoS policies |
Multi-robot Systems | Requires network configuration | Native multi-domain support |
Security | Limited | Built-in security with DDS (authentication, encryption) |
Scalability | Limited by single master | Improved with distributed architecture |
Package Management and Creation
Feature | ROS1 | ROS2 |
---|---|---|
Package Creation Command | catkin_create_pkg <pkg_name> [dependencies] |
ros2 pkg create --build-type ament_cmake/ament_python <pkg_name> |
Package Structure (C++) | CMakeLists.txt , package.xml , src/ , include/ |
CMakeLists.txt , package.xml , src/ , include/ |
Package Structure (Python) | Same as C++, with Python files in scripts/ or src/ |
Different structure with setup.py , setup.cfg , Python modules in <pkg_name>/ |
Package XML Format | Format 1 or 2 | Format 3 (supports conditional dependencies) |
Build System | Catkin | Ament |
Build Command | catkin_make or catkin build |
colcon build |
Workspace Setup | ~/catkin_ws/src , ~/catkin_ws/devel , ~/catkin_ws/build |
~/ros2_ws/src , ~/ros2_ws/install , ~/ros2_ws/build |
Source Workspace | source ~/catkin_ws/devel/setup.bash |
source ~/ros2_ws/install/setup.bash |
Nodes and Execution
Feature | ROS1 | ROS2 |
---|---|---|
Node Creation (C++) | Inherit from no class, use global NodeHandle | Inherit from rclcpp::Node |
Node Creation (Python) | Import rospy , use global functions |
Import rclpy , inherit from rclpy.node.Node |
Node Launch | rosrun <pkg_name> <node_name> |
ros2 run <pkg_name> <node_name> |
Node List Command | rosnode list |
ros2 node list |
Node Info Command | rosnode info <node_name> |
ros2 node info <node_name> |
Main Loop (C++) | ros::spin() or ros::spinOnce() |
rclcpp::spin() or custom executor |
Main Loop (Python) | rospy.spin() |
rclpy.spin() |
Execution Model | Single-threaded or multi-threaded only | Flexible executors (single-threaded, multi-threaded, custom) |
Node Lifecycle | Not supported natively | Managed nodes with lifecycle states |
Topics, Publishers, and Subscribers
Feature | ROS1 | ROS2 |
---|---|---|
List Topics | rostopic list |
ros2 topic list |
Topic Info | rostopic info <topic> |
ros2 topic info <topic> |
Echo Topic | rostopic echo <topic> |
ros2 topic echo <topic> |
Publisher Creation (C++) | ros::Publisher pub = nh.advertise<msg_type>("topic", queue_size) |
rclcpp::Publisher<msg_type>::SharedPtr pub = node->create_publisher<msg_type>("topic", qos) |
Publisher Creation (Python) | pub = rospy.Publisher("topic", msg_type, queue_size=10) |
pub = node.create_publisher(msg_type, "topic", qos_profile) |
Subscriber Creation (C++) | ros::Subscriber sub = nh.subscribe("topic", queue_size, callback) |
auto sub = node->create_subscription<msg_type>("topic", qos, callback) |
Subscriber Creation (Python) | sub = rospy.Subscriber("topic", msg_type, callback) |
sub = node.create_subscription(msg_type, "topic", callback, qos_profile) |
Publishing Messages (C++) | pub.publish(msg) |
pub->publish(msg) |
Publishing Messages (Python) | pub.publish(msg) |
pub.publish(msg) |
Quality of Service | Not supported | Configurable QoS policies (reliability, durability, etc.) |
Intra-process Communication | Not supported natively | Supported for optimized same-process communication |
Topic Remapping | Command line only rosrun pkg node _topic:=new_name |
Command line ros2 run pkg node --ros-args -r topic:=new_name |
Services and Actions
Feature | ROS1 | ROS2 |
---|---|---|
Service Creation (C++) | ros::ServiceServer srv = nh.advertiseService("service", callback) |
rclcpp::Service<srv_type>::SharedPtr srv = node->create_service<srv_type>("service", callback) |
Service Creation (Python) | rospy.Service("service", srv_type, callback) |
node.create_service(srv_type, "service", callback) |
Service Call (C++) | ros::ServiceClient client = nh.serviceClient<srv_type>("service") |
rclcpp::Client<srv_type>::SharedPtr client = node->create_client<srv_type>("service") |
Service Call (Python) | rospy.ServiceProxy("service", srv_type) |
node.create_client(srv_type, "service") |
List Services | rosservice list |
ros2 service list |
Call Service | rosservice call <service> <args> |
ros2 service call <service> <srv_type> <args> |
Actions | Uses actionlib package |
Built-in rclcpp_action /rclpy.action |
Parameters
Feature | ROS1 | ROS2 |
---|---|---|
Parameter Server | Centralized in master | Distributed (each node has its own) |
Set Parameter | rosparam set <param> <value> |
ros2 param set <node> <param> <value> |
Get Parameter | rosparam get <param> |
ros2 param get <node> <param> |
List Parameters | rosparam list |
ros2 param list <node> |
Parameter Files | Load with rosparam load <file> |
Part of node configuration |
Get Parameter (C++) | nh.getParam("param", var) |
node->get_parameter("param", var) or node->declare_parameter("param", default_val) |
Get Parameter (Python) | rospy.get_param("param") |
node.get_parameter("param").value or node.declare_parameter("param", default_val) |
Build Tools and Process
Feature | ROS1 | ROS2 |
---|---|---|
Build System | Catkin | Ament |
Build Tool | catkin_make or catkin build |
colcon build |
Package Dependencies | <build_depend> , <run_depend> |
<build_depend> , <exec_depend> , <test_depend> , etc. |
CMake Functions | catkin_package() , add_executable() |
ament_package() , add_executable() , ament_target_dependencies() |
Python Setup | catkin_python_setup() |
Uses Python's setup.py |
Install Rules | Optional | Required for all executables and libraries |
Build Options | Limited options with catkin | Extensive options with colcon (symlink-install, packages-select, etc.) |
Launch Files
Feature | ROS1 | ROS2 |
---|---|---|
Format | XML only | Python, XML, or YAML |
Launch Command | roslaunch <pkg> <file>.launch |
ros2 launch <pkg> <file>.py/xml/yaml |
Node Inclusion | <node pkg="pkg" type="executable" name="name"/> |
XML: similar Python: Node(package='pkg', executable='exec', name='name') |
Arguments | <arg name="arg" default="val"/> |
XML: similar Python: DeclareLaunchArgument('arg', default_value='val') |
Conditionals | Limited XML conditionals | Full programming language capabilities in Python launches |
Include Files | <include file="$(find pkg)/launch/file.launch"/> |
XML: similar Python: IncludeLaunchDescription(...) |
Data Recording and Playback (Bags)
Feature | ROS1 | ROS2 |
---|---|---|
Command Tool | rosbag |
ros2 bag |
Record All Topics | rosbag record -a |
ros2 bag record -a |
Record Specific Topics | rosbag record <topic1> <topic2> |
ros2 bag record <topic1> <topic2> |
Play Bag File | rosbag play <file>.bag |
ros2 bag play <path-to-bag-folder> |
Info on Bag | rosbag info <file>.bag |
ros2 bag info <path-to-bag-folder> |
Storage Format | Custom .bag files |
SQLite database by default, pluggable storage |
Compression | Limited options | Multiple modes (file, message) and formats (zstd) |
Splitting | By size only | By size or duration |
Simulation Time | Use with --clock |
Use with --use-sim-time |
Playback Control | Limited (start/stop) | Services for pause, resume, seek, play at rate, etc. |
Debugging and Analysis Tools
Feature | ROS1 | ROS2 |
---|---|---|
Visualization | RViz | RViz2 |
Graph Visualization | rqt_graph | rqt_graph |
Message Plotting | rqt_plot | rqt_plot |
Console Logging | rqt_console | rqt_console |
Topic Monitoring | rostopic, rqt_topic | ros2 topic, rqt_topic |
Node Introspection | rosnode | ros2 node |
Message Introspection | rosmsg show | ros2 interface show |
Service Introspection | rossrv show | ros2 interface show |
Diagnostics | /diagnostics topic |
/diagnostics topic |
Image Debugging | image_view | image_tools |
Converting Between ROS1 and ROS2
Feature | Description |
---|---|
ros1_bridge | Package for connecting ROS1 and ROS2 systems |
Message Compatibility | Standard messages have equivalent types in both systems |
Bridge Usage | ros2 run ros1_bridge dynamic_bridge |
Bridge Limitations | Only works with message types known at compile time |
Bridge Options | --bridge-all-2to1-topics to bridge all ROS2 topics to ROS1 |
Additional ROS2 Features
Feature | Description |
---|---|
Lifecycle Nodes | Managed nodes with predefined states (unconfigured, inactive, active, etc.) |
Components | Dynamically loadable nodes that can use intra-process communications |
QoS Settings | Configure reliability, durability, history, and other communication properties |
Multi-domain Support | Run ROS2 nodes in different DDS domains for isolation |
Security | Authentication, encryption, and access control with SROS2 |
留言
張貼留言