• Stars
    star
    155
  • Rank 240,864 (Top 5 %)
  • Language
    C++
  • License
    Apache License 2.0
  • Created over 9 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Implementation of the ROS Middleware (rmw) Interface using eProsima's Fast RTPS.

ROS 2 Middleware Implementation for eProsima's Fast DDS

rmw_fastrtps is a ROS 2 middleware implementation, providing an interface between ROS 2 and eProsima's Fast DDS middleware.

Getting started

This implementation is available in all ROS 2 distributions, both from binaries and from sources. You can specify Fast DDS as your ROS 2 middleware layer in two different ways:

  1. Exporting RMW_IMPLEMENTATION environment variable:
    export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
  2. When launching your ROS 2 application:
    RMW_IMPLEMENTATION=rmw_fastrtps_cpp ros2 run <your_package> <your application>

Two different RMW implementations

rmw_fastrtps actually provides not one but two different ROS 2 middleware implementations, both of them using Fast DDS as middleware layer: rmw_fastrtps_cpp and rmw_fastrtps_dynamic_cpp (note that directory rmw_fastrtps_shared_cpp just contains the code that the two implementations share, and does not constitute a layer on its own).

The main difference between the two is that rmw_fastrtps_dynamic_cpp uses introspection typesupport at run time to decide on the serialization/deserialization mechanism. On the other hand, rmw_fastrtps_cpp uses its own typesupport, which generates the mapping for each message type at build time.

Mind that the default ROS 2 RMW implementation is rmw_fastrtps_cpp. You can however set it to rmw_fastrtps_dynamic_cpp using the environment variable RMW_IMPLEMENTATION as described above.

Advance usage

ROS 2 only allows for the configuration of certain middleware features. For example, see ROS 2 QoS policies). In addition to ROS 2 QoS policies, rmw_fastrtps sets two more Fast DDS configurable parameters:

  • History memory policy: PREALLOCATED_WITH_REALLOC_MEMORY_MODE
  • Publication mode: ASYNCHRONOUS_PUBLISH_MODE

However, rmw_fastrtps offers the possibility to further configure Fast DDS:

Change publication mode

Fast DDS features two different publication modes: synchronous and asynchronous. To learn more about the implications of choosing one mode over the other, please refer to DDS: Asynchronous vs Synchronous Publishing:

rmw_fastrtps offers an easy way to change Fast DDS' publication mode without the need of defining a XML file. That is environment variable RMW_FASTRTPS_PUBLICATION_MODE. The admissible values are:

  • ASYNCHRONOUS: asynchronous publication mode. Setting this mode implies that when the publisher invokes the write operation, the data is copied into a queue, a notification about the addition to the queue is performed, and control of the thread is returned to the user before the data is actually sent. A background thread (asynchronous thread) is in turn in charge of consuming the queue and sending the data to every matched reader.
  • SYNCHRONOUS: synchronous publication mode. Setting this mode implies that the data is sent directly within the context of the user thread. This entails that any blocking call occurring during the write operation would block the user thread, thus preventing the application with continuing its operation. It is important to note that this mode typically yields higher throughput rates at lower latencies, since the notification and context switching between threads is not present.
  • AUTO: let Fast DDS select the publication mode. This implies using the publication mode set in the XML file or, failing that, the default value set in Fast DDS (which currently is set to SYNCHRONOUS).

If RMW_FASTRTPS_PUBLICATION_MODE is not set, then both rmw_fastrtps_cpp and rmw_fastrtps_dynamic_cpp behave as if it were set to SYNCHRONOUS.

Full QoS configuration

Fast DDS QoS policies can be fully configured through a combination of the rmw QoS profile API, and the Fast DDS XML file's QoS elements. Configuration depends on the environment variable RMW_FASTRTPS_USE_QOS_FROM_XML.

  1. ROS 2 QoS contained in rmw_qos_profile_t are always honored, unless set to *_SYSTEM_DEFAULT. In that case, XML values, or Fast DDS default values in the absence of XML ones, are applied. Setting any QoS in rmw_qos_profile_t to something other than *_SYSTEM_DEFAULT entails that specifying it via XML files has no effect, since they do not override what was used to create the publisher, subscription, service, or client.
  2. In order to modify the history memory policy or publication mode using XML files, environment variable RMW_FASTRTPS_USE_QOS_FROM_XML must be set to 1 (it is set to 0 by default). This tells rmw_fastrtps that it should override both the history memory policy and the publication mode using the XML. Bear in mind that setting this environment variable but not setting either of these policies in the XML results in Fast DDS' defaults configurations being used.
