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 
42 {
43 private:
44  class Page
45  {
46  private:
47  std::unique_ptr<CyclicVecFloat<3, 2>[]> c_;
48  std::unique_ptr<std::pair<float, float>[]> r_;
50  int ser_size_;
51 
52  inline size_t addr(const CyclicVecInt<3, 2>& pos) const
53  {
54  size_t addr = pos[2];
55  for (int i = 1; i >= 0; i--)
56  addr = addr * size_[i] + pos[i];
57  return addr;
58  }
59 
60  public:
61  void reset(const CyclicVecInt<3, 2>& size);
63  {
64  return c_[addr(pos)];
65  }
66  inline const CyclicVecFloat<3, 2>& motion(const CyclicVecInt<3, 2>& pos) const
67  {
68  return c_[addr(pos)];
69  }
70  inline std::pair<float, float>& radiuses(const CyclicVecInt<3, 2>& pos)
71  {
72  return r_[addr(pos)];
73  }
74  inline const std::pair<float, float>& radiuses(const CyclicVecInt<3, 2>& pos) const
75  {
76  return r_[addr(pos)];
77  }
78  };
79 
80  std::vector<Page> pages_;
81 
82 public:
83  void reset(const float linear_resolution, const float angular_resolution, const int range);
85  const int start_angle,
86  const CyclicVecInt<3, 2>& end) const
87  {
88  return pages_[start_angle].motion(end);
89  }
90  inline const std::pair<float, float>& getRadiuses(
91  const int start_angle,
92  const CyclicVecInt<3, 2>& end) const
93  {
94  return pages_[start_angle].radiuses(end);
95  }
96 
97  std::list<CyclicVecFloat<3, 2>> interpolate(
98  const std::list<CyclicVecInt<3, 2>>& path_grid,
99  const float interval,
100  const int local_range) const;
101 };
102 
103 #endif // PLANNER_CSPACE_PLANNER_3D_ROTATION_CACHE_H
size_t addr(const CyclicVecInt< 3, 2 > &pos) const
std::vector< Page > pages_
CyclicVecFloat< 3, 2 > & motion(const CyclicVecInt< 3, 2 > &pos)
const CyclicVecFloat< 3, 2 > & motion(const CyclicVecInt< 3, 2 > &pos) const
const std::pair< float, float > & getRadiuses(const int start_angle, const CyclicVecInt< 3, 2 > &end) const
const CyclicVecFloat< 3, 2 > & getMotion(const int start_angle, const CyclicVecInt< 3, 2 > &end) const
CyclicVecInt< 3, 2 > size_
const std::pair< float, float > & radiuses(const CyclicVecInt< 3, 2 > &pos) const
std::unique_ptr< CyclicVecFloat< 3, 2 >[]> c_
std::unique_ptr< std::pair< float, float >[]> r_
void reset(const CyclicVecInt< 3, 2 > &size)
std::pair< float, float > & radiuses(const CyclicVecInt< 3, 2 > &pos)
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 Tue Jul 9 2019 05:00:13