diff --git a/rmw_fastrtps_cpp/src/rmw_node.cpp b/rmw_fastrtps_cpp/src/rmw_node.cpp index 6f2a404f2..1cb22eb5d 100644 --- a/rmw_fastrtps_cpp/src/rmw_node.cpp +++ b/rmw_fastrtps_cpp/src/rmw_node.cpp @@ -217,7 +217,19 @@ rmw_create_node( Domain::getDefaultParticipantAttributes(participantAttrs); participantAttrs.rtps.builtin.domainId = static_cast(domain_id); + // since the participant name is not part of the DDS spec participantAttrs.rtps.setName(name); + // the node name is also set in the user_data + size_t name_length = strlen(name); + const char prefix[6] = "name="; + participantAttrs.rtps.userData.resize(name_length + sizeof(prefix)); + memcpy(participantAttrs.rtps.userData.data(), prefix, sizeof(prefix) - 1); + { + for (size_t i = 0; i < name_length; ++i) { + participantAttrs.rtps.userData[sizeof(prefix) - 1 + i] = name[i]; + } + participantAttrs.rtps.userData[sizeof(prefix) - 1 + name_length] = ';'; + } if (security_options->security_root_path) { // if security_root_path provided, try to find the key and certificate files