RMW_FASTRTPS_USE_QOS_FROM_XML rmw QoS profile Fast DDS XML QoS Fast DDS XML history memory policy and publication mode
0 (default) Use default values Ignored - overridden by rmw_qos_profile_t Ignored - overrided by rmw_fastrtps
0 (default) Set to non system default Ignored - overridden by rmw_qos_profile_t Ignored - overrided by rmw_fastrtps
0 (default) Set to system default Used Ignored - overrided by rmw_fastrtps
1 Use default values Ignored - overridden by rmw_qos_profile_t Used
1 Set to non system default Ignored - overridden by rmw_qos_profile_t Used
1 Set to system default Used Used

Note: Setting RMW_FASTRTPS_USE_QOS_FROM_XML to 1 effectively overrides whatever configuration was set with RMW_FASTRTPS_PUBLICATION_MODE. Furthermore, If RMW_FASTRTPS_USE_QOS_FROM_XML is set to 1, and history memory policy or publication mode are not specified in the XML, then the Fast DDS' default configurations will be used:

There are two ways of telling a ROS 2 application which XML to use:

  1. Placing your XML file in the running directory under the name DEFAULT_FASTRTPS_PROFILES.xml.
  2. Setting environment variable FASTRTPS_DEFAULT_PROFILES_FILE to contain the path to your XML file (relative to the working directory).

To verify the actual QoS settings using rmw:

// Create a publisher within a node with specific topic, type support, options, and QoS
rmw_publisher_t* rmw_publisher = rmw_create_publisher(node, type_support, topic_name, qos_profile, publisher_options);
// Check the actual QoS set on the publisher
rmw_qos_profile_t qos;
rmw_publisher_get_actual_qos(rmw_publisher, &qos);

Applying different profiles to different entities

rmw_fastrtps allows for the configuration of different entities with different QoS using the same XML file. For doing so, rmw_fastrtps locates profiles in the XML based on topic names abiding to the following rules:

Creating publishers/subscriptions with different profiles

To configure a publisher/subscription, define a <publisher>/<subscriber> profile with attribute profile_name=topic_name, where topic name is the name of the topic prepended by the node namespace (which defaults to "" if not specified), i.e. the node's namespace followed by topic name used to create the publisher/subscription. Mind that topic names always start with / (it is added when creating the topic if not present), and that namespace and topic name are always separated by one /. If such profile is not defined, rmw_fastrtps attempts to load the <publisher>/<subscriber> profile with attribute is_default_profile="true". The following table presents different combinations of node namespaces and user specified topic names, as well as the resulting topic names and the suitable profile names:

User specified topic name Node namespace Final topic name Profile name
chatter DEFAULT ("") /chatter /chatter
chatter test_namespace /test_namespace/chatter /test_namespace/chatter
chatter /test_namespace /test_namespace/chatter /test_namespace/chatter
/chatter test_namespace /chatter /chatter
/chatter /test_namespace /chatter /chatter

IMPORTANT: As shown in the table, node namespaces are NOT prepended to user specified topic names starting with /, a.k.a Fully Qualified Names (FQN). For a complete description of topic name remapping please refer to Remapping Names.

Creating services with different profiles

ROS 2 services contain a subscription for receiving requests, and a publisher to reply to them. rmw_fastrtps allows for configuring each of these endpoints separately in the following manner:

  1. To configure the request subscription, define a <subscriber> profile with attribute profile_name=topic_name, where topic name is the name of the service after mangling. For more information on name mangling, please refer to Topic and Service name mapping to DDS. If such profile is not defined, rmw_fastrtps attempts to load a <subscriber> profile with attribute profile_name="service". If neither of the previous profiles exist, rmw_fastrtps attempts to load the <subscriber> profile with attribute is_default_profile="true".
  2. To configure the reply publisher, define a <publisher> profile with attribute profile_name=topic_name, where topic name is the name of the service after mangling. If such profile is not defined, rmw_fastrtps attempts to load a <publisher> profile with attribute profile_name="service". If neither of the previous profiles exist, rmw_fastrtps attempts to load the <publisher> profile with attribute is_default_profile="true".
