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

[collision monitor] Transient local durability for subscription to polygon topic #4207

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ class Polygon
double simulation_time_step_;
/// @brief Whether polygon is enabled
bool enabled_;
/// @brief Wether the subscription to polygon topic has transient local QoS durability
bool polygon_subscribe_transient_local_;
/// @brief Polygon subscription
rclcpp::Subscription<geometry_msgs::msg::PolygonStamped>::SharedPtr polygon_sub_;
/// @brief Footprint subscriber
Expand Down
7 changes: 7 additions & 0 deletions nav2_collision_monitor/src/polygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ bool Polygon::configure()
"[%s]: Subscribing on %s topic for polygon",
polygon_name_.c_str(), polygon_sub_topic.c_str());
rclcpp::QoS polygon_qos = rclcpp::SystemDefaultsQoS(); // set to default
if (polygon_subscribe_transient_local_) {
polygon_qos.transient_local();
}
polygon_sub_ = node->create_subscription<geometry_msgs::msg::PolygonStamped>(
polygon_sub_topic, polygon_qos,
std::bind(&Polygon::polygonCallback, this, std::placeholders::_1));
Expand Down Expand Up @@ -432,6 +435,10 @@ bool Polygon::getParameters(
footprint_topic =
node->get_parameter(polygon_name_ + ".footprint_topic").as_string();
}
nav2_util::declare_parameter_if_not_declared(
node, polygon_name_ + ".polygon_subscribe_transient_local", rclcpp::ParameterValue(false));
polygon_subscribe_transient_local_ =
node->get_parameter(polygon_name_ + ".polygon_subscribe_transient_local").as_bool();
} catch (const std::exception & ex) {
RCLCPP_ERROR(
logger_,
Expand Down
Loading