Terrain¶
Terrain objects are used to describe the terrain over to optimize a gait.
HeightMap¶
-
namespace
gambol Variables
-
static const std::map<HeightMap::TerrainID, std::string>
terrain_names= {{HeightMap::FlatID, "Flat"}, {HeightMap::BlockID, "Block"}, {HeightMap::StairsID, "Stairs"}, {HeightMap::GapID, "Gap"}, {HeightMap::SlopeID, "Slope"}, {HeightMap::ChimneyID, "Chimney"}, {HeightMap::ChimneyLRID, "ChimenyLR"},}¶
-
class
HeightMap¶ - #include <HeightMap.h>
Holds the height and slope information of the terrain.
This class and the examples were taken from TOWR!
This class is responsible for providing the height values and slope at each position (x,y). Examples of various height map examples can be found in height_map_examples.h.
If a height map of the terrain already exists, e.g. Octomap/Gridmap, then a simple adapter for these can be written to comply to this minimal interface and to be used with towr.
The height map is used to formulate constraints such as “foot must be touching terrain during stance phase”.
Subclassed by gambol::Block, gambol::Chimney, gambol::ChimneyLR, gambol::FlatGround, gambol::Gap, gambol::Hill, gambol::Slope, gambol::SlopeConstant, gambol::Stairs
Public Types
-
enum
TerrainID¶ Terrains IDs corresponding for factory method.
Values:
-
enumerator
FlatID¶
-
enumerator
BlockID¶
-
enumerator
StairsID¶
-
enumerator
GapID¶
-
enumerator
SlopeID¶
-
enumerator
ChimneyID¶
-
enumerator
ChimneyLRID¶
-
enumerator
HillID¶
-
enumerator
SlopeConstantID¶
-
enumerator
TERRAIN_COUNT¶
-
enumerator
-
using
Vector3d= Eigen::Vector3d¶
-
using
MatrixXd= Eigen::MatrixXd¶
-
using
Jacobian= Eigen::SparseMatrix<double, Eigen::RowMajor>¶
Public Functions
-
HeightMap() = default¶
-
virtual
~HeightMap() = default¶
-
virtual double
GetHeight(double x, double y) const = 0¶ - Parameters
x – The x position.
y – The y position.
- Returns
The height of the terrain [m] at a specific 2D position.
-
double
GetDerivativeOfHeightWrt(Dim2D dim, double x, double y) const¶ How the height value changes at a 2D position in direction dim.
- Parameters
dim – The direction (x,y) w.r.t. which the height change is desired.
x – The x position on the terrain.
y – The y position on the terrain.
- Returns
The derivative of the height with respect to the dimension.
-
Vector3d
GetNormalizedBasis(Direction direction, double x, double y) const¶ Returns either the vector normal or tangent to the terrain patch.
- Parameters
direction – The terrain normal or tangent vectors.
x – The x position on the terrain.
y – The y position on the terrain.
- Returns
The normalized 3D vector in the specified direction.
-
Vector3d
GetDerivativeOfNormalizedBasisWrt(Direction direction, Dim2D dim, double x, double y) const¶ How the terrain normal/tangent vectors change when moving in x or y.
- Parameters
direction – The terrain normal or tangent vectors.
dim – The dimension w.r.t which the change is searched for.
x – The x position on the terrain.
y – The y position on the terrain.
- Returns
The normalized 3D derivative w.r.t dimension dim.
-
Vector3d
GetDerivativeOfNormalizedBasisWrt(Direction direction, Dim2D dim, const Vector3d &pos) const¶
-
Jacobian
GetDerivativeOfNormalizedBasis(Direction direction, const Vector3d &pos) const¶ How the terrain normal/tangent vectors change when moving.
This version returns an entire jacobian. The w.r.t.-z component is zero.
- Parameters
direction – The terrain normal or tangent vectors.
pos – The x, y and z position on the terrain.
- Returns
The normalized 3D derivative w.r.t dimension dim.
-
double
GetFrictionCoeff() const¶ - Returns
The constant friction coefficient over the whole terrain.
Public Static Functions
Protected Attributes
-
double
friction_coeff_= 0.5¶
Private Functions
-
Vector3d
GetBasis(Direction direction, double x, double y, const DimDerivs &dim_deriv = {}) const¶ returns either the terrain normal/tangent or its derivative.
- Parameters
direction – Terrain normal or tangent vector.
x – The x position on the terrain.
y – The y position on the terrain.
dim_deriv – If empty, the vector is returned, if e.g. X_ is set, the derivative of the vector w.r.t. x is returned.
- Returns
the 3D not-normalized vector.
-
Vector3d
GetDerivativeOfNormalizedVectorWrtNonNormalizedIndex(const Vector3d &non_normalized, int index) const¶
-
virtual double
GetHeightDerivWrtX(double x, double y) const¶
-
virtual double
GetHeightDerivWrtY(double x, double y) const¶
-
virtual double
GetHeightDerivWrtXX(double x, double y) const¶
-
virtual double
GetHeightDerivWrtXY(double x, double y) const¶
-
virtual double
GetHeightDerivWrtYX(double x, double y) const¶
-
virtual double
GetHeightDerivWrtYY(double x, double y) const¶
-
enum
-
static const std::map<HeightMap::TerrainID, std::string>
HeightMap Examples¶
-
namespace
gambol -
class
Block: public gambol::HeightMap¶ - #include <HeightMapExamples.h>
Sample terrain with a step in height in x-direction.
-
class
Chimney: public gambol::HeightMap¶ - #include <HeightMapExamples.h>
Sample terrain with a tilted vertical wall to cross a gap.
-
class
ChimneyLR: public gambol::HeightMap¶ - #include <HeightMapExamples.h>
Sample terrain with two tilted vertical walls to cross a gap.
-
class
FlatGround: public gambol::HeightMap¶ - #include <HeightMapExamples.h>
Sample terrain of even height.
Public Functions
-
FlatGround(double height = 0.0)¶
-
virtual double
GetHeight(double x, double y) const override¶ - Parameters
x – The x position.
y – The y position.
- Returns
The height of the terrain [m] at a specific 2D position.
Private Members
-
double
height_¶
-
-
class
Gap: public gambol::HeightMap¶ - #include <HeightMapExamples.h>
Sample terrain with parabola-modeled gap in x-direction.
Public Functions
-
virtual double
GetHeight(double x, double y) const override¶ - Parameters
x – The x position.
y – The y position.
- Returns
The height of the terrain [m] at a specific 2D position.
-
virtual double
GetHeightDerivWrtX(double x, double y) const override¶
-
virtual double
GetHeightDerivWrtXX(double x, double y) const override¶
Private Members
-
const double
gap_start_= 0.6¶
-
const double
w= 0.3¶
-
const double
h= 1.5¶
-
const double
xc= gap_start_ + dx¶
-
const double
gap_end_x= gap_start_ + w¶
-
virtual double
-
class
Hill: public gambol::HeightMap¶ - #include <HeightMapExamples.h>
Sample terrain which is a quadratic hill.
Public Functions
-
virtual double
GetHeight(double x, double y) const override¶ - Parameters
x – The x position.
y – The y position.
- Returns
The height of the terrain [m] at a specific 2D position.
-
virtual double
GetHeightDerivWrtX(double x, double y) const override¶
-
virtual double
GetHeightDerivWrtY(double x, double y) const override¶
-
virtual double
GetHeightDerivWrtXX(double x, double y) const override¶
-
virtual double
GetHeightDerivWrtYY(double x, double y) const override¶
-
virtual double
-
class
Slope: public gambol::HeightMap¶ - #include <HeightMapExamples.h>
Sample terrain with an increasing and then decreasing slope in x-direction.
Public Functions
-
virtual double
GetHeight(double x, double y) const override¶ - Parameters
x – The x position.
y – The y position.
- Returns
The height of the terrain [m] at a specific 2D position.
-
virtual double
GetHeightDerivWrtX(double x, double y) const override¶
Private Members
-
const double
slope_start_= 0.1¶
-
const double
up_length_= 3.0¶
-
const double
down_length_= 3.0¶
-
const double
height_center= 1.5¶
-
const double
x_down_start_= slope_start_ + up_length_¶
-
const double
x_flat_start_= x_down_start_ + down_length_¶
-
const double
slope_= height_center / up_length_¶
-
virtual double
-
class
SlopeConstant: public gambol::HeightMap¶ - #include <HeightMapExamples.h>
Sample terrain which is a constant slope.
Public Functions
-
virtual double
GetHeight(double x, double y) const override¶ - Parameters
x – The x position.
y – The y position.
- Returns
The height of the terrain [m] at a specific 2D position.
-
virtual double
GetHeightDerivWrtX(double x, double y) const override¶
-
virtual double
GetHeightDerivWrtY(double x, double y) const override¶
-
virtual double
-
class
Stairs: public gambol::HeightMap¶ - #include <HeightMapExamples.h>
Sample terrain with a two-steps in height in x-direction.
Public Functions
-
virtual double
GetHeight(double x, double y) const override¶ - Parameters
x – The x position.
y – The y position.
- Returns
The height of the terrain [m] at a specific 2D position.
-
virtual double
-
class