.. _getting-started-connext: ************************************************** 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 :numref:`enable-connext750-index`.) .. 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: 1. Create a new directory (outside of your ROS 2 workspace) called ``connext_ws``. 2. Copy the IDL file for your ROS 2 type into the newly created directory: .. code-block:: bash cp /src/tutorial_interfaces/tutorial_interfaces/share/tutorial_interfaces/msg/Num.idl . 3. 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): .. code-block:: bash source /resource/scripts/rtisetenv_x64Linux4gcc7.3.0.bash 4. 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. .. code-block:: idl module tutorial_interfaces { module msg { module dds_ { struct Num_ { int64 num; }; }; }; }; 5. Generate your *Connext* example application: .. code-block:: bash rtiddsgen -example x64Linux4gcc7.3.0 -language c++11 Num.idl 6. Edit `Num_publisher.cpp` and `Num_subscriber.cpp` to set the topic name to ``rt/topic``: .. code-block:: c++ 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. 7. Compile your *Connext* application: .. code-block:: bash make -f makefile_x64Linux4gcc7.3.0 8. In one terminal, run the *Connext* subscriber: .. code-block:: bash ./objs/x64Linux4gcc7.3.0/Num_subscriber 9. In another terminal, run the ROS 2 publisher: .. code-block:: bash ros2 run cpp_pubsub talker 10. Verify that the *Connext* subscriber application now starts receiving data from the ROS 2 publisher application: .. code-block:: text ::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]