Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added transient local subscription qos profile parameter to map saver #1871

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions nav2_bringup/bringup/launch/tb3_simulation_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ def generate_launch_description():
# TODO(orduno) Switch back once ROS argument passing has been fixed upstream
# https://github.com/ROBOTIS-GIT/turtlebot3_simulations/issues/91
# default_value=os.path.join(get_package_share_directory('turtlebot3_gazebo'),
# 'worlds/turtlebot3_worlds/waffle.model'),
default_value=os.path.join(bringup_dir, 'worlds', 'waffle.model'),
# 'worlds/turtlebot3_worlds/house.world'),
default_value=os.path.join(bringup_dir, 'worlds', 'house.world'),
Copy link
Member

Choose a reason for hiding this comment

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

We don't have a house.world file in our package for that to be a valid default. If you'd like to propose adding one, we can talk about that for sure, but in another ticket / PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like my IDE did some automatic refactor with cached information about a house world I worked on for a bit. My bad for not checking.

description='Full path to world model file to load')

# Specify the actions
Expand Down
1 change: 1 addition & 0 deletions nav2_bringup/bringup/params/nav2_params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ map_saver:
save_map_timeout: 5000
free_thresh_default: 0.25
occupied_thresh_default: 0.65
map_subscribe_transient_local: True
SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved

planner_server:
ros__parameters:
Expand Down
2 changes: 2 additions & 0 deletions nav2_map_server/include/nav2_map_server/map_saver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ class MapSaver : public nav2_util::LifecycleNode
// Default values for map thresholds
double free_thresh_default_;
double occupied_thresh_default_;
// param for handling QoS configuration
bool map_subscribe_transient_local_;

// The name of the service for saving a map from topic
const std::string save_map_service_name_{"save_map"};
Expand Down
9 changes: 8 additions & 1 deletion nav2_map_server/src/map_saver/map_saver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ MapSaver::MapSaver()

free_thresh_default_ = declare_parameter("free_thresh_default", 0.25),
occupied_thresh_default_ = declare_parameter("occupied_thresh_default", 0.65);
map_subscribe_transient_local_ = declare_parameter("map_subscribe_transient_local", true);
}

MapSaver::~MapSaver()
Expand Down Expand Up @@ -180,8 +181,14 @@ bool MapSaver::saveMapTopicToFile(
// Add new subscription for incoming map topic.
// Utilizing local rclcpp::Node (rclcpp_node_) from nav2_util::LifecycleNode
// as a map listener.
rclcpp::QoS map_qos(10); // initialize to default
if (map_subscribe_transient_local_) {
map_qos.transient_local();
map_qos.reliable();
map_qos.keep_last(1);
}
auto map_sub = rclcpp_node_->create_subscription<nav_msgs::msg::OccupancyGrid>(
map_topic_loc, rclcpp::SystemDefaultsQoS(), mapCallback);
map_topic_loc, map_qos, mapCallback);

rclcpp::Time start_time = now();
while (rclcpp::ok()) {
Expand Down