rotation_cache.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2019, 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_ROTATION_CACHE_H
31 #define PLANNER_CSPACE_PLANNER_3D_ROTATION_CACHE_H
32 
33 #include <cmath>
34 #include <list>
35 #include <memory>
36 #include <utility>
37 #include <vector>
38 
40 
41 namespace planner_cspace
42 {
43 namespace planner_3d
44 {
46 {
47 private:
48  class Page
49  {
50  private:
51  std::unique_ptr<CyclicVecFloat<3, 2>[]> c_;
52  std::unique_ptr<std::pair<float, float>[]> r_;
54  int ser_size_;
55 
56  inline size_t addr(const CyclicVecInt<3, 2>& pos) const
57  {
58  size_t addr = pos[2];
59  for (int i = 1; i >= 0; i--)
60  addr = addr * size_[i] + pos[i];
61  return addr;
62  }
63 
64  public:
65  void reset(const CyclicVecInt<3, 2>& size);
67  {
68  return c_[addr(pos)];
69  }
70  inline const CyclicVecFloat<3, 2>& motion(const CyclicVecInt<3, 2>& pos) const
71  {
72  return c_[addr(pos)];
73  }
74  inline std::pair<float, float>& radiuses(const CyclicVecInt<3, 2>& pos)
75  {
76  return r_[addr(pos)];
77  }
78  inline const std::pair<float, float>& radiuses(const CyclicVecInt<3, 2>& pos) const
79  {
80  return r_[addr(pos)];
81  }
82  };
83 
84  std::vector<Page> pages_;
85 
86 public:
87  void reset(const float linear_resolution, const float angular_resolution, const int range);
89  const int start_angle,
90  const CyclicVecInt<3, 2>& end) const
91  {
92  return pages_[start_angle].motion(end);
93  }
94  inline const std::pair<float, float>& getRadiuses(
95  const int start_angle,
96  const CyclicVecInt<3, 2>& end) const
97  {
98  return pages_[start_angle].radiuses(end);
99  }
100 
101  std::list<CyclicVecFloat<3, 2>> interpolate(
102  const std::list<CyclicVecInt<3, 2>>& path_grid,
103  const float interval,
104  const int local_range) const;
105 };
106 } // namespace planner_3d
107 } // namespace planner_cspace
108 
109 #endif // PLANNER_CSPACE_PLANNER_3D_ROTATION_CACHE_H
std::unique_ptr< CyclicVecFloat< 3, 2 >[]> c_
const std::pair< float, float > & radiuses(const CyclicVecInt< 3, 2 > &pos) const
const CyclicVecFloat< 3, 2 > & motion(const CyclicVecInt< 3, 2 > &pos) const
std::unique_ptr< std::pair< float, float >[]> r_
const CyclicVecFloat< 3, 2 > & getMotion(const int start_angle, const CyclicVecInt< 3, 2 > &end) const
size_t addr(const CyclicVecInt< 3, 2 > &pos) const
void reset(const CyclicVecInt< 3, 2 > &size)
CyclicVecFloat< 3, 2 > & motion(const CyclicVecInt< 3, 2 > &pos)
std::pair< float, float > & radiuses(const CyclicVecInt< 3, 2 > &pos)
const std::pair< float, float > & getRadiuses(const int start_angle, const CyclicVecInt< 3, 2 > &end) const
std::list< CyclicVecFloat< 3, 2 > > interpolate(const std::list< CyclicVecInt< 3, 2 >> &path_grid, const float interval, const int local_range) const


planner_cspace
Author(s): Atsushi Watanabe
autogenerated on Wed May 12 2021 02:20:42