Creating clients with different profiles

ROS 2 clients contain a publisher to send requests, and a subscription to receive the service's replies. rmw_fastrtps allows for configuring each of these endpoints separately in the following manner:

  1. To configure the requests publisher, define a <publisher> profile with attribute profile_name=topic_name, where topic name is the name of the service after mangling. If such profile is not defined, rmw_fastrtps attempts to load a <publisher> profile with attribute profile_name="client". If neither of the previous profiles exist, rmw_fastrtps attempts to load the <publisher> profile with attribute is_default_profile="true".
  2. To configure the reply subscription, define a <subscriber> profile with attribute profile_name=topic_name, where topic name is the name of the service after mangling. If such profile is not defined, rmw_fastrtps attempts to load a <subscriber> profile with attribute profile_name="client". If neither of the previous profiles exist, rmw_fastrtps attempts to load the <subscriber> profile with attribute is_default_profile="true".

Example

The following example configures Fast DDS to publish synchronously, and to have a pre-allocated history that can be expanded whenever it gets filled.

  1. Create a Fast DDS XML file with:

    <?xml version="1.0" encoding="UTF-8"?>
    <dds xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles">
        <profiles>
            <!-- Default publisher profile -->
            <publisher profile_name="default publisher profile" is_default_profile="true">
                <qos>
                    <publishMode>
                        <kind>SYNCHRONOUS</kind>
                    </publishMode>
                </qos>
                <historyMemoryPolicy>PREALLOCATED_WITH_REALLOC</historyMemoryPolicy>
            </publisher>
    
            <!-- Default subscriber profile -->
            <subscriber profile_name="default subscriber profile" is_default_profile="true">
                <historyMemoryPolicy>PREALLOCATED_WITH_REALLOC</historyMemoryPolicy>
            </subscriber>
    
            <!-- Publisher profile for topic helloworld -->
            <publisher profile_name="helloworld">
                <qos>
                    <publishMode>
                        <kind>SYNCHRONOUS</kind>
                    </publishMode>
                </qos>
            </publisher>
    
            <!-- Request subscriber profile for services -->
            <subscriber profile_name="service">
                <historyMemoryPolicy>PREALLOCATED_WITH_REALLOC</historyMemoryPolicy>
            </subscriber>
    
            <!-- Request publisher profile for clients -->
            <publisher profile_name="client">
                <qos>
                    <publishMode>
                        <kind>ASYNCHRONOUS</kind>
                    </publishMode>
                </qos>
            </publisher>
    
            <!-- Request subscriber profile for server of service "add_two_ints" -->
            <subscriber profile_name="rq/add_two_intsRequest">
                <historyMemoryPolicy>PREALLOCATED_WITH_REALLOC</historyMemoryPolicy>
            </subscriber>
    
            <!-- Reply subscriber profile for client of service "add_two_ints" -->
            <subscriber profile_name="rr/add_two_intsReply">
                <historyMemoryPolicy>PREALLOCATED_WITH_REALLOC</historyMemoryPolicy>
            </subscriber>
        </profiles>
    </dds>
  2. Run the talker/listener ROS 2 demo:

    1. In one terminal

      FASTRTPS_DEFAULT_PROFILES_FILE=<path_to_xml_file> RMW_FASTRTPS_USE_QOS_FROM_XML=1 RMW_IMPLEMENTATION=rmw_fastrtps_cpp ros2 run demo_nodes_cpp talker
    2. In another terminal

      FASTRTPS_DEFAULT_PROFILES_FILE=<path_to_xml_file> RMW_FASTRTPS_USE_QOS_FROM_XML=1 RMW_IMPLEMENTATION=rmw_fastrtps_cpp ros2 run demo_nodes_cpp listener

Change participant discovery options

ROS 2 allows controlling participant discovery with two environment variables: ROS_AUTOMATIC_DISCOVERY_RANGE and ROS_STATIC_PEERS. Full configuration of participant discovery can also be set with XML files; however, the ROS specific environment variables should be disabled to prevent them from interfering. Set ROS_AUTOMATIC_DISCOVERY_RANGE to the value SYSTEM_DEFAULT to disable both ROS specific environment variables.

