Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions 1 micro_ros_agent/include/agent/Agent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class Agent

eprosima::uxr::AgentInstance& xrce_dds_agent_instance_;
std::map<eprosima::fastdds::dds::DomainId_t, std::shared_ptr<graph_manager::GraphManager>> graph_manager_map_;
std::string namespace_remapping = "";

std::shared_ptr<graph_manager::GraphManager> find_or_create_graph_manager(eprosima::fastdds::dds::DomainId_t domain_id);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class GraphManager
/**
* @brief Default constructor.
*/
GraphManager(eprosima::fastdds::dds::DomainId_t domain_id);
GraphManager(eprosima::fastdds::dds::DomainId_t domain_id, std::string namespace_remapping);

/**
* @brief Default destructor.
Expand Down Expand Up @@ -274,6 +274,7 @@ class GraphManager
std::string& node_namespace);

eprosima::fastdds::dds::DomainId_t domain_id_;
std::string namespace_remapping_;
bool graph_changed_;
bool display_on_change_;
std::thread microros_graph_publisher_;
Expand Down
16 changes: 13 additions & 3 deletions 16 micro_ros_agent/src/agent/Agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ bool Agent::create(
char** argv)
{
bool result = xrce_dds_agent_instance_.create(argc, argv);

// Find namespace remapping
for (int i = 0; i < argc; i++)
{
if (strcmp(argv[i], "--namespace-remapping") == 0 && i + 1 < argc)
{
namespace_remapping = argv[i + 1];
std::cout << "Remapping all entities to namespace " << namespace_remapping << std::endl;
}
}

if (result)
{
/**
Expand Down Expand Up @@ -293,16 +304,15 @@ void Agent::run()

std::shared_ptr<graph_manager::GraphManager> Agent::find_or_create_graph_manager(eprosima::fastdds::dds::DomainId_t domain_id)
{

auto it = graph_manager_map_.find(domain_id);
auto it = graph_manager_map_.find(domain_id);

if (it != graph_manager_map_.end()) {
return it->second;
}else{
return graph_manager_map_.insert(
std::make_pair(
domain_id,
std::make_shared<graph_manager::GraphManager>(domain_id)
std::make_shared<graph_manager::GraphManager>(domain_id, namespace_remapping)
)
).first->second;
}
Expand Down
16 changes: 13 additions & 3 deletions 16 micro_ros_agent/src/agent/graph_manager/graph_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ namespace uros {
namespace agent {
namespace graph_manager {

GraphManager::GraphManager(eprosima::fastdds::dds::DomainId_t domain_id)
GraphManager::GraphManager(eprosima::fastdds::dds::DomainId_t domain_id, std::string namespace_remapping)
: domain_id_(domain_id)
, namespace_remapping_(namespace_remapping)
, graph_changed_(false)
, display_on_change_(false)
, mtx_()
Expand Down Expand Up @@ -313,6 +314,8 @@ void GraphManager::add_participant(
std::string isolated_node_name, isolated_namespace;
get_name_and_namespace(qos.name().to_string(), isolated_node_name, isolated_namespace);

isolated_namespace = namespace_remapping_ + isolated_namespace;

rmw_dds_common::msg::ParticipantEntitiesInfo info =
graphCache_.add_node(gid, isolated_node_name, isolated_namespace);

Expand Down Expand Up @@ -355,7 +358,10 @@ void GraphManager::add_datawriter(
{
const std::string& topic_name = datawriter->get_topic()->get_name();
const std::string& type_name = datawriter->get_topic()->get_type_name();
this->add_datawriter(datawriter_guid, topic_name, type_name,

auto remapped_topic_name = namespace_remapping_ + "/" + topic_name;

this->add_datawriter(datawriter_guid, remapped_topic_name, type_name,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a mistake here? the remapping should only be in the overload of add_datawriter below? This will double namespace it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably it was intended for add_datareader? Which neither overload has a remapping

participant->guid(), datawriter->get_qos());
}

Expand All @@ -372,7 +378,9 @@ void GraphManager::add_datawriter(
"rmw_fastrtps_cpp", participant_guid);
const rmw_qos_profile_t qos_profile = fastdds_qos_to_rmw_qos(writer_qos);

graphCache_.add_entity(datawriter_gid, topic_name,
auto remapped_topic_name = namespace_remapping_ + "/" + topic_name;

graphCache_.add_entity(datawriter_gid, remapped_topic_name,
type_name, participant_gid, qos_profile, false);
}

Expand Down Expand Up @@ -441,6 +449,7 @@ void GraphManager::associate_entity(
{
std::string isolated_node_name, isolated_namespace;
get_name_and_namespace(qos.name().c_str(), isolated_node_name, isolated_namespace);
isolated_namespace = namespace_remapping_ + isolated_namespace;
info = graphCache_.associate_writer(
entity_gid, participant_gid, isolated_node_name, isolated_namespace);
break;
Expand All @@ -449,6 +458,7 @@ void GraphManager::associate_entity(
{
std::string isolated_node_name, isolated_namespace;
get_name_and_namespace(qos.name().c_str(), isolated_node_name, isolated_namespace);
isolated_namespace = namespace_remapping_ + isolated_namespace;
info = graphCache_.associate_reader(
entity_gid, participant_gid, isolated_node_name, isolated_namespace);
break;
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.