15 #ifndef NAV2_COSTMAP_2D__COSTMAP_FILTERS__ZONE_PARAMETER_FILTER_HPP_
16 #define NAV2_COSTMAP_2D__COSTMAP_FILTERS__ZONE_PARAMETER_FILTER_HPP_
23 #include "geometry_msgs/msg/pose.hpp"
24 #include "nav_msgs/msg/occupancy_grid.hpp"
25 #include "rclcpp/rclcpp.hpp"
26 #include "std_msgs/msg/u_int8.hpp"
28 #include "nav2_costmap_2d/costmap_filters/costmap_filter.hpp"
29 #include "nav2_msgs/msg/costmap_filter_info.hpp"
61 int min_i,
int min_j,
int max_i,
int max_j,
62 const geometry_msgs::msg::Pose & pose)
override;
80 const nav2_msgs::msg::CostmapFilterInfo::ConstSharedPtr & msg);
86 const nav_msgs::msg::OccupancyGrid::ConstSharedPtr & msg);
110 const std::string & target_node,
111 const std::vector<rclcpp::Parameter> & params);
120 nav2::Subscription<nav2_msgs::msg::CostmapFilterInfo>::SharedPtr filter_info_sub_;
121 nav2::Subscription<nav_msgs::msg::OccupancyGrid>::SharedPtr mask_sub_;
122 nav2::Publisher<std_msgs::msg::UInt8>::SharedPtr state_event_pub_;
124 nav_msgs::msg::OccupancyGrid::ConstSharedPtr filter_mask_;
125 std::string global_frame_;
127 uint8_t current_state_{0};
128 bool state_initialized_{
false};
133 std::string target_node;
134 rclcpp::Parameter param;
136 std::map<uint8_t, std::vector<StateParamEntry>> state_param_map_;
138 std::map<std::string, std::vector<rclcpp::Parameter>> nominal_defaults_;
139 std::map<std::string, rclcpp::AsyncParametersClient::SharedPtr> param_clients_;
141 std::vector<std::shared_future<
142 std::vector<rcl_interfaces::msg::SetParametersResult>>> pending_futures_;
144 std::string state_event_topic_;
146 bool filter_info_received_{
false};
A 2D costmap provides a mapping between points in the world and their associated "costs".
: CostmapFilter basic class. It is inherited from Layer in order to avoid hidden problems when the sh...
Costmap filter that applies a configured set of ROS parameters based on the mask value at the robot's...
void loadStateConfig()
Parse the per-state parameter map and nominal_defaults from YAML overrides.
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 asyn...
void applyState(uint8_t new_state)
Apply the parameter set associated with the given state. State 0 restores nominal_defaults; throws on...
void resetFilter() override
Reset filter — drop subscriptions, reset publisher, clear nominal-defaults capture.
void resetToNominal()
Restore all overridden parameters to their nominal_defaults values via async set_parameters.
void maskCallback(const nav_msgs::msg::OccupancyGrid::ConstSharedPtr &msg)
Subscriber callback for the filter mask topic.
bool isActive()
Whether the filter has received its mask and is operational.
void initializeFilter(const std::string &filter_info_topic) override
Initialise filter, subscribe to filter info / mask, build per-target-node async parameter clients.
void issueAsyncSetParameters(const std::string &target_node, const std::vector< rclcpp::Parameter > ¶ms)
Issue an async set_parameters call to the named target node.
void filterInfoCallback(const nav2_msgs::msg::CostmapFilterInfo::ConstSharedPtr &msg)
Subscriber callback for the filter info topic.
void checkPendingParameterUpdates()
Process completed set_parameters results non-blockingly. Called at the start of every process(); a fa...