ROS 1 to ROS 2 Migration: Is It Worth It?
In this article
Yes, you should migrate from ROS 1 to ROS 2 if you are starting a new project or plan to maintain your robot for more than a few years, because ROS 1 is no longer receiving new feature development and its official support ends in 2025. However, if you have a stable, working ROS 1 system that you do not need to extend or integrate with modern tools, migrating may not be urgent—but you should still plan a path forward.
Background: Why ROS 2 Exists
ROS 1 was designed in 2007 for research and prototyping. It worked well for single-robot systems on one machine, but it was never built for real-world production needs like multi-robot coordination, real-time control, or secure communication. ROS 2, first released in 2017, was a ground-up rewrite that addresses those gaps while keeping the core concepts (nodes, topics, services) familiar to ROS 1 users.
Key differences you will notice immediately:
- Middleware: ROS 1 uses its own custom TCP/UDP transport; ROS 2 uses DDS (Data Distribution Service), which is a standard for industrial IoT and robotics.
- Real-time support: ROS 2 can be used with real-time kernels and provides better control over execution timing.
- Security: ROS 2 has built-in authentication and encryption via DDS security plugins; ROS 1 has none.
- Multi-machine and multi-robot: ROS 2 handles distributed systems more gracefully, with automatic discovery and better network behavior.
- Lifecycle nodes: ROS 2 lets you manage node states (unconfigured, active, shutdown), which is useful for complex systems.
How ROS 2 Changes the Way You Code
If you know ROS 1, you already understand 80% of ROS 2. But the API and build system have changed. Here are the most important differences:
- Build system: ROS 1 uses
catkin; ROS 2 usesamentwithcolconas the build tool. The package structure is similar, but the CMake files and setup scripts differ. - Python support: ROS 1 supports Python 2 and 3; ROS 2 only supports Python 3. Also, the Python API is now the primary interface, not a afterthought.
- Node handles: In ROS 1, you create a
rospy.init_node(); in ROS 2, you create aNodeobject and pass it around. This makes code more modular and testable. - Parameters: ROS 1 uses the parameter server (global); ROS 2 uses per-node parameters with a more flexible system (e.g., you can have arrays, dictionaries, and even set parameters at runtime).
- Actions: The action API is similar, but the goal and result messages are now defined in the same
.actionfile, and the client/server API has changed slightly.
For example, a simple publisher in ROS 1 looks like:
import rospy
from std_msgs.msg import String
rospy.init_node('talker')
pub = rospy.Publisher('chatter', String, queue_size=10)
rate = rospy.Rate(10)
while not rospy.is_shutdown():
pub.publish('hello')
rate.sleep()
In ROS 2, it becomes:
import rclpy
from std_msgs.msg import String
rclpy.init()
node = rclpy.create_node('talker')
pub = node.create_publisher(String, 'chatter', 10)
rate = node.create_rate(10)
while rclpy.ok():
pub.publish('hello')
rate.sleep()
Notice the explicit node object and the need to call rclpy.init() and rclpy.shutdown().
How to Choose: When to Migrate, When to Wait
There is no one-size-fits-all answer, but these guidelines can help:
- New projects: Start with ROS 2. No reason to learn a deprecated system.
- Existing ROS 1 project that is still in active development: Migrate sooner rather than later. The longer you wait, the more code you have to convert.
- Legacy system that works and is not being extended: You can keep using ROS 1, but be aware that after 2025 there will be no official updates, and security patches will stop. If the system is not connected to the internet or is in a controlled environment, this may be acceptable.
- Research or education: Most new research and courses are moving to ROS 2. You will find more support and examples.
If you decide to migrate, the process is not a simple find-and-replace. Plan for these steps:
- Inventory your packages and dependencies. Some ROS 1 libraries have no ROS 2 equivalent yet.
- Set up a ROS 2 workspace and install the
ros1_bridgepackage, which lets ROS 1 and ROS 2 nodes communicate while you transition. - Convert your packages one at a time, starting with the lowest-level ones (message definitions, then libraries, then nodes).
- Test each converted package in isolation before integrating.
- Update your launch files. ROS 2 uses
launchfiles in Python or XML, but the syntax is different.
Common Problems and Misconceptions
Many people think migration is a drop-in replacement, but it is not. Here are common issues you will encounter:
- Message types are not always compatible: Some message definitions changed (e.g.,
std_msgs/Headeris the same, butsensor_msgs/PointCloud2has different field names). Check the migration guides. - DDS discovery can be slow on large networks: ROS 2 uses DDS discovery, which broadcasts on the network. In some environments, you may need to configure discovery settings to avoid delays.
- Not all ROS 1 packages have been ported: Some popular packages like
gmapping(2D SLAM) andhector_slamare not officially supported in ROS 2, though alternatives exist (e.g.,slam_toolbox). - Real-time guarantees are not automatic: ROS 2 can be real-time if you use the right DDS implementation and configure your system, but it is not real-time out of the box.
A common misconception is that ROS 2 is just a newer version of ROS 1. In reality, it is a different middleware with a different API. You cannot run ROS 1 nodes on ROS 2 without the bridge, and even then, the bridge only works if the message types are compatible.
Costs and Effort of Migration
The cost of migrating depends on the size of your codebase and the availability of ROS 2 ports. A rough estimate for a typical robotics project:
- Small project (a few nodes, simple messages): A few days to a week.
- Medium project (10-20 nodes, custom messages, some libraries): 2-4 weeks.
- Large project (many packages, complex dependencies, hardware drivers): Several months, especially if you have to rewrite drivers or wait for upstream ports.
You also need to consider the learning curve. If your team is new to ROS 2, expect a week or two of training. But the long-term benefits—better security, real-time capability, and ongoing support—usually outweigh the initial effort.
Safety and Security Considerations
If your robot is safety-critical or operates in an environment where security matters, ROS 2 is the safer choice. ROS 1 has no built-in security: any node on the network can publish or subscribe to any topic without authentication. ROS 2 supports SROS2, which provides encryption and access control. However, even with ROS 2, you must configure security properly; it is not enabled by default.
For safety-critical applications, ROS 2 is still not certified to standards like ISO 26262 (for automotive) or IEC 61508 (for industrial). You would need to layer your own safety mechanisms on top. But ROS 2’s real-time support and lifecycle management give you more tools to build a safe system than ROS 1 ever had.
Alternatives to Full Migration
If you are not ready to migrate completely, you have a few options:
- Use the ROS 1 bridge: Run ROS 1 and ROS 2 nodes side by side. This lets you gradually move nodes over, but the bridge adds complexity and a potential single point of failure.
- Stay on ROS 1 and freeze your code: If your system is stable and you do not need new features, you can continue to use it. Just be aware of the end-of-support date.
- Switch to a different framework: Some teams move to other robotics middleware like LCM, or use plain DDS directly. This gives you more control but loses the ecosystem of ROS tools.
In practice, most teams find that the bridge is useful during a transition period, but not as a long-term solution.
Frequently Asked Questions
Is ROS 1 still supported?
ROS 1 is in maintenance mode. The final distribution, Noetic, is supported until 2025. After that, there will be no official updates, though the open-source community may continue to maintain it informally.
Can I run ROS 1 and ROS 2 on the same robot?
Yes, you can run both on the same machine, but they are separate systems. You can use the ros1_bridge to connect them, but you need to run a ROS 1 master and a ROS 2 daemon separately. This is useful during migration.
Do I need to rewrite all my code?
Not all, but most. The core logic (algorithms, math) can be reused, but the ROS-specific parts (node creation, publishers, subscribers, services, actions) need to be rewritten. Message definitions are mostly compatible, but you may need to adjust some field names.
What is the hardest part of migration?
For most people, it is the lack of ROS 2 ports for their favorite packages. If you rely on a specific SLAM algorithm or driver that has not been ported, you may have to use alternatives or write your own.
Is ROS 2 faster than ROS 1?
Not necessarily. ROS 2 can have lower latency in some cases, but the DDS overhead can make it slower in others. The main advantage is scalability and real-time capability, not raw speed.
Can I use ROS 2 on a Raspberry Pi?
Yes, ROS 2 runs on Ubuntu for ARM, but it is resource-intensive. You may need to use a lightweight DDS implementation like Cyclone DDS and disable some features to get acceptable performance.