height_map_examples.h
Go to the documentation of this file.
1 /******************************************************************************
2 Copyright (c) 2018, Alexander W. Winkler. All rights reserved.
3 
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
6 
7 * Redistributions of source code must retain the above copyright notice, this
8  list of conditions and the following disclaimer.
9 
10 * Redistributions in binary form must reproduce the above copyright notice,
11  this list of conditions and the following disclaimer in the documentation
12  and/or other materials provided with the distribution.
13 
14 * Neither the name of the copyright holder nor the names of its
15  contributors may be used to endorse or promote products derived from
16  this software without specific prior written permission.
17 
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 ******************************************************************************/
29 
30 #ifndef TOWR_TOWR_ROS_INCLUDE_TOWR_ROS_HEIGHT_MAP_EXAMPLES_H_
31 #define TOWR_TOWR_ROS_INCLUDE_TOWR_ROS_HEIGHT_MAP_EXAMPLES_H_
32 
34 
35 namespace towr {
36 
45 class FlatGround : public HeightMap {
46 public:
47  FlatGround(double height = 0.0);
48  double GetHeight(double x, double y) const override { return height_; };
49 
50 private:
51  double height_; // [m]
52 };
53 
57 class Block : public HeightMap {
58 public:
59  double GetHeight(double x, double y) const override;
60  double GetHeightDerivWrtX(double x, double y) const override;
61 
62 private:
63  double block_start = 0.7;
64  double length_ = 3.5;
65  double height_ = 0.5; // [m]
66 
67  double eps_ = 0.03; // approximate as slope
68  const double slope_ = height_/eps_;
69 };
70 
74 class Stairs : public HeightMap {
75 public:
76  double GetHeight(double x, double y) const override;
77 
78 private:
79  double first_step_start_ = 1.0;
80  double first_step_width_ = 0.4;
81  double height_first_step = 0.2;
82  double height_second_step = 0.4;
83  double width_top = 1.0;
84 };
85 
89 class Gap : public HeightMap {
90 public:
91  double GetHeight(double x, double y) const override;
92  double GetHeightDerivWrtX(double x, double y) const override;
93  double GetHeightDerivWrtXX(double x, double y) const override;
94 
95 private:
96  const double gap_start_ = 1.0;
97  const double w = 0.5;
98  const double h = 1.5;
99 
100  const double slope_ = h/w;
101  const double dx = w/2.0;
102  const double xc = gap_start_ + dx; // gap center
103  const double gap_end_x = gap_start_ + w;
104 
105  // generated with matlab
106  // see matlab/gap_height_map.m
107  // coefficients of 2nd order polynomial
108  // h = a*x^2 + b*x + c
109  const double a = (4*h)/(w*w);
110  const double b = -(8*h*xc)/(w*w);
111  const double c = -(h*(w - 2*xc)*(w + 2*xc))/(w*w);
112 };
113 
117 class Slope : public HeightMap {
118 public:
119  double GetHeight(double x, double y) const override;
120  double GetHeightDerivWrtX(double x, double y) const override;
121 
122 private:
123  const double slope_start_ = 1.0;
124  const double up_length_ = 1.0;
125  const double down_length_ = 1.0;
126  const double height_center = 0.7;
127 
128  const double x_down_start_ = slope_start_+up_length_;
129  const double x_flat_start_ = x_down_start_ + down_length_;
130  const double slope_ = height_center/up_length_;
131 };
132 
136 class Chimney : public HeightMap {
137 public:
138  double GetHeight(double x, double y) const override;
139  double GetHeightDerivWrtY(double x, double y) const override;
140 
141 private:
142  const double x_start_ = 1.0;
143  const double length_ = 1.5;
144  const double y_start_ = 0.5; // distance to start of slope from center at z=0
145  const double slope_ = 3.0;
146 
147  const double x_end_ = x_start_+length_;
148 };
149 
153 class ChimneyLR : public HeightMap {
154 public:
155  double GetHeight(double x, double y) const override;
156  double GetHeightDerivWrtY(double x, double y) const override;
157 
158 private:
159  const double x_start_ = 0.5;
160  const double length_ = 1.0;
161  const double y_start_ = 0.5; // distance to start of slope from center at z=0
162  const double slope_ = 2;
163 
164  const double x_end1_ = x_start_+length_;
165  const double x_end2_ = x_start_+2*length_;
166 };
167 
170 } /* namespace towr */
171 
172 #endif /* TOWR_TOWR_ROS_INCLUDE_TOWR_ROS_HEIGHT_MAP_EXAMPLES_H_ */
Holds the height and slope information of the terrain.
Definition: height_map.h:71
FlatGround(double height=0.0)
Sample terrain of even height.
Sample terrain with an increasing and then decreasing slope in x-direction.
Sample terrain with a tilted vertical wall to cross a gap.
virtual double GetHeightDerivWrtY(double x, double y) const
Definition: height_map.h:164
Sample terrain with two tilted vertical walls to cross a gap.
double GetHeight(double x, double y) const override
virtual double GetHeightDerivWrtXX(double x, double y) const
Definition: height_map.h:167
virtual double GetHeightDerivWrtX(double x, double y) const
Definition: height_map.h:163
Sample terrain with a two-steps in height in x-direction.
Sample terrain with a step in height in x-direction.
Sample terrain with parabola-modeled gap in x-direction.


towr
Author(s): Alexander W. Winkler
autogenerated on Mon Feb 28 2022 23:54:22