Bridging
Your Transitions

from ROS 1to ROS 2

Mabel Zhang
Open Robotics

WHO, WHAT, WHY, W…

2

Overview
WHO cares
You run on ROS 1 now.
You(r boss) want to move to ROS 2.

WHAT is the bridge
Talks between ROS 1 and ROS 2
WHY would I bother
Stuff don’t break while you port incrementally to ROS 2
3

Disclaimer:
I didn’t write the bridge.
(I’m as newb as you.)4Outline
Built-in types
Matching custom types (automatically associated)
Non-matching custom types (NOT automatically associated)

All code available: github.com/mabelzhang/ros1_bridge_sandbox

5

HOW

6

Setupros1_bridge

A ROS 1 Robot(e.g. VRX)

ROS 1 Melodic

ROS 2 Dashing

Dockerfile

All code available: github.com/mabelzhang/ros1_bridge_sandbox

7

Part 1/3

BASICS: BUILT-IN TYPES

8

Use CaseIf you only ever use built-in types. No custom types.
std_msgs
sensor_msgs
geometry_msgs
std_srvs…

All code available: github.com/mabelzhang/ros1_bridge_sandbox

9

Built-in Types: Work Out of the Box
Install bridge:$ sudo apt install ros-dashing-ros1-bridgeSee all built-in types automatically bridged:$ ros2 run ros1_bridge dynamic_bridge --print-pairs

Run bridge:$ ros2 run ros1_bridge dynamic_bridge --bridge-alltopics

All code available: github.com/mabelzhang/ros1_bridge_sandbox

10

Demo: Built-in Typessensor data

ROS 1

ROS 2

All code available: github.com/mabelzhang/ros1_bridge_sandbox

11

ROS 1

bridge

ROS 2
12

ROS 1

ROS 2
All code available: github.com/mabelzhang/ros1_bridge_sandbox13

Demo: Built-in Types

command

ROS 1

ROS 2

All code available: github.com/mabelzhang/ros1_bridge_sandbox

14

ROS 1bridge

ROS 2
15

Part 2/3

INTERMEDIATE:
CUSTOM TYPES, AUTO-ASSOCIATED
16

Use CaseIf you define custom types, e.g.
JointCommand.msg:
float64 position

All code available: github.com/mabelzhang/ros1_bridge_sandbox

17

Custom Types: Automatic association
Need to recompile bridge.
Easiest: automatic association between ROS 1 & 2 types
Conditions:
Package names end in _msgs in ROS 1, _msgs / _interfaces in ROS 2 AND
Message names match AND
Fields match

All code available: github.com/mabelzhang/ros1_bridge_sandbox

18

Custom Types: Compiling the Bridge
Key: Separate workspaces and separate shells,for ROS 1, ROS 2, and bridge┣ ros1_bridge_ws/src/ros1_bridge┣ ros1_msgs_ws/src/bridge_msgs┗ ros2_msgs_ws/src/bridge_msgs
Compile and source each workspace in separate shells.

All code available: github.com/mabelzhang/ros1_bridge_sandbox

19

Custom Types: Compiling the Bridge
Shell 1: Build ROS 1 messages$ . /opt/ros/melodic/setup.bash$ catkin_make_isolated --install$ . install_isolated/setup.bash

Shell 2: Build ROS 2 messages$ . /opt/ros/dashing/setup.bash$ colcon build --packages-select bridge_msgs$ . install/local_setup.bash

All code available: github.com/mabelzhang/ros1_bridge_sandbox

20

Custom Types: Compiling the Bridge
Shell 3: Build bridge$ . /opt/ros/melodic/setup.bash$ . /opt/ros/dashing/setup.bash$ . ../ros1_bridge_sandbox/ros1_msgs_ws/install_isolated/setup.bash$ . ../ros1_bridge_sandbox/ros2_msgs_ws/install/local_setup.bash$ colcon build --packages-select ros1_bridge --cmake-force-configure$ . install/local_setup.bash

Verify custom messages are bridged:$ ros2 run ros1_bridge dynamic_bridge --print-pairs | grep bridge_msgs- 'bridge_msgs/JointCommand' (ROS 2) <=> 'bridge_msgs/JointCommand'(ROS 1)
Instructions Available

All code available: github.com/mabelzhang/ros1_bridge_sandbox21

Demo: Custom Typecustom msg

ROS 1

ROS 2

All code available: github.com/mabelzhang/ros1_bridge_sandbox

22

bridgeROS 1
pubcustom

ROS 2
subcustom23

Demo: Custom Typecustom msg

ROS 1

ROS 2

All code available: github.com/mabelzhang/ros1_bridge_sandbox

24

bridge

ROS 1
subcustom

ROS 2
pubcustom
25

Part 3/3

IF YOU MUST:
CUSTOM MAPPINGS, NOT AUTO-ASSOCIATED
26

Use Case
If message types cannot have matching names and fields,
e.g. /rosout:rosgraph_msgs/Log.msg:
Header header
byte level
string namestring msg
string filestring function
uint32 line
string[] topics

rcl_interfaces/Log.msg:
builtin_interfaces/Time
stamp
uint8 level
string namestring msg
string filestring function
uint32 line

All code available: github.com/mabelzhang/ros1_bridge_sandbox

27

Define Custom Mapping in YAML
rcl_interfaces/mapping_rules.yaml:
ros1_package_name: 'rosgraph_msgs'
ros1_message_name: 'Log'ros2_package_name: 'rcl_interfaces'ros2_message_name: 'Log'
fields_1_to_2:
header.stamp: 'stamp'level: 'level'
name: 'name'msg: 'msg'
file: 'file'
function: 'function'line: 'line'
All code available: github.com/mabelzhang/ros1_bridge_sandbox

28

Define Custom Mapping in YAML
rcl_interfaces/CMakeLists.txt:
install(FILES mapping_rules.yaml DESTINATIONshare/${PROJECT_NAME})

rcl_interfaces/package.xml:<export><ros1_bridge mapping_rules="mapping_rules.yaml"/></export>

Recompile package; recompile bridge as before.
All code available: github.com/mabelzhang/ros1_bridge_sandbox29

Demo: Custom YAML Mapping/rosout

ROS 1

ROS 2

All code available: github.com/mabelzhang/ros1_bridge_sandbox30

bridge

ROS 1
subROS 2
customYAML

ROS 2
pub31

A FEW NOTES

32

A Few Notes
echo alone does not suffice. Write a subscriber.
Use --bridge-all-topics to guarantee bridging.

If cannot get dynamic bridge to work, try static bridge
simple_bridge.cpp in ros1_bridge.
Migration guide from ROS 1 to ROS 2

https://index.ros.org/doc/ros2/Contributing/Migration-Guide/All code available: github.com/mabelzhang/ros1_bridge_sandbox

34

Thank you.

35