layer.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * Software License Agreement (BSD License)
4  *
5  * Copyright (c) 2008, 2013, Willow Garage, Inc.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of Willow Garage, Inc. nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *
35  * Author: David V. Lu!!
36  *********************************************************************/
37 #ifndef COSTMAP_2D_LAYER_H_
38 #define COSTMAP_2D_LAYER_H_
39 
40 #include <costmap_2d/costmap_2d.h>
42 #include <string>
43 #include <tf2_ros/buffer.h>
44 
45 namespace costmap_2d
46 {
47 class LayeredCostmap;
48 
49 class Layer
50 {
51 public:
52  Layer();
53 
54  void initialize(LayeredCostmap* parent, std::string name, tf2_ros::Buffer *tf);
55 
64  virtual void updateBounds(double robot_x, double robot_y, double robot_yaw, double* min_x, double* min_y,
65  double* max_x, double* max_y) {}
66 
71  virtual void updateCosts(Costmap2D& master_grid, int min_i, int min_j, int max_i, int max_j) {}
72 
74  virtual void deactivate() {}
75 
77  virtual void activate() {}
78 
79  virtual void reset() {}
80 
81  virtual ~Layer() {}
82 
93  bool isCurrent() const
94  {
95  return current_;
96  }
97 
111  inline bool isEnabled() const noexcept
112  {
113  return enabled_;
114  }
115 
117  virtual void matchSize() {}
118 
119  inline const std::string& getName() const noexcept
120  {
121  return name_;
122  }
123 
125  const std::vector<geometry_msgs::Point>& getFootprint() const;
126 
130  virtual void onFootprintChanged() {}
131 
132 protected:
137  virtual void onInitialize() {}
138 
139  LayeredCostmap* layered_costmap_;
140  bool current_;
141  bool enabled_;
142  std::string name_;
144 
145 private:
146  std::vector<geometry_msgs::Point> footprint_spec_;
147 };
148 
149 } // namespace costmap_2d
150 
151 #endif // COSTMAP_2D_LAYER_H_
costmap_2d::Layer::tf_
tf2_ros::Buffer * tf_
Definition: layer.h:178
costmap_2d::Layer::matchSize
virtual void matchSize()
Implement this to make this layer match the size of the parent costmap.
Definition: layer.h:152
costmap_2d::Layer::enabled_
bool enabled_
Definition: layer.h:176
costmap_2d::Layer::onFootprintChanged
virtual void onFootprintChanged()
LayeredCostmap calls this whenever the footprint there changes (via LayeredCostmap::setFootprint())....
Definition: layer.h:165
costmap_2d::Layer::Layer
Layer()
Definition: layer.cpp:35
costmap_2d::Layer::initialize
void initialize(LayeredCostmap *parent, std::string name, tf2_ros::Buffer *tf)
Definition: layer.cpp:43
layered_costmap.h
costmap_2d::Layer::activate
virtual void activate()
Restart publishers if they've been stopped.
Definition: layer.h:112
buffer.h
costmap_2d::Layer::updateCosts
virtual void updateCosts(Costmap2D &master_grid, int min_i, int min_j, int max_i, int max_j)
Actually update the underlying costmap, only within the bounds calculated during UpdateBounds().
Definition: layer.h:106
costmap_2d::Layer::name_
std::string name_
Definition: layer.h:177
costmap_2d::Layer::current_
bool current_
Definition: layer.h:175
costmap_2d::Layer::layered_costmap_
LayeredCostmap * layered_costmap_
Definition: layer.h:174
costmap_2d::Layer::getName
const std::string & getName() const noexcept
Definition: layer.h:154
costmap_2d::Layer::isCurrent
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,...
Definition: layer.h:128
costmap_2d.h
costmap_2d::Layer::~Layer
virtual ~Layer()
Definition: layer.h:116
costmap_2d::Layer::footprint_spec_
std::vector< geometry_msgs::Point > footprint_spec_
Definition: layer.h:181
tf2_ros::Buffer
costmap_2d::Layer::updateBounds
virtual void updateBounds(double robot_x, double robot_y, double robot_yaw, double *min_x, double *min_y, double *max_x, double *max_y)
This is called by the LayeredCostmap to poll this plugin as to how much of the costmap it needs to up...
Definition: layer.h:99
costmap_2d::Layer::getFootprint
const std::vector< geometry_msgs::Point > & getFootprint() const
Convenience function for layered_costmap_->getFootprint().
Definition: layer.cpp:51
costmap_2d::Layer::onInitialize
virtual void onInitialize()
This is called at the end of initialize(). Override to implement subclass-specific initialization.
Definition: layer.h:172
costmap_2d::Layer::deactivate
virtual void deactivate()
Stop publishers.
Definition: layer.h:109
tf
costmap_2d::Layer::isEnabled
bool isEnabled() const noexcept
getter if the current layer is enabled.
Definition: layer.h:146
costmap_2d
Definition: array_parser.h:37
costmap_2d::Layer::reset
virtual void reset()
Definition: layer.h:114


costmap_2d
Author(s): Eitan Marder-Eppstein, David V. Lu!!, Dave Hershberger, contradict@gmail.com
autogenerated on Mon Mar 6 2023 03:50:17