Nav2 Navigation Stack - jazzy  jazzy
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 <Eigen/Dense>
19 #include <cmath>
20 #include <memory>
21 #include <string>
22 #include <vector>
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 "tf2_ros/message_filter.h"
30 #include "message_filters/subscriber.h"
31 #include "pluginlib/class_loader.hpp"
32 
33 using nav2_costmap_2d::LETHAL_OBSTACLE;
34 using nav2_costmap_2d::INSCRIBED_INFLATED_OBSTACLE;
35 using nav2_costmap_2d::NO_INFORMATION;
36 using rcl_interfaces::msg::ParameterType;
37 namespace nav2_costmap_2d
38 {
44 {
45 public:
49  virtual void onInitialize();
61  virtual void updateBounds(
62  double robot_x,
63  double robot_y,
64  double robot_yaw,
65  double * min_x,
66  double * min_y,
67  double * max_x,
68  double * max_y);
77  virtual void updateCosts(
78  nav2_costmap_2d::Costmap2D & master_grid,
79  int min_i,
80  int min_j,
81  int max_i,
82  int max_j);
83  virtual void onFootprintChanged();
85  virtual void matchSize();
89  virtual void deactivate();
93  virtual void activate();
97  virtual void reset();
101  virtual bool isClearable();
106  void clearArea(int start_x, int start_y, int end_x, int end_y, bool invert) override;
107 
108  void addPlugin(std::shared_ptr<Layer> plugin, std::string layer_name);
109  pluginlib::ClassLoader<Layer> plugin_loader_{"nav2_costmap_2d", "nav2_costmap_2d::Layer"};
114  rcl_interfaces::msg::SetParametersResult dynamicParametersCallback(
115  std::vector<rclcpp::Parameter> parameters);
116 
117 private:
119  rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr
120  dyn_params_handler_;
121 
122  nav2_costmap_2d::CombinationMethod combination_method_;
123  std::vector<std::shared_ptr<Layer>> plugins_;
124  std::vector<std::string> plugin_names_;
125  std::vector<std::string> plugin_types_;
126 };
127 } // namespace nav2_costmap_2d
128 #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:68
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.
rcl_interfaces::msg::SetParametersResult dynamicParametersCallback(std::vector< rclcpp::Parameter > parameters)
Callback executed when a parameter change is detected.
virtual void onInitialize()
Initialization process of layer on startup.
virtual void matchSize()
Update the footprint to match size of the parent costmap.
virtual void onFootprintChanged()
LayeredCostmap calls this whenever the footprint there changes (via LayeredCostmap::setFootprint())....
virtual void updateBounds(double robot_x, double robot_y, double robot_yaw, double *min_x, double *min_y, double *max_x, double *max_y)
Update the bounds of the master costmap by this layer's update dimensions.
virtual void deactivate()
Deactivate the layer.
virtual void activate()
Activate 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...
virtual void reset()
Reset this costmap.
virtual bool isClearable()
If clearing operations should be processed on this layer or not.
virtual void updateCosts(nav2_costmap_2d::Costmap2D &master_grid, int min_i, int min_j, int max_i, int max_j)
Update the costs in the master costmap in the window.