Skip to content

Commit 9d3fbc6

Browse files
Fix graph manager node namespaces (backport #72) (#73)
* Fix graph manager node namespaces (#72) (cherry picked from commit a623308) # Conflicts: # micro_ros_agent/src/agent/graph_manager/graph_manager.cpp * Update graph_manager.cpp Co-authored-by: Pablo Garrido <pablogs9@gmail.com>
1 parent a3fe4aa commit 9d3fbc6

1 file changed

Lines changed: 30 additions & 2 deletions

File tree

micro_ros_agent/src/agent/graph_manager/graph_manager.cpp

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,36 @@ void GraphManager::add_participant(
309309

310310
if (node_name != enclave) // Do not add root node
311311
{
312+
// Split node name in domain and node name
313+
std::istringstream iss(node_name);
314+
std::vector<std::string> result;
315+
std::string token;
316+
317+
while(std::getline(iss, token, '/'))
318+
{
319+
result.push_back(token);
320+
}
321+
322+
std::string isolated_node_name = "";
323+
std::string isolated_namespace = "";
324+
325+
if (result.size() > 1)
326+
{
327+
isolated_namespace = result[0];
328+
for (size_t i = 1; i < result.size(); i++)
329+
{
330+
isolated_node_name.append(result[i] + "/");
331+
}
332+
isolated_node_name.pop_back();
333+
}
334+
else
335+
{
336+
isolated_node_name = node_name;
337+
isolated_namespace = "";
338+
}
339+
312340
rmw_dds_common::msg::ParticipantEntitiesInfo info =
313-
graphCache_.add_node(gid, node_name, enclave_);
341+
graphCache_.add_node(gid, isolated_node_name, isolated_namespace);
314342
ros_discovery_datawriter_->write(static_cast<void *>(&info));
315343
}
316344
}
@@ -684,4 +712,4 @@ void GraphManager::DatareaderListener::on_data_available(
684712
} // namespace agent
685713
} // namespace uros
686714

687-
#endif // _UROS_AGENT_GRAPH_MANAGER_CPP
715+
#endif // _UROS_AGENT_GRAPH_MANAGER_CPP

0 commit comments

Comments
 (0)