distance_map.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2021, 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 PLANNER_CSPACE_PLANNER_3D_DISTANCE_MAP_H
31 #define PLANNER_CSPACE_PLANNER_3D_DISTANCE_MAP_H
32 
33 #include <cmath>
34 #include <limits>
35 #include <unordered_map>
36 #include <utility>
37 #include <vector>
38 
42 
43 namespace planner_cspace
44 {
45 namespace planner_3d
46 {
48 {
49 public:
51 
52  struct Rect
53  {
56  Rect(const Astar::Vec& min, const Astar::Vec& max)
57  : min(min)
58  , max(max) // NOLINT(build/include_what_you_use)
59  {
60  }
61  };
62 
63  struct DebugData
64  {
68  };
69 
70  struct Params
71  {
73  int range;
77  float resolution;
78  };
79 
80  struct SearchDiffs
81  {
83  std::vector<Astar::Vec> pos;
84  float grid_to_len;
85  float euclid_cost;
86  };
87 
89  const BlockMemGridmapBase<char, 3, 2>& cm_rough,
90  const CostmapBBF& bbf_costmap);
91 
92  void setParams(const CostCoeff& cc, const int num_cost_estim_task);
93 
94  void init(const GridAstarModel3D::Ptr model, const Params& p);
95 
96  void update(
97  const Astar::Vec& s, const Astar::Vec& e,
98  const Rect& rect);
99 
100  void create(const Astar::Vec& s, const Astar::Vec& e);
101 
102  inline const Astar::Vec& size() const
103  {
104  return g_.size();
105  }
106  inline float& operator[](const Astar::Vec& pos)
107  {
108  return g_.operator[](pos);
109  }
110  inline const float operator[](const Astar::Vec& pos) const
111  {
112  return g_.operator[](pos);
113  }
114  inline const Astar::Gridmap<float>& gridmap() const
115  {
116  return g_;
117  }
118  inline const DebugData& getDebugData() const
119  {
120  return debug_data_;
121  }
122 
123 protected:
124  Astar::Gridmap<float> g_;
130 
131  std::vector<SearchDiffs> search_diffs_;
133 
135  std::unordered_map<Astar::Vec, bool, Astar::Vec> edges_;
137 
138  void fillCostmap(
140  const Astar::Vec& s_rough);
141 };
142 } // namespace planner_3d
143 } // namespace planner_cspace
144 
145 #endif // PLANNER_CSPACE_PLANNER_3D_DISTANCE_MAP_H
void init(const GridAstarModel3D::Ptr model, const Params &p)
CyclicVecInt< DIM, NONCYCLIC > Vec
Definition: grid_astar.h:67
DistanceMap(const BlockMemGridmapBase< char, 3, 2 > &cm_rough, const CostmapBBF &bbf_costmap)
Rect(const Astar::Vec &min, const Astar::Vec &max)
Definition: distance_map.h:56
float & operator[](const Astar::Vec &pos)
Definition: distance_map.h:106
const float operator[](const Astar::Vec &pos) const
Definition: distance_map.h:110
const BlockMemGridmapBase< char, 3, 2 > & cm_rough_
Definition: distance_map.h:128
reservable_priority_queue< Astar::PriorityVec > pq_erase_
Definition: distance_map.h:136
const Astar::Vec & size() const
Definition: distance_map.h:102
const Astar::Gridmap< float > & gridmap() const
Definition: distance_map.h:114
void setParams(const CostCoeff &cc, const int num_cost_estim_task)
reservable_priority_queue< Astar::PriorityVec > pq_open_
Definition: distance_map.h:134
std::vector< SearchDiffs > search_diffs_
Definition: distance_map.h:131
void fillCostmap(reservable_priority_queue< Astar::PriorityVec > &open, const Astar::Vec &s_rough)
void create(const Astar::Vec &s, const Astar::Vec &e)
const DebugData & getDebugData() const
Definition: distance_map.h:118
std::unordered_map< Astar::Vec, bool, Astar::Vec > edges_
Definition: distance_map.h:135
void update(const Astar::Vec &s, const Astar::Vec &e, const Rect &rect)


planner_cspace
Author(s): Atsushi Watanabe
autogenerated on Mon Jul 3 2023 02:39:06