{"id":23168254,"url":"https://github.com/asorbini/rticonnextdds-ros2-adapter","last_synced_at":"2025-04-04T22:22:02.710Z","repository":{"id":146825654,"uuid":"472922335","full_name":"asorbini/rticonnextdds-ros2-adapter","owner":"asorbini","description":"C/C++ library to help Connext applications interact with a ROS 2 system.","archived":false,"fork":false,"pushed_at":"2023-11-16T16:38:33.000Z","size":246,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-10T06:46:05.920Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asorbini.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-22T20:11:23.000Z","updated_at":"2022-03-23T01:55:43.000Z","dependencies_parsed_at":"2024-12-18T02:40:49.107Z","dependency_job_id":"21146c78-3afa-43eb-8116-2abe8dbca674","html_url":"https://github.com/asorbini/rticonnextdds-ros2-adapter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asorbini%2Frticonnextdds-ros2-adapter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asorbini%2Frticonnextdds-ros2-adapter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asorbini%2Frticonnextdds-ros2-adapter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asorbini%2Frticonnextdds-ros2-adapter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asorbini","download_url":"https://codeload.github.com/asorbini/rticonnextdds-ros2-adapter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247256780,"owners_count":20909357,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-18T02:40:27.946Z","updated_at":"2025-04-04T22:22:02.690Z","avatar_url":"https://github.com/asorbini.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ROS 2 helper for Connext DDS applications\n\n`rticonnextdds-ros2-adapter` is an open-source C/C++ library to help\napplications built with Connext DDS interact with the\n[ROS 2 graph](https://docs.ros.org/en/rolling/Tutorials/Understanding-ROS2-Nodes.html#the-ros-2-graph) and other components of the ROS 2 ecosystem.\n\n## Building\n\n`rticonnextdds-ros2-adapter` provides native APIs for both C and C++.\n\nThe libraries can be built using CMake:\n\n```sh\n# Clone this repository\ngit clone https://github.com/asorbini/rticonnextdds-ros2-adapter\n\n# Create a build directory\nmkdir build\n\n# Load Connext DDS for your architecture into the environment,\n# e.g. load Connext DDS for Linux 64 bit using the provided env script.\nsource ~/rti_connext_dds-6.0.1/resource/scripts/rtisetenv_x64Linux4gcc7.3.0.bash\n\n# Configure project using cmake: specify a custom install prefix, and\n# optionally build included tests and examples.\ncmake rticonnextdds-ros2-adapter \\\n  -Bbuild \\\n  -DCMAKE_INSTALL_PREFIX=install \\\n  -DBUILD_TESTING=ON \\\n  -DBUILD_EXAMPLES=ON \\\n\n# Invoke native build tool using cmake and install artifacts.\ncmake --build build -- install\n```\n\n## Examples\n\nThe included examples will only be built if the repository is configured with\n`-DBUILD_EXAMPLES=ON`.\n\nYou can find all examples in the installation directory under `bin/`.\nIn order to run them, you will have to add `install/lib` to your shared library\npath, e.g. on Linux (assuming that you used `-DCMAKE_INSTALL_PREFIX=install` when configuring the project):\n\n```sh\nexport LD_LIBRARY_PATH=\"${LD_LIBRARY_PATH}:install/lib\"\n```\n\nThe examples are written to work out of the box with some ROS 2 applications. In order to run them, you will need a recent version of [ROS 2](https://docs.ros.org/en/rolling/Installation.html) with [rmw_connextdds](https://github.com/ros2/rmw_connextdds) installed.\n\n### hello_c_adapter, hello_cpp_adapter\n\n- Examples [hello_c_adapter](examples/c/hello_c_adapter/hello_c_adapter.c) and [hello_c_adapter](examples/cpp/hello_cpp_adapter/hello_cpp_adapter.cpp) will listen for messages on ROS 2 topic `\"chatter\"` and\n  duplicate them on topic \"chatter_dup\".\n\n- Use the `talker` node from `demo_nodes_cpp` to generate data,\n  then start the examples to read it.\n\n  ```sh\n  # Start talker in background (or use a different terminal).\n  RMW_IMPLEMENTATION=rmw_connextdds ros2 run demo_nodes_cpp talker \u0026\n\n  install/bin/hello_cpp_adapter\n  ```\n\n- You can use `rqt`'s \"Node Graph\" plugin to visualize the example node and\n  its endpoints:\n\n  ![hello_cpp_adapter in rqt](docs/static/hello_cpp_adapter_rqt.png)\n\n### parameters_client_cpp\n\n- Example [parameters_client_cpp](examples/cpp/parameters_cpp/parameters_client_cpp.cpp) will send a request to the `\"list_parameters\"` service\n  of ROS 2 node `\"talker\"`.\n\n- Start `demo_nodes_cpp/talker`, then start the client to query it:\n\n  ```sh\n  # Start talker in background (or use a different terminal).\n  RMW_IMPLEMENTATION=rmw_connextdds ros2 run demo_nodes_cpp talker \u0026\n\n  install/bin/parameters_client_cpp\n  ```\n\n### parameters_service_cpp\n\n- Example [parameters_service_cpp](examples/cpp/parameters_cpp/parameters_service_cpp.cpp) will advertise a (fake) `\"list_parameters\"` service.\n\n- Start the service, then use the `ros2 service` utility to interact with it\n\n  ```sh\n  # Start service in background (or use a different terminal).\n  install/bin/parameters_service_cpp \u0026\n\n  # Query list of available services:\n  RMW_IMPLEMENTATION=rmw_connextdds ros2 service list\n\n  # Invoke the service:\n  RMW_IMPLEMENTATION=rmw_connextdds ros2 service call \\\n    /foo/list_parameters rcl_interfaces/srv/ListParameters\n  ```\n\n- You can also use `rqt`'s \"Service Call\" plugin to interact with the service:\n\n  ![parameters_service_cpp in rqt](docs/static/parameters_service_cpp_in_rqt.png)\n\n## Unit tests\n\nIn order to build the included unit tests, the respository must have been\nconfigured with `-DBUILD_TESTING=ON`.\n\nOnce built, you can ran all included tests using `ctest`:\n\n```sh\n(cd build/test \u0026\u0026 ctest)\n```\n\n## API Usage\n\nThe adapter library allows application to instantiate a local ROS 2 graph object, which they can then use to register local\nDDS endpoints and have the graph announce them to other ROS 2 applications over the network.\n\nIn order to register their DDS endpoints, users must first associate their DomainParticipant with a ROS 2 Node identity, by\nspecifying a name and namespace for it.\n\nAfter creating a local node, users can either register each endpoint by hand, or they can let the library inspect the node's\nDomainParticipant to automatically register any endpoint whose\ntopic name follows the ROS 2 naming conventions.\n\nThe local graph object requires at least a DomainParticipant, which it\nwill use to create the DDS entities required to propagate the\nROS 2 graph information.\n\nOnly endpoints whose topic name follows the ROS 2 naming conventions\nmay be registered on the graph. The library offers some helper\nfunctions to facilitate generation of conforming names.\n\n### C API\n\nThe `rticonnextdds-ros2-adapter` C API is meant to be integrated into applications using Connext's C API.\n\nApplications are expected to create an object of type `RTIROS2_Graph` and pass it a DomainParticipant to use through the properties object:\n\n```c\n#include \"ndds/ndds_c.h\"\n#include \"rticonnextdds_ros2_adapter/rticonnextdds_ros2_adapter_c.h\"\n\n/* The application will typically reuse its DomainParticipant,\n   for example created manually from the participant factory */\nDDS_DomainParticipant * my_participant = \n  DDS_DomainParticipantFactory_create_participant(DDS_TheParticipantFactory,\n    0, \u0026DDS_PARTICIPANT_QOS_DEFAULT, NULL, DDS_STATUS_MASK_NONE);\n\n\nRTIROS2_GraphProperties props = RTIROS2_GraphProperties_INITIALIZER;\nprops.graph_participant = my_participant;\nRTIROS2_Graph * graph = RTIROS2_Graph_new(\u0026props);\n```\n\nEndpoints must be associated with a ROS 2 Node, so before registering them, users\nmust declare one or more nodes and save their handle for future reference.\n\nEach node must be assigned a name, a namespace, and a DomainParticipant.\n\nThe namespace argument might be NULL, in which case the default namespace (\"/\")\nwill be used.\n\nThe participant argument can also be `NULL`, in which case the node will be\nassociated with the DomainParticipant used by the graph.\n\n```c\nconst RTIROS2_GraphNodeHandle node_h =\n  RTIROS2_Graph_register_local_node(graph, \"my_node\", NULL, NULL);\nif (RTIROS2_GraphNodeHandle_INVALID == node_h)\n{\n  printf(\"failed to register node\\n);\n}\n```\n\nAfter registering a node, the application can use the API to map its DDS endpoints\nto ROS 2 entities. For example, assuming the application created a DataReader\nfor topic `\"rt/chatter\"` (`my_reader`), the reader could be mapped to a\nROS 2 subscription for topic `\"chatter\"`:\n\n```c\nconst RTIROS2_GraphEndpointHandle endp_h =\n  RTIROS2_Graph_register_local_subscription(graph, node_h, my_reader);\nif (RTIROS2_GraphEndpointHandle_INVALID == endp_h)\n{\n  printf(\"failed to register subscription\\n);\n}\n```\n\nAlternatively, the library can inspect the DomainParticipant associated with\na node and automatically register all endpoints that are found to be following\nthe ROS 2 naming conventions:\n\n```c\nDDS_ReturnCode_t rc = RTIROS2_Graph_inspect_node(graph, node_h);\nif (DDS_RETCODE_OK != rc)\n{\n  printf(\"failed to inspect node\\n);\n}\n```\n\nNote that this automatic inspection will not work if you plan on declaring\nmultiple local nodes and having them share the same DomainParticipant, because\nin this case the endpoints will be all associated with the first node to be\ninspected. If you want to share the DomainParticipant between multiple nodes\nyou should manually register your endpoints for a finer grained control.\n\n### C++ API\n\nThe `rticonnextdds-ros2-adapter` C++ API is meant to be integrated into applications\nthat are already using Connext's \"modern\" C++ API.\n\nThe C++ adapter API is built on top of the C implementation, and it exposes\nvery similar interfaces in a more C++ friendly variant.\n\nApplications are expected to instantiate class `rti::ros2::Graph` with a\n`dds::domain::DomainParticipant`:\n\n```cpp\n#include \"dds/dds.hpp\"\n#include \"rticonnextdds_ros2_adapter/rticonnextdds_ros2_adapter_cpp.hpp\"\n\ndds::domain::DomainParticipant my_participant(0);\n\nrti::ros2::GraphProperties props;\nprops.graph_participant = my_participant;\n\nrti::ros2::Graph graph(props);\n```\n\nSimilarly to the C API, users are expected to map local DomainParticipants to\nROS 2 Nodes, and then use the node handles to map their DDS endpoints to ROS 2\nentities.\n\n```cpp\nusing namespace rti::ros2;\n\nGraphNodeHandle node_h = graph.register_local_node(\"my_node\");\nif (GraphNodeHandle_INVALID == endp_h)\n{\n  std::cout \u003c\u003c \"failed to register node\" \u003c\u003c std::endl;\n}\nelse\n{\n  GraphEndpointHandle endp_h = graph.register_local_subscription(node_h, my_reader);\n  if (GraphEndpointHandle_INVALID == endp_h)\n  {\n    std::cout \u003c\u003c \"failed to register subscription\" \u003c\u003c std::endl;\n  }\n}\n```\n\nThe C++ API can also automatically inspect a node's participant:\n\n```cpp\ntry {\n  graph.inspect_local_node(node_h);\n} catch (dds::core::Exception \u0026 e)\n{\n  std::cout \u003c\u003c \"DDS exception: \" \u003c\u003c e.what() \u003c\u003c std::endl;\n}\n```\n\nThe main difference with the C API is that in the C++ API, functions which returned\n`DDS_ReturnCode_t` in C will instead throw an exception\nderived from `dds::core::Exception` in case of error.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasorbini%2Frticonnextdds-ros2-adapter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasorbini%2Frticonnextdds-ros2-adapter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasorbini%2Frticonnextdds-ros2-adapter/lists"}