15 #ifndef NAV2_COLLISION_MONITOR__EXCLUSION_ZONE_HPP_
16 #define NAV2_COLLISION_MONITOR__EXCLUSION_ZONE_HPP_
23 #include "rclcpp/rclcpp.hpp"
24 #include "geometry_msgs/msg/polygon_stamped.hpp"
26 #include "tf2/time.hpp"
27 #include "tf2/LinearMath/Transform.hpp"
29 #include "nav2_ros_common/lifecycle_node.hpp"
30 #include "nav2_ros_common/tf2_factories.hpp"
32 #include "nav2_msgs/msg/exclusion_zone_description.hpp"
34 #include "nav2_collision_monitor/types.hpp"
36 namespace nav2_collision_monitor
65 const nav2::LifecycleNode::WeakPtr & node,
66 const std::string & zone_name,
67 const nav2::TransformBuffer::SharedPtr tf_buffer,
68 const std::string & base_frame_id,
69 const std::string & global_frame_id,
70 const tf2::Duration & transform_tolerance,
71 const bool base_shift_correction);
89 bool configure(
const nav2_msgs::msg::ExclusionZoneDescription & desc);
108 void apply(
const rclcpp::Time & curr_time, std::vector<Point> & data)
const;
146 const std::vector<rclcpp::Parameter> & parameters);
155 const rclcpp::Time & curr_time, tf2::Transform & tf_zone_to_base)
const;
162 rclcpp::Logger
logger_{rclcpp::get_logger(
"collision_monitor")};
167 rclcpp::node_interfaces::PostSetParametersCallbackHandle::SharedPtr post_set_params_handler_;
168 rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr on_set_params_handler_;
208 nav2::Publisher<geometry_msgs::msg::PolygonStamped>::SharedPtr
zone_pub_;
Region that removes (masks out) source points falling inside it.
bool base_shift_correction_
Whether to correct the zone transform for base movement between data and current time.
void deactivate()
Deactivates the visualization publisher (if any)
nav2::TransformBuffer::SharedPtr tf_buffer_
TF buffer.
double min_height_
Lower bound of the height band (base-frame z) a point must be within to be excluded.
void apply(const rclcpp::Time &curr_time, std::vector< Point > &data) const
Removes from data all points that fall inside the (enabled) zone. No-op when the zone is disabled....
rclcpp::Logger logger_
Collision monitor node logger.
bool enabled_
Whether the zone is currently active.
double radius_
Circle radius (for circle type)
double radius_squared_
radius squared, cached
~ExclusionZone()
ExclusionZone destructor.
bool getParameters()
Reads ROS parameters for the zone.
ExclusionZone(const nav2::LifecycleNode::WeakPtr &node, const std::string &zone_name, const nav2::TransformBuffer::SharedPtr tf_buffer, const std::string &base_frame_id, const std::string &global_frame_id, const tf2::Duration &transform_tolerance, const bool base_shift_correction)
ExclusionZone constructor.
bool is_circle_
Whether the zone shape is a circle (otherwise polygon)
double frame_hold_timeout_
Extra time (s) beyond the transform tolerance that a stale zone-frame pose may keep being used before...
bool getZoneToBaseTransform(const rclcpp::Time &curr_time, tf2::Transform &tf_zone_to_base) const
Resolve the zone-frame -> base-frame transform for this cycle.
std::vector< Point > poly_
Zone polygon vertices, expressed in frame_id_ (for polygon type)
bool visualize_
Whether to publish the zone footprint for visualization.
std::string zone_name_
Name of the zone.
bool configure()
Reads ROS parameters and configures the zone.
std::string global_frame_id_
Global (fixed) frame ID, used to bridge the zone lookup in time.
std::string frame_id_
Frame the zone shape is anchored to (tracked via TF). Defaults to base_frame_id_.
std::string base_frame_id_
Robot base frame ID.
void publish() const
Publishes the zone footprint for visualization (if enabled)
void activate()
Activates the visualization publisher (if any)
nav2::LifecycleNode::WeakPtr node_
Collision Monitor node.
bool getEnabled() const
Obtains the enabled state of the zone.
rclcpp::Clock::SharedPtr node_clock_
Node clock (for throttled logging and message stamps)
void updateParametersCallback(const std::vector< rclcpp::Parameter > ¶meters)
Apply parameter updates after validation (dynamic reconfigure)
std::string getName() const
Obtains the name of the zone.
std::mutex mutex_
Dynamic parameters handlers.
double max_height_
Upper bound of the height band (base-frame z) a point must be within to be excluded.
rcl_interfaces::msg::SetParametersResult validateParameterUpdatesCallback(const std::vector< rclcpp::Parameter > ¶meters)
Validate incoming parameter updates before applying them.
nav2::Publisher< geometry_msgs::msg::PolygonStamped >::SharedPtr zone_pub_
Zone footprint publisher.
tf2::Duration transform_tolerance_
Transform tolerance.