costmap_3d.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2018, the neonavigation authors
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the copyright holder nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef COSTMAP_CSPACE_COSTMAP_3D_H
31 #define COSTMAP_CSPACE_COSTMAP_3D_H
32 
33 #include <memory>
34 #include <vector>
35 
36 #include <ros/ros.h>
37 
43 
45 
46 namespace costmap_cspace
47 {
48 class Costmap3d
49 {
50 protected:
51  std::vector<Costmap3dLayerBase::Ptr> costmaps_;
53 
54 public:
55  using Ptr = std::shared_ptr<Costmap3d>;
56 
57  explicit Costmap3d(const int ang_resolution)
58  {
59  ang_resolution_ = ang_resolution;
60 
61  ROS_ASSERT(ang_resolution_ > 0);
62  }
63  template <typename T>
64  typename T::Ptr addRootLayer()
65  {
66  typename T::Ptr
67  costmap_base(new T);
68 
69  costmap_base->setAngleResolution(ang_resolution_);
70 
71  costmap_base->setOverlayMode(MapOverlayMode::MAX);
72 
73  costmaps_.resize(1);
74  costmaps_[0] = costmap_base;
75 
76  return costmap_base;
77  }
78  template <typename T>
79  typename T::Ptr addLayer(
80  const MapOverlayMode overlay_mode = MapOverlayMode::MAX)
81  {
82  typename T::Ptr costmap_overlay(new T);
83  costmap_overlay->setAngleResolution(ang_resolution_);
84  costmap_overlay->setOverlayMode(overlay_mode);
85 
86  costmaps_.back()->setChild(costmap_overlay);
87  costmaps_.push_back(costmap_overlay);
88 
89  return costmap_overlay;
90  }
92  Costmap3dLayerBase::Ptr costmap_overlay,
93  const MapOverlayMode overlay_mode = MapOverlayMode::MAX)
94  {
95  costmap_overlay->setAngleResolution(ang_resolution_);
96  costmap_overlay->setOverlayMode(overlay_mode);
97 
98  costmaps_.back()->setChild(costmap_overlay);
99  costmaps_.push_back(costmap_overlay);
100 
101  return costmap_overlay;
102  }
104  {
105  return costmaps_.front();
106  }
107 };
108 } // namespace costmap_cspace
109 
110 #endif // COSTMAP_CSPACE_COSTMAP_3D_H
std::vector< Costmap3dLayerBase::Ptr > costmaps_
Definition: costmap_3d.h:51
T::Ptr addLayer(const MapOverlayMode overlay_mode=MapOverlayMode::MAX)
Definition: costmap_3d.h:79
MapOverlayMode
Definition: base.h:96
Costmap3dLayerBase::Ptr addLayer(Costmap3dLayerBase::Ptr costmap_overlay, const MapOverlayMode overlay_mode=MapOverlayMode::MAX)
Definition: costmap_3d.h:91
Costmap3dLayerBase::Ptr getRootLayer()
Definition: costmap_3d.h:103
Costmap3d(const int ang_resolution)
Definition: costmap_3d.h:57
std::shared_ptr< Costmap3dLayerBase > Ptr
Definition: base.h:255
#define ROS_ASSERT(cond)
std::shared_ptr< Costmap3d > Ptr
Definition: costmap_3d.h:55


costmap_cspace
Author(s): Atsushi Watanabe
autogenerated on Wed May 12 2021 02:20:29