Nav2 Navigation Stack - lyrical  lyrical
ROS 2 Navigation Stack
plugin_container_layer.hpp
1 // Copyright (c) 2024 Polymath Robotics, Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef NAV2_COSTMAP_2D__PLUGIN_CONTAINER_LAYER_HPP_
16 #define NAV2_COSTMAP_2D__PLUGIN_CONTAINER_LAYER_HPP_
17 
18 #include <cmath>
19 #include <memory>
20 #include <string>
21 #include <vector>
22 
23 #include "rclcpp/rclcpp.hpp"
24 #include "nav2_costmap_2d/layer.hpp"
25 #include "nav2_costmap_2d/layered_costmap.hpp"
26 #include "nav2_costmap_2d/costmap_layer.hpp"
27 #include "nav2_costmap_2d/observation_buffer.hpp"
28 #include "nav2_costmap_2d/inflation_layer.hpp"
29 #include "nav2_ros_common/tf2_factories.hpp"
30 #include "pluginlib/class_loader.hpp"
31 
32 using nav2_costmap_2d::LETHAL_OBSTACLE;
33 using nav2_costmap_2d::INSCRIBED_INFLATED_OBSTACLE;
34 using nav2_costmap_2d::NO_INFORMATION;
35 using rcl_interfaces::msg::ParameterType;
36 namespace nav2_costmap_2d
37 {
43 {
44 public:
48  void onInitialize() override;
60  void updateBounds(
61  double robot_x,
62  double robot_y,
63  double robot_yaw,
64  double * min_x,
65  double * min_y,
66  double * max_x,
67  double * max_y) override;
76  void updateCosts(
77  nav2_costmap_2d::Costmap2D & master_grid,
78  int min_i,
79  int min_j,
80  int max_i,
81  int max_j) override;
82  void onFootprintChanged() override;
84  void matchSize() override;
88  void deactivate() override;
92  void activate() override;
96  void reset() override;
100  bool isClearable() override;
105  void clearArea(int start_x, int start_y, int end_x, int end_y, bool invert) override;
106 
107  void addPlugin(std::shared_ptr<Layer> plugin, std::string layer_name);
108  pluginlib::ClassLoader<Layer> plugin_loader_{"nav2_costmap_2d", "nav2_costmap_2d::Layer"};
117  rcl_interfaces::msg::SetParametersResult validateParameterUpdatesCallback(
118  const std::vector<rclcpp::Parameter> & parameters);
119 
126  void updateParametersCallback(const std::vector<rclcpp::Parameter> & parameters);
127 
128 private:
130  rclcpp::node_interfaces::PostSetParametersCallbackHandle::SharedPtr post_set_params_handler_;
131  rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr on_set_params_handler_;
132 
133  nav2_costmap_2d::CombinationMethod combination_method_;
134  std::vector<std::shared_ptr<Layer>> plugins_;
135  std::vector<std::string> plugin_names_;
136  std::vector<std::string> plugin_types_;
137 };
138 } // namespace nav2_costmap_2d
139 #endif // NAV2_COSTMAP_2D__PLUGIN_CONTAINER_LAYER_HPP_
A 2D costmap provides a mapping between points in the world and their associated "costs".
Definition: costmap_2d.hpp:69
A costmap layer base class for costmap plugin layers. Rather than just a layer, this object also cont...
Holds a list of plugins and applies them only to the specific layer.
bool isClearable() override
If clearing operations should be processed on this layer or not.
void onInitialize() override
Initialization process of layer on startup.
void onFootprintChanged() override
LayeredCostmap calls this whenever the footprint there changes (via LayeredCostmap::setFootprint())....
void reset() override
Reset this costmap.
void matchSize() override
Update the footprint to match size of the parent costmap.
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.
void deactivate() override
Deactivate the layer.
void clearArea(int start_x, int start_y, int end_x, int end_y, bool invert) override
Clear an area in the constituent costmaps with the given dimension if invert, then clear everything e...
rcl_interfaces::msg::SetParametersResult validateParameterUpdatesCallback(const std::vector< rclcpp::Parameter > &parameters)
Validate incoming parameter updates before applying them. This callback is triggered when one or more...
void updateCosts(nav2_costmap_2d::Costmap2D &master_grid, int min_i, int min_j, int max_i, int max_j) override
Update the costs in the master costmap in the window.
void updateParametersCallback(const std::vector< rclcpp::Parameter > &parameters)
Apply parameter updates after validation This callback is executed when parameters have been successf...
void activate() override
Activate the layer.