Nav2 Navigation Stack - rolling  main
ROS 2 Navigation Stack
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
nav2_costmap_2d::ZoneParameterFilter Class Reference

Costmap filter that applies a configured set of ROS parameters based on the mask value at the robot's pose. More...

#include <nav2_costmap_2d/include/nav2_costmap_2d/costmap_filters/zone_parameter_filter.hpp>

Inheritance diagram for nav2_costmap_2d::ZoneParameterFilter:
Inheritance graph
[legend]
Collaboration diagram for nav2_costmap_2d::ZoneParameterFilter:
Collaboration graph
[legend]

Classes

struct  StateParamEntry
 

Public Member Functions

void initializeFilter (const std::string &filter_info_topic) override
 Initialise filter, subscribe to filter info / mask, build per-target-node async parameter clients.
 
void process (nav2_costmap_2d::Costmap2D &master_grid, int min_i, int min_j, int max_i, int max_j, const geometry_msgs::msg::Pose &pose) override
 Sample the mask at the robot pose; if the state changed, apply the new state's parameter set via async client and, if configured, publish the state event.
 
void resetFilter () override
 Reset filter — drop subscriptions, reset publisher, clear nominal-defaults capture.
 
bool isActive ()
 Whether the filter has received its mask and is operational.
 
- Public Member Functions inherited from nav2_costmap_2d::CostmapFilter
 CostmapFilter ()
 A constructor.
 
 ~CostmapFilter ()
 A destructor.
 
mutex_tgetMutex ()
 : returns pointer to a mutex
 
void onInitialize () final
 Initialization process of layer on startup.
 
void updateBounds (double robot_x, double robot_y, double robot_yaw, double *min_x, double *min_y, double *max_x, double *max_y) override
 Update the bounds of the master costmap by this layer's update dimensions. More...
 
void updateCosts (nav2_costmap_2d::Costmap2D &master_grid, int min_i, int min_j, int max_i, int max_j) final
 Update the costs in the master costmap in the window. More...
 
void activate () final
 Activate the layer.
 
void deactivate () final
 Deactivate the layer.
 
void reset () final
 Reset the layer.
 
bool isClearable () final
 If clearing operations should be processed on this layer or not.
 
- Public Member Functions inherited from nav2_costmap_2d::Layer
 Layer ()
 A constructor.
 
virtual ~Layer ()
 A destructor.
 
void initialize (LayeredCostmap *parent, std::string name, nav2::TransformBuffer *tf, const nav2::LifecycleNode::WeakPtr &node, rclcpp::CallbackGroup::SharedPtr callback_group)
 Initialization process of layer on startup.
 
virtual void matchSize ()
 Implement this to make this layer match the size of the parent costmap.
 
virtual void onFootprintChanged ()
 LayeredCostmap calls this whenever the footprint there changes (via LayeredCostmap::setFootprint()). Override to be notified of changes to the robot's footprint.
 
std::string getName () const
 Get the name of the costmap layer.
 
bool isCurrent () const
 Check to make sure all the data in the layer is up to date. If the layer is not up to date, then it may be unsafe to plan using the data from this layer, and the planner may need to know. More...
 
void setCurrent (bool current)
 Set whether the data in the layer is up to date. More...
 
bool isEnabled () const
 Gets whether the layer is enabled.
 
const std::vector< geometry_msgs::msg::Point > & getFootprint () const
 Convenience function for layered_costmap_->getFootprint().
 
std::string getFullName (const std::string &param_name)
 Convenience functions for declaring ROS parameters.
 
std::string joinWithParentNamespace (const std::string &topic)
 

Protected Member Functions

void filterInfoCallback (const nav2_msgs::msg::CostmapFilterInfo::ConstSharedPtr &msg)
 Subscriber callback for the filter info topic.
 
void maskCallback (const nav_msgs::msg::OccupancyGrid::ConstSharedPtr &msg)
 Subscriber callback for the filter mask topic.
 
void loadStateConfig ()
 Parse the per-state parameter map and nominal_defaults from YAML overrides.
 
