Skip to content

Commit

Permalink
adding namespace support for map saving (#613)
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveMacenski committed Sep 25, 2023
1 parent 5445c62 commit b26c7c3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/map_saver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,16 @@ bool MapSaver::saveMapCallback(
}

const std::string name = req->name.data;
std::string set_namespace;
const std::string namespace_str = std::string(node_->get_namespace());
if (!namespace_str.empty()) {
set_namespace = " -r __ns:=" + namespace_str;
}

if (name != "") {
RCLCPP_INFO(node_->get_logger(),
"SlamToolbox: Saving map as %s.", name.c_str());
int rc = system(("ros2 run nav2_map_server map_saver_cli -f " + name + " --ros-args -p map_subscribe_transient_local:=true").c_str());
int rc = system(("ros2 run nav2_map_server map_saver_cli -f " + name + " --ros-args -p map_subscribe_transient_local:=true" + set_namespace).c_str());
if (rc == 0) {
response->result = response->RESULT_SUCCESS;
} else {
Expand All @@ -70,7 +76,7 @@ bool MapSaver::saveMapCallback(
} else {
RCLCPP_INFO(node_->get_logger(),
"SlamToolbox: Saving map in current directory.");
int rc = system("ros2 run nav2_map_server map_saver_cli --ros-args -p map_subscribe_transient_local:=true");
int rc = system(("ros2 run nav2_map_server map_saver_cli --ros-args -p map_subscribe_transient_local:=true" + set_namespace).c_str());
if (rc == 0) {
response->result = response->RESULT_SUCCESS;
} else {
Expand Down

0 comments on commit b26c7c3

Please sign in to comment.