From a175c126857dafd44f3b889057c9dd184d57d392 Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Thu, 7 Dec 2017 14:20:09 -0800 Subject: [PATCH] add node name to user data --- rmw_fastrtps_cpp/src/rmw_node.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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