Skip to content

Commit

Permalink
fix map saving
Browse files Browse the repository at this point in the history
  • Loading branch information
rafal-gorecki committed Jan 10, 2024
1 parent f5fe37a commit 7b3db1f
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions husarion_utils/healthcheck.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,18 @@ class HealthCheckNode : public rclcpp::Node {
std::placeholders::_1));

save_map_client_ =
create_client<nav2_msgs::srv::SaveMap>("/map_saver/save_map");
create_client<nav2_msgs::srv::SaveMap>("map_saver/save_map");

// Read the ROBOT_NAMESPACE environment variable
const char *robotNamespaceEnv = std::getenv("ROBOT_NAMESPACE");
ns_prefix = (robotNamespaceEnv != nullptr)
? "/" + std::string(robotNamespaceEnv)
: "";
if (!ns_prefix.empty()) {
RCLCPP_INFO(get_logger(), "ROBOT_NAMESPACE: %s", ns_prefix.c_str());
}

// Read the environment variable
// Read the SAVE_MAP_PERIOD environment variable
const char *saveMapPeriodEnv = std::getenv("SAVE_MAP_PERIOD");
if (saveMapPeriodEnv != nullptr) {
try {
Expand Down Expand Up @@ -73,7 +82,7 @@ class HealthCheckNode : public rclcpp::Node {
auto request = std::make_shared<nav2_msgs::srv::SaveMap::Request>();
request->free_thresh = 0.25;
request->occupied_thresh = 0.65;
request->map_topic = "map";
request->map_topic = ns_prefix + "/map";
request->map_url = "/maps/map";
request->map_mode = "trinary";
request->image_format = "png";
Expand All @@ -100,6 +109,7 @@ class HealthCheckNode : public rclcpp::Node {
bool map_exist;
bool is_controller_active;
duration<double> saveMapPeriod;
std::string ns_prefix;

rclcpp::Subscription<nav_msgs::msg::OccupancyGrid>::SharedPtr map_subscriber_;
rclcpp::Subscription<lifecycle_msgs::msg::TransitionEvent>::SharedPtr
Expand Down

0 comments on commit 7b3db1f

Please sign in to comment.