void applyState (uint8_t new_state)
 Apply the parameter set associated with the given state. State 0 restores nominal_defaults; throws on unknown state.
 
void resetToNominal ()
 Restore all overridden parameters to their nominal_defaults values via async set_parameters.
 
void issueAsyncSetParameters (const std::string &target_node, const std::vector< rclcpp::Parameter > &params)
 Issue an async set_parameters call to the named target node.
 
void checkPendingParameterUpdates ()
 Process completed set_parameters results non-blockingly. Called at the start of every process(); a failed set on any target throws (a failed set on a safety parameter is a stop condition).
 
- Protected Member Functions inherited from nav2_costmap_2d::CostmapFilter
void enableCallback (const std::shared_ptr< rmw_request_id_t > request_header, const std::shared_ptr< std_srvs::srv::SetBool::Request > request, std::shared_ptr< std_srvs::srv::SetBool::Response > response)
 Costmap filter enabling/disabling callback. More...
 
bool transformPose (const std::string global_frame, const geometry_msgs::msg::Pose &global_pose, const std::string mask_frame, geometry_msgs::msg::Pose &mask_pose) const
 : Transforms robot pose from current layer frame to mask frame More...
 
int8_t getMaskData (nav_msgs::msg::OccupancyGrid::ConstSharedPtr filter_mask, const unsigned int mx, const unsigned int my) const
 Get the data of a cell in the filter mask. More...
 
unsigned char getMaskCost (nav_msgs::msg::OccupancyGrid::ConstSharedPtr filter_mask, const unsigned int mx, const unsigned int &my) const
 Get the cost of a cell in the filter mask. More...
 

Protected Attributes

nav2::Subscription< nav2_msgs::msg::CostmapFilterInfo >::SharedPtr filter_info_sub_
 
nav2::Subscription< nav_msgs::msg::OccupancyGrid >::SharedPtr mask_sub_
 
nav2::Publisher< std_msgs::msg::UInt8 >::SharedPtr state_event_pub_
 
nav_msgs::msg::OccupancyGrid::ConstSharedPtr filter_mask_
 
std::string global_frame_
 
uint8_t current_state_ {0}
 
bool state_initialized_ {false}
 
std::map< uint8_t, std::vector< StateParamEntry > > state_param_map_
 
std::map< std::string, std::vector< rclcpp::Parameter > > nominal_defaults_
 
std::map< std::string, rclcpp::AsyncParametersClient::SharedPtr > param_clients_
 
std::vector< std::shared_future< std::vector< rcl_interfaces::msg::SetParametersResult > > > pending_futures_
 
std::string state_event_topic_
 
bool filter_info_received_ {false}
 
- Protected Attributes inherited from nav2_costmap_2d::CostmapFilter
std::string filter_info_topic_
 : Name of costmap filter info topic
 
std::string mask_topic_
 : Name of filter mask topic
 
tf2::Duration transform_tolerance_
 : mask_frame->global_frame_ transform tolerance
 
nav2::ServiceServer< std_srvs::srv::SetBool >::SharedPtr enable_service_
 : A service to enable/disable costmap filter
 
- Protected Attributes inherited from nav2_costmap_2d::Layer
LayeredCostmaplayered_costmap_
 
std::string name_
 
nav2::TransformBuffer * tf_
 
rclcpp::CallbackGroup::SharedPtr callback_group_
 
nav2::LifecycleNode::WeakPtr node_
 
rclcpp::Clock::SharedPtr clock_
 
rclcpp::Logger logger_ {rclcpp::get_logger("nav2_costmap_2d")}
 
std::atomic_bool current_
 
bool enabled_
 

Additional Inherited Members

- Public Types inherited from nav2_costmap_2d::CostmapFilter
typedef std::recursive_mutex mutex_t
 : Provide a typedef to ease future code maintenance
 

Detailed Description

Costmap filter that applies a configured set of ROS parameters based on the mask value at the robot's pose.

The filter mask uses occupancy-grid values. State 0 is the reset state; each non-zero state ID maps via configuration to a list of parameter overrides on configured target nodes.

Definition at line 43 of file zone_parameter_filter.hpp.


The documentation for this class was generated from the following files: