Skip to content

Commit

Permalink
Add private namespaces
Browse files Browse the repository at this point in the history
Signed-off-by: Kotochleb <[email protected]>
  • Loading branch information
Kotochleb committed Mar 18, 2024
1 parent c727652 commit 1b8dbcd
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions ros_gz_bridge/src/ros_gz_bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,20 @@ void RosGzBridge::spin()
std::string config_file;
this->get_parameter("config_file", config_file);
const std::string ros_ns = this->get_namespace();
const std::string ros_node_name = this->get_name();
if (!config_file.empty()) {
auto entries = readFromYamlFile(config_file);
for (auto & entry : entries) {
if (entry.gz_topic_name[0] != '/' && ros_ns.length() > 1) {
entry.gz_topic_name = ros_ns + '/' + entry.gz_topic_name;
if (entry.gz_topic_name[0] != '/') {
if (entry.gz_topic_name[0] == '~' &&
entry.gz_topic_name[1] == '/' &&
ros_node_name.length() > 1) {
entry.gz_topic_name = ros_node_name + '/' +
entry.gz_topic_name.substr(2);
}
if (ros_ns.length() > 1) {
entry.gz_topic_name = ros_ns + '/' + entry.gz_topic_name;
}
}
this->add_bridge(entry);
}
Expand Down

0 comments on commit 1b8dbcd

Please sign in to comment.