Quality Declaration files

Quality Declarations for each package in this repository:

Quality Declarations for the external dependencies of these packages can be found in:

More Repositories

1

ros2

The Robot Operating System, is a meta operating system for robots.
3,426
star
2

examples

Example packages for ROS 2
C++
683
star
3

ros2_documentation

ROS 2 docs repository
Python
541
star
4

rclcpp

rclcpp (ROS Client Library for C++)
C++
536
star
5

demos

C++
491
star
6

ros1_bridge

ROS 2 package that provides bidirectional communication between ROS 1 and ROS 2
C++
435
star
7

rclpy

rclpy (ROS Client Library for Python)
Python
288
star
8

rviz

ROS 3D Robot Visualizer
C++
287
star
9

rosbag2

C++
272
star
10

design

Design documentation for ROS 2.0 effort
JavaScript
224
star
11

common_interfaces

A set of packages which contain common interface files (.msg and .srv).
C++
220
star
12

ros2cli

ROS 2 command line interface tools
Python
173
star
13

rmw_zenoh

RMW for ROS 2 using Zenoh as the middleware
C++
171
star
14

rmw_iceoryx

rmw implementation for iceoryx
C++
153
star
15

ros2_tracing

Tracing tools for ROS 2.
Python
137
star
16

rcl

Library to support implementation of language specific ROS Client Libraries.
C++
128
star
17

launch

Tools for launching multiple processes and for writing tests involving multiple processes.
Python
123
star
18

geometry2

A set of ROS packages for keeping track of coordinate transforms.
C++
120
star
19

rclc

ROS Client Library for the C language.
C
113
star
20

rmw_cyclonedds

ROS 2 RMW layer for Eclipse Cyclone DDS
C++
112
star
21

turtlebot2_demo

C++
95
star
22

rmw

The ROS Middleware (rmw) Interface.
C
95
star
23

sros2

tools to generate and distribute keys for SROS 2
Python
89
star
24

freertps

a free, portable, minimalist, work-in-progress RTPS implementation
C
89
star
25

rosidl

Packages which provide the ROS IDL (.msg) definition and code generation.
C++
74
star
26

ros2_embedded_nuttx

This repository isn't actively being worked on. If you would like to take over maintainership please open a ticket on https://github.com/ros2/ros2
C
72
star
27

message_filters

C++
70
star
28

realtime_support

Minimal real-time testing utility for measuring jitter and latency.
C++
61
star
29

rcutils

Common C functions and data structures used in ROS 2
C
56
star
30

launch_ros

Tools for launching ROS nodes and for writing tests involving ROS nodes.
Python
55
star
31

domain_bridge

Bridge communication across different ROS 2 domains.
C++
52
star
32

ci

ROS 2 CI Infrastructure
Python
48
star
33

rmw_connextdds

ROS 2 RMW layer for RTI Connext DDS Professional and RTI Connext DDS Micro.
C++
47
star
34

example_interfaces

Msg, Srv, etc. ROS interfaces used in examples
CMake
47
star
35

system_tests

C++
38
star
36

rcl_interfaces

A repository for messages and services used by the ROS client libraries
C++
38
star
37

rcpputils

C++
31
star
38

tutorials

C++
30
star
39

ros2_embedded_freertos

This repository isn't actively being worked on. If you would like to take over maintainership please open a ticket on https://github.com/ros2/ros2 -- ROS 2 for embedded devices.
C
29
star
40

rmw_connext

Implementation of the ROS Middleware (rmw) Interface using RTI's Connext DDS.
C++
26
star
41

choco-packages

Chocolatey package configurations for upstream dependencies
PowerShell
25
star
42

rosbag2_bag_v2

rosbag2 plugin for replaying ros1 version2 bag files
C++
24
star
43

rmw_dps

Implementation of the ROS Middleware (rmw) Interface using Intel's Distributed Publish & Subscribe.
C++
23
star
44

buildfarm_perf_tests

Performance tests which run regularly on the buildfarm
C++
23
star
45

rmw_implementation

CMake infrastructure and dependencies for rmw implementations
C++
21
star
46

openrobotics_darknet_ros

