height_map_examples.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 Copyright (c) 2018, Alexander W. Winkler. All rights reserved.
00003 
00004 Redistribution and use in source and binary forms, with or without
00005 modification, are permitted provided that the following conditions are met:
00006 
00007 * Redistributions of source code must retain the above copyright notice, this
00008   list of conditions and the following disclaimer.
00009 
00010 * Redistributions in binary form must reproduce the above copyright notice,
00011   this list of conditions and the following disclaimer in the documentation
00012   and/or other materials provided with the distribution.
00013 
00014 * Neither the name of the copyright holder nor the names of its
00015   contributors may be used to endorse or promote products derived from
00016   this software without specific prior written permission.
00017 
00018 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00019 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00021 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00022 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00023 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00024 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00025 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00026 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00027 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00028 ******************************************************************************/
00029 
00030 #ifndef TOWR_TOWR_ROS_INCLUDE_TOWR_ROS_HEIGHT_MAP_EXAMPLES_H_
00031 #define TOWR_TOWR_ROS_INCLUDE_TOWR_ROS_HEIGHT_MAP_EXAMPLES_H_
00032 
00033 #include <towr/terrain/height_map.h>
00034 
00035 namespace towr {
00036 
00045 class FlatGround : public HeightMap {
00046 public:
00047   FlatGround(double height = 0.0);
00048   double GetHeight(double x, double y)  const override { return height_; };
00049 
00050 private:
00051   double height_; // [m]
00052 };
00053 
00057 class Block : public HeightMap {
00058 public:
00059   double GetHeight(double x, double y)  const override;
00060   double GetHeightDerivWrtX(double x, double y) const override;
00061 
00062 private:
00063   double block_start = 0.7;
00064   double length_     = 3.5;
00065   double height_     = 0.5; // [m]
00066 
00067   double eps_ = 0.03; // approximate as slope
00068   const double slope_ = height_/eps_;
00069 };
00070 
00074 class Stairs : public HeightMap {
00075 public:
00076   double GetHeight(double x, double y) const override;
00077 
00078 private:
00079   double first_step_start_  = 1.0;
00080   double first_step_width_  = 0.4;
00081   double height_first_step  = 0.2;
00082   double height_second_step = 0.4;
00083   double width_top = 1.0;
00084 };
00085 
00089 class Gap : public HeightMap {
00090 public:
00091   double GetHeight(double x, double y) const override;
00092   double GetHeightDerivWrtX(double x, double y) const override;
00093   double GetHeightDerivWrtXX(double x, double y) const override;
00094 
00095 private:
00096   const double gap_start_ = 1.0;
00097   const double w = 0.5;
00098   const double h = 1.5;
00099 
00100   const double slope_ = h/w;
00101   const double dx = w/2.0;
00102   const double xc = gap_start_ + dx; // gap center
00103   const double gap_end_x = gap_start_ + w;
00104 
00105   // generated with matlab
00106   // see matlab/gap_height_map.m
00107   // coefficients of 2nd order polynomial
00108   // h = a*x^2 + b*x + c
00109   const double a = (4*h)/(w*w);
00110   const double b = -(8*h*xc)/(w*w);
00111   const double c = -(h*(w - 2*xc)*(w + 2*xc))/(w*w);
00112 };
00113 
00117 class Slope : public HeightMap {
00118 public:
00119   double GetHeight(double x, double y) const override;
00120   double GetHeightDerivWrtX(double x, double y) const override;
00121 
00122 private:
00123   const double slope_start_ = 1.0;
00124   const double up_length_   = 1.0;
00125   const double down_length_ = 1.0;
00126   const double height_center = 0.7;
00127 
00128   const double x_down_start_ = slope_start_+up_length_;
00129   const double x_flat_start_ = x_down_start_ + down_length_;
00130   const double slope_ = height_center/up_length_;
00131 };
00132 
00136 class Chimney : public HeightMap {
00137 public:
00138   double GetHeight(double x, double y) const override;
00139   double GetHeightDerivWrtY(double x, double y) const override;
00140 
00141 private:
00142   const double x_start_ = 1.0;
00143   const double length_  = 1.5;
00144   const double y_start_ = 0.5; // distance to start of slope from center at z=0
00145   const double slope_   = 3.0;
00146 
00147   const double x_end_ = x_start_+length_;
00148 };
00149 
00153 class ChimneyLR : public HeightMap {
00154 public:
00155   double GetHeight(double x, double y) const override;
00156   double GetHeightDerivWrtY(double x, double y) const override;
00157 
00158 private:
00159   const double x_start_ = 0.5;
00160   const double length_  = 1.0;
00161   const double y_start_ = 0.5; // distance to start of slope from center at z=0
00162   const double slope_   = 2;
00163 
00164   const double x_end1_ = x_start_+length_;
00165   const double x_end2_ = x_start_+2*length_;
00166 };
00167 
00170 } /* namespace towr */
00171 
00172 #endif /* TOWR_TOWR_ROS_INCLUDE_TOWR_ROS_HEIGHT_MAP_EXAMPLES_H_ */


towr
Author(s): Alexander W. Winkler
autogenerated on Mon Apr 15 2019 02:42:32