Skip to content

Commit a623308

Browse files
authored
Fix graph manager node namespaces (#72)
1 parent e133754 commit a623308

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

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
}
@@ -587,7 +615,7 @@ static eprosima::fastdds::dds::DataReaderQos reader_qos_conversion(
587615
const eprosima::fastdds::dds::ReaderQos& reader_qos)
588616
{
589617
eprosima::fastdds::dds::DataReaderQos datareader_qos;
590-
618+
591619
datareader_qos.durability(reader_qos.m_durability);
592620
datareader_qos.deadline(reader_qos.m_deadline);
593621
datareader_qos.latency_budget(reader_qos.m_latencyBudget);

0 commit comments

Comments
 (0)