ROS 2 interface to darknet, an open source neural network library.
C++
20
star
47

rosidl_python

rosidl support for Python
EmberScript
19
star
48

ros_core_documentation

Documentation for the Core ROS 2 packages which does not fit into one of the individual packages' documentation.
Python
17
star
49

ros_network_viz

Python
17
star
50

rcl_logging

Logging implementations for ROS 2.
C++
16
star
51

rmw_gurumdds

Implementation of the ROS middleware interface using GurumNetworks GurumDDS.
C++
13
star
52

ros_testing

Single point of entry for writing tests which involve Nodes in ROS 2.
Python
13
star
53

rosidl_typesupport

Packages which provide the typesupport for ROS messages and services
C++
13
star
54

eigen3_cmake_module

Adds a custom find module for Eigen3
CMake
12
star
55

rmw_dds_common

C++
11
star
56

rmw_opensplice

Implementation of the ROS Middleware (rmw) interface using PrismTech's OpenSplice DDS.
C++
11
star
57

variants

Variants for ROS 2 (implemented as ament packages)
CMake
9
star
58

cookbook

A set of recipes for doing common tasks in ROS 2
C++
9
star
59

ros_workspace

Package to set ROS environment and configuration variables for ROS 2.
CMake
7
star
60

performance_test_fixture

Test fixture and CMake macro for using osrf_testing_tools_cpp with Google Benchmark
C++
7
star
61

tsc_working_group_governance_template

7
star
62

unique_identifier_msgs

CMake
6
star
63

rosidl_dds

Python
6
star
64

tlsf

Snapshot of TLSF allocator
C
6
star
65

detection_visualizer

ROS 2 package with a node that draws bound boxes for debugging computer vision nodes.
Python
6
star
66

rosidl_runtime_py

Runtime utilities for working with generated ROS interfaces in Python
Python
5
star
67

ros2_dds_profiles_examples

Example dds profiles to configure DDS correctly for different use cases
Python
5
star
68

rosidl_typesupport_gurumdds

Typesupport package which generates interfaces used by rmw_gurumdds.
EmberScript
4
star
69

python_cmake_module

CMake module for finding Python in a consistent way for all ROS 2 packages.
CMake
4
star
70

ament_cmake_ros

Python
4
star
71

darknet_vendor

CMake wrapper around darknet, an open source neural network framework.
CMake
4
star
72

ros2_generate_interface_docs

Python
4
star
73

middleware_working_group

Working group focused on functionality provided by the communication middleware and the language specific client libraries.
4
star
74

test_interface_files

CMake
3
star
75

rosidl_typesupport_opensplice

rosidl typesupport for PrismTech's OpenSplice DDS.
EmberScript
3
star
76

pybind11_vendor

Vendor package for pybind11.
CMake
3
star
77

tinyxml_vendor

Vendor package for providing tinyxml within a cmake package
CMake
2
star
78

rosidl_typesupport_fastrtps

rosidl typesupport for eProsima's FastRTPS
EmberScript
2
star
79

spdlog_vendor

Vendor package for spdlog
CMake
2
star
80

rosidl_dynamic_typesupport

Unified Interface for Dynamic (Runtime) Typesupport and Serialization
C
2
star
81

tinyxml2_vendor

temporary vendor package for tinyxml2
CMake
2
star
82

libyaml_vendor

CMake wrapper downloading and building libyaml
C++
2
star
83

orocos_kdl_vendor

CMake
2
star
84

unique_identifier

ROS 2 support for Universally Unique Identifiers
C++
1
star
85

rmw_freertps

rmw implementation using freertps
C++
1
star
86

netperf

C++
1
star
87

ros2.github.io

website for ros2.org
HTML
1
star
88

mimick_vendor

CMake
1
star
89

yaml_cpp_vendor

Vendor package for providing yaml cpp within a cmake package
CMake
1
star
90

ros2doc

i can haz docs?
Python
1
star
91

ros2cli_common_extensions

CMake
1
star
92

poco_vendor

CMake shim over the poco library: https://github.com/pocoproject/poco
CMake
1
star
93

rosidl_typesupport_connext

rosidl typesupport for RTI's Connext DDS.
EmberScript
1
star
94

docs.ros2.org

HTML
1
star