15 #ifndef NAV2_COSTMAP_2D__CLEAR_COSTMAP_SERVICE_HPP_
16 #define NAV2_COSTMAP_2D__CLEAR_COSTMAP_SERVICE_HPP_
23 #include "rclcpp/rclcpp.hpp"
24 #include "nav2_msgs/srv/clear_costmap_except_region.hpp"
25 #include "nav2_msgs/srv/clear_costmap_around_robot.hpp"
26 #include "nav2_msgs/srv/clear_costmap_around_pose.hpp"
27 #include "nav2_msgs/srv/clear_entire_costmap.hpp"
28 #include "nav2_costmap_2d/costmap_layer.hpp"
29 #include "nav2_ros_common/lifecycle_node.hpp"
30 #include "nav2_ros_common/service_server.hpp"
48 const nav2::LifecycleNode::WeakPtr & parent,
Costmap2DROS & costmap);
64 bool clearRegion(
double reset_distance,
bool invert,
const std::vector<std::string> & plugins);
71 const geometry_msgs::msg::PoseStamped & pose,
double reset_distance,
72 const std::vector<std::string> & plugins);
82 rclcpp::Logger logger_{rclcpp::get_logger(
"nav2_costmap_2d")};
88 unsigned char reset_value_;
91 nav2::ServiceServer<nav2_msgs::srv::ClearCostmapExceptRegion>::SharedPtr
92 clear_except_service_;
96 void clearExceptRegionCallback(
97 const std::shared_ptr<rmw_request_id_t> request_header,
98 const std::shared_ptr<nav2_msgs::srv::ClearCostmapExceptRegion::Request> request,
99 const std::shared_ptr<nav2_msgs::srv::ClearCostmapExceptRegion::Response> response);
101 nav2::ServiceServer<nav2_msgs::srv::ClearCostmapAroundRobot>::SharedPtr
102 clear_around_service_;
106 void clearAroundRobotCallback(
107 const std::shared_ptr<rmw_request_id_t> request_header,
108 const std::shared_ptr<nav2_msgs::srv::ClearCostmapAroundRobot::Request> request,
109 const std::shared_ptr<nav2_msgs::srv::ClearCostmapAroundRobot::Response> response);
111 nav2::ServiceServer<nav2_msgs::srv::ClearCostmapAroundPose>::SharedPtr
112 clear_around_pose_service_;
116 void clearAroundPoseCallback(
117 const std::shared_ptr<rmw_request_id_t> request_header,
118 const std::shared_ptr<nav2_msgs::srv::ClearCostmapAroundPose::Request> request,
119 const std::shared_ptr<nav2_msgs::srv::ClearCostmapAroundPose::Response> response);
121 nav2::ServiceServer<nav2_msgs::srv::ClearEntireCostmap>::SharedPtr
122 clear_entire_service_;
126 void clearEntireCallback(
127 const std::shared_ptr<rmw_request_id_t> request_header,
128 const std::shared_ptr<nav2_msgs::srv::ClearEntireCostmap::Request> request,
129 const std::shared_ptr<nav2_msgs::srv::ClearEntireCostmap::Response> response);
134 void clearLayerRegion(
135 std::shared_ptr<CostmapLayer> & costmap,
double pose_x,
double pose_y,
double reset_distance,
141 bool getPosition(
double & x,
double & y)
const;
149 void validatePlugins(
150 const std::vector<std::string> & requested_plugins,
151 const std::vector<std::shared_ptr<Layer>> * layers,
152 std::vector<std::string> & invalid_plugins)
const;
164 bool validateAndClearPlugins(
165 const std::vector<std::string> & plugins,
166 const std::vector<std::shared_ptr<Layer>> * layers,
167 std::function<
void(std::shared_ptr<CostmapLayer> &)> clear_callback,
168 const std::string & operation_name)
const;
Exposes services to clear costmap objects in inclusive/exclusive regions or completely.
bool clearAroundPose(const geometry_msgs::msg::PoseStamped &pose, double reset_distance, const std::vector< std::string > &plugins)
Clears the region around a specific pose.
~ClearCostmapService()
A destructor.
bool clearEntirely(const std::vector< std::string > &plugins)
Clears the entire layer.
ClearCostmapService()=delete
A constructor.
bool clearRegion(double reset_distance, bool invert, const std::vector< std::string > &plugins)
Clears the region outside of a user-specified area reverting to the static map.
A ROS wrapper for a 2D Costmap. Handles subscribing to topics that provide observations about obstacl...