4. Interoperating Connext 7.3.0 or Earlier with ROS 2
The following describes a quick way to get started with ROS 2 and Connext, for Connext versions 7.3.0 or earlier. (Interoperating Connext 7.5.0 or later with ROS 2 is even easier. See Section 5.)
Note
These instructions are for using standalone Connext applications with ROS 2 applications, regardless of the RMW used. This approach is ideal if you have an existing ROS 2 system that you cannot change, but you want to utilize the many features of Connext in additional applications.
Ensure these prerequisites:
ROS 2 (any LTS version)
It is recommended to use Ubuntu 24.04 (LTS) and Debian packages for installation, since this platform is referenced throughout the examples. Substitute your platform for “x64Linux4gcc7.3.0” throughout the examples if you are using another architecture.
Existing ROS 2 application
The examples throughout this document are based on the Creating custom msg and serv files and Writing a simple publisher and subscriber (C++) ROS 2 tutorials. If you have your own existing application, you should substitute your own types and topic names throughout the examples.
Connext (any version at/before 7.3.0)
In these getting started steps, your ROS 2 application will publish to your Connext subscribing application:
Create a new directory (outside of your ROS 2 workspace) called
connext_ws.Copy the IDL file for your ROS 2 type into the newly created directory:
cp <ros2_ws>/src/tutorial_interfaces/tutorial_interfaces/share/tutorial_interfaces/msg/Num.idl .
Configure your Connext environment (note: it is recommended to do this in a separate terminal from the one where you have configured your ROS 2 environment):
source <rti_connext_install_directory>/resource/scripts/rtisetenv_x64Linux4gcc7.3.0.bash
Modify your IDL to follow ROS 2 naming conventions. ROS 2 DDS types include an additional
dds_namespace before the underlying typename, and the typenames are appended with_. We must manually modify this typename before generating the type, in order to allow communication to take place.module tutorial_interfaces { module msg { module dds_ { struct Num_ { int64 num; }; }; }; };
Generate your Connext example application:
rtiddsgen -example x64Linux4gcc7.3.0 -language c++11 Num.idl
Edit Num_publisher.cpp and Num_subscriber.cpp to set the topic name to
rt/topic:dds::topic::Topic< ::tutorial_interfaces::msg::dds_::Num_> topic(participant, "rt/topic");
Note
This is not the same topic name that is used in your ROS 2 application. Your ROS 2 application should be using the topic name “topic”. The RMW automatically adds “rt/” to the topic name at runtime.
Compile your Connext application:
make -f makefile_x64Linux4gcc7.3.0
In one terminal, run the Connext subscriber:
./objs/x64Linux4gcc7.3.0/Num_subscriber
In another terminal, run the ROS 2 publisher:
ros2 run cpp_pubsub talker
Verify that the Connext subscriber application now starts receiving data from the ROS 2 publisher application:
::tutorial_interfaces::msg::Num subscriber sleeping up to 1 sec... [num: 0] ::tutorial_interfaces::msg::Num subscriber sleeping up to 1 sec... [num: 1] ::tutorial_interfaces::msg::Num subscriber sleeping up to 1 sec... [num: 2] ::tutorial_interfaces::msg::Num subscriber sleeping up to 1 sec... [num: 3]