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 <ros/ros.h>
34 
40 
42 
43 #include <vector>
44 
45 namespace costmap_cspace
46 {
47 class Costmap3d
48 {
49 protected:
50  std::vector<Costmap3dLayerBase::Ptr> costmaps_;
52 
53 public:
54  using Ptr = std::shared_ptr<Costmap3d>;
55 
56  explicit Costmap3d(const int ang_resolution)
57  {
58  ang_resolution_ = ang_resolution;
59 
60  ROS_ASSERT(ang_resolution_ > 0);
61  }
62  template <typename T>
63  typename T::Ptr addRootLayer()
64  {
65  typename T::Ptr
66  costmap_base(new T);
67 
68  costmap_base->setAngleResolution(ang_resolution_);
69 
70  costmap_base->setOverlayMode(MapOverlayMode::MAX);
71 
72  costmaps_.resize(1);
73  costmaps_[0] = costmap_base;
74 
75  return costmap_base;
76  }
77  template <typename T>
78  typename T::Ptr addLayer(
79  const MapOverlayMode overlay_mode = MapOverlayMode::MAX)
80  {
81  typename T::Ptr costmap_overlay(new T);
82  costmap_overlay->setAngleResolution(ang_resolution_);
83  costmap_overlay->setOverlayMode(overlay_mode);
84 
85  costmaps_.back()->setChild(costmap_overlay);
86  costmaps_.push_back(costmap_overlay);
87 
88  return costmap_overlay;
89  }
91  Costmap3dLayerBase::Ptr costmap_overlay,
92  const MapOverlayMode overlay_mode = MapOverlayMode::MAX)
93  {
94  costmap_overlay->setAngleResolution(ang_resolution_);
95  costmap_overlay->setOverlayMode(overlay_mode);
96 
97  costmaps_.back()->setChild(costmap_overlay);
98  costmaps_.push_back(costmap_overlay);
99 
100  return costmap_overlay;
101  }
103  {
104  return costmaps_.front();
105  }
106 };
107 } // namespace costmap_cspace
108 
109 #endif // COSTMAP_CSPACE_COSTMAP_3D_H
std::vector< Costmap3dLayerBase::Ptr > costmaps_
Definition: costmap_3d.h:50
T::Ptr addLayer(const MapOverlayMode overlay_mode=MapOverlayMode::MAX)
Definition: costmap_3d.h:78
MapOverlayMode
Definition: base.h:80
Costmap3dLayerBase::Ptr addLayer(Costmap3dLayerBase::Ptr costmap_overlay, const MapOverlayMode overlay_mode=MapOverlayMode::MAX)
Definition: costmap_3d.h:90
Costmap3dLayerBase::Ptr getRootLayer()
Definition: costmap_3d.h:102
Costmap3d(const int ang_resolution)
Definition: costmap_3d.h:56
std::shared_ptr< Costmap3dLayerBase > Ptr
Definition: base.h:210
#define ROS_ASSERT(cond)
std::shared_ptr< Costmap3d > Ptr
Definition: costmap_3d.h:54


costmap_cspace
Author(s): Atsushi Watanabe
autogenerated on Tue Jul 9 2019 04:59:48