jrosclient keeps all ROS generic interfaces separate from ROS1 and ROS2 implementations:
This allows users to use jrosclient as a ROS bridge and in the same Java application to communicate between ROS1 and ROS2.
Additionally this allows users to write ROS version agnostic code as long as format of messages stays the same across ROS versions.
In this documentation we will write a ROS Bridge betwee ROS1 and ROS2. More precisely we will create an application which be listening for ROS1 topic "helloRos" and publishing all messages it receives to another topic "helloRos" but in ROS2.
We are going to use "std_msgs.StringMessage" message type which is common for ROS1 and ROS2. Due to that we don't need to convert messages we receive from ROS1 format to ROS2 format and can send them as is.
See complete code.
To run the application we would need to run ROS1 and ROS2. We recommend to do it on two separate hosts.
Open two terminals one for each host
Finally on ROS1 host build and run the application following instructions. It will subscribe to ROS1 topic and announce the publisher for the same topic but in ROS2. Then it will start forwarding messages.
In ROS2 terminal you should see:
data: Hello ROS --- data: Hello ROS --- data: Hello ROS --- data: Hello ROS