types: Doxygen documentation

namespace soil_simulator
struct body_soil
#include <types.hpp>

Store information related to the position of the body soil.

Public Members

int ind

Index of the body soil layer.

int ii

Index of the body soil position in the X direction.

int jj

Index of the body soil position in the Y direction.

float x_b

Cartesian coordinate in the X direction of the body soil in the reference body frame. [m]

float y_b

Cartesian coordinate in the Y direction of the body soil in the reference body frame. [m]

float z_b

Cartesian coordinate in the Z direction of the body soil in the reference body frame. [m]

float h_soil

Vertical extent of the soil column. [m].

class Grid
#include <types.hpp>

Store all parameters related to the simulation grid.

Convention:

  • The simulation grid is centred at 0, that is, if the extent of the grid is 10.0, the grid would then extend from -5.0 to 5.0, this applies to all direction.

  • The grid is composed of regular 3D cells

             H-----------G
            /           /|
           /     O     / |
          /           /  |
         E-----------F   C
         |           |  /
         |           | /
         |           |/
         A-----------B
    

  • The cells have the same size in both lateral direction

AB = BC = CD = DA = EF = FG = GH = HE,

while their height can potentially be lower

AE = BF = CG = DH <= AB.

  • The centre of each cell (O) is considered to be at the centre of the top surface.

  • The considered reference frame follows the right-hand rule, with the Z direction pointing upward.

Usage:

soil_simulator::Grid grid(4.0, 4.0, 3.0, 0.05, 0.01);

This would create a grid of size [-4, 4] in the X direction, [-4, 4] in the Y direction, [-3, 3] in the Z direction, and with cells of size 0.05 x 0.05 x 0.01 in the XYZ direction.

Public Functions

Grid(float grid_size_x = 4.0, float grid_size_y = 4.0, float grid_size_z = 4.0, float cell_size_xy = 0.05, float cell_size_z = 0.01)

Create a new instance of Grid using the grid size in [m].

The actual size of the grid would be:

  • [-grid_size_x, grid_size_x] in the X direction.

  • [-grid_size_y, grid_size_y] in the Y direction.

  • [-grid_size_z, grid_size_z] in the Z direction.

Requirements:

  • All inputs should be greater than zero.

  • cell_size_xy should be lower than or equal to grid_size_x and grid_size_y.

  • cell_size_z should be lower than or equal to grid_size_z.

Parameters:
  • grid_size_x – Half size of the grid in the X direction. [m]

  • grid_size_y – Half size of the grid in the Y direction. [m]

  • grid_size_z – Half size of the grid in the Z direction. [m]

  • cell_size_xy – Size of the cells in the X and Y direction. [m]

  • cell_size_z – Height of the cells in the Z direction. [m]

inline ~Grid()

Destructor.

Public Members

int half_length_x_

Number of grid elements in the positive (or negative) X direction.

int half_length_y_

Number of grid elements in the positive (or negative) Y direction.

int half_length_z_

Number of grid elements in the positive (or negative) Z direction.

float cell_size_xy_

Size of the cells in the X and Y direction. [m].

float cell_size_z_

Height of the cells in the Z direction. [m].

float cell_area_

Surface area of one cell in the horizontal plane. [m^2].

float cell_volume_

Volume of one cell. [m^3].

std::vector<float> vect_x_

Vector providing a conversion between cell’s index and cell’s position in the X direction.

std::vector<float> vect_y_

Vector providing a conversion between cell’s index and cell’s position in the Y direction.

std::vector<double> vect_z_

Vector providing a conversion between cell’s index and cell’s position in the Z direction.

class Body
#include <types.hpp>

Base class for objects interacting with soil.

This class is not meant to be used directly. Instead, derived classes should be used.

Subclassed by soil_simulator::Blade, soil_simulator::Bucket

Public Members

std::vector<float> j_pos_init_

Cartesian coordinates of the body joint in its reference pose. [m].

std::vector<float> b_pos_init_

Cartesian coordinates of the body base in its reference pose. [m].

std::vector<float> t_pos_init_

Cartesian coordinates of the body teeth in its reference pose. [m].

float width_

Width of the body. [m].

std::vector<float> pos_

Cartesian coordinates of the body origin. [m].

std::vector<float> ori_

Orientation of the body. [Quaternion].

Protected Functions

Body(std::vector<float> o_pos_init, std::vector<float> j_pos_init, std::vector<float> b_pos_init, std::vector<float> t_pos_init, float width)

Create a new instance of Body using the reference positions of the body origin, joint, base, and teeth as well as the body width.

The position of the body joint, base, and teeth are given relative to the position of the body origin.

Requirements:

  • All provided Cartesian coordinates should be a vector of size 3.

  • The body joint, base and teeth should have strictly different location.

  • The body width should be greater than zero.

Parameters:
  • o_pos_init – Cartesian coordinates of the body origin in its reference pose. [m]

  • j_pos_init – Cartesian coordinates of the body joint in its reference pose. [m]

  • b_pos_init – Cartesian coordinates of the body base in its reference pose. [m]

  • t_pos_init – Cartesian coordinates of the body teeth in its reference pose. [m]

  • width – Width of the body. [m]

inline virtual ~Body()

Destructor.

class Bucket : public soil_simulator::Body
#include <types.hpp>

Store all parameters related to a bucket object.

Convention:

  • The bucket is approximated as a triangular prism

                   A ____________________ D
                  /.                     /|
                 / .                    / |
                /  .                   /  |
               /   .                  /   |
              /    .                 /    |
             /     .                /     |
            /      .               /      |
           /       C . . . . . .  / . . . F
          /      .               /        ̸
         /     .                /       ̸
        /    .                 /      ̸
       /   .                  /     ̸
      /  .                   /    ̸
     / .                    /   ̸
    B ____________________ E
    

  • The middle of the segment AD is referred to as the bucket joint.

  • The middle of the segment CF is referred to as the bucket base.

  • The middle of the segment BE is referred to as the bucket teeth.

  • The surface ABED is open and referred to as the bucket front.

  • The surface BCFE is a bucket wall and referred to as the bucket base.

  • The surface ACFD is a bucket wall and referred to as the bucket back.

  • The surface ABC is a bucket wall and referred to as the bucket right side.

  • The surface DEF is a bucket wall and referred to as the bucket left side.

  • The bucket has a constant width, denoted as

AD = BE = CF = `width_`.

  • The centre of rotation of the bucket is assumed to be at the bucket origin (not shown in the figure) and the bucket vertices are given relative to this origin.

  • The provided coordinates are assumed to be the reference pose of the bucket, from which the bucket pose is calculated throughout the code.

Usage:

std::vector<float> o_pos = {0.0, 0.0, 0.0};
std::vector<float> j_pos = {0.0, 0.0, 0.0};
std::vector<float> b_pos = {0.0, 0.0, -0.5};
std::vector<float> t_pos = {1.0, 0.0, -0.5};

soil_simulator::Bucket bucket(o_pos, j_pos, b_pos, t_pos, 0.5);

This would create a bucket ABCDEF with its centre of rotation at the bucket joint and with:

  • A = [0.0, -0.25, 0.0]

  • B = [1.0, -0.25, -0.5]

  • C = [0.0, -0.25, -0.5]

  • D = [0.0, 0.25, 0.0]

  • E = [1.0, 0.25, -0.5]

  • F = [0.0, 0.25, -0.5]

Public Functions

inline Bucket(std::vector<float> o_pos_init = {0.0, 0.0, 0.0}, std::vector<float> j_pos_init = {0.0, 0.0, 0.0}, std::vector<float> b_pos_init = {0.0, 0.0, -0.5}, std::vector<float> t_pos_init = {0.7, 0.0, -0.5}, float width = 0.5)

Constructor.

inline ~Bucket()

Destructor.

class Blade : public soil_simulator::Body
#include <types.hpp>

Store all parameters related to a blade object.

Convention:

  • The blade is approximated with the following shape

                                 A __ B
                                 ̸ .   ̸  \
                               ̸     ̸.    \
                             ̸     ̸   .    \
                           ̸     ̸      .    \
                        C __ D         .    \
                         \    \         .    \
                          \    \         .    \
                           \    \         .    \
                            \    \         E __ F
                             \    \      .  .   ̸  ⟍
                              \    \   .      ̸.     ⟍
                               \    \.      ̸    .     ⟍
                                \ .  \   ̸         .     ⟍
                                 G __ H             I __ J
                                   ⟍    ⟍         .      ̸
                                     ⟍    ⟍     .      ̸
                                       ⟍    ⟍ .      ̸
                                         ⟍  .  ⟍    ̸
                                           K __ L
    

  • The middle of the segment FH is referred to as the blade joint.

  • The middle of the segment BD is referred to as the blade base.

  • The middle of the segment JL is referred to as the blade teeth.

  • The shape ABCDEFGH is referred to as the blade ankle.

  • The shape EFGHIJKL is referred to as the blade heel.

  • The blade has a constant width, denoted as

AC = BD = EG = FH = IK = JL = `width_`.

  • The blade has a constant thickness of two cell lengths

AB = CD = EF = GH = IJ = KL = 2 * `cell_size_xy_`.

  • The centre of rotation of the blade is assumed to be at the blade origin (not shown in the figure) and the blade vertices are given relative to this origin.

  • The provided coordinates are assumed to be the reference pose of the blade, from which the blade pose is calculated throughout the code.

Usage:

std::vector<float> o_pos = {0.0, 0.0, 0.0};
std::vector<float> j_pos = {0.9, 0.0, 0.2};
std::vector<float> b_pos = {0.75, 0.0, 1.5};
std::vector<float> t_pos = {1.6, 0.0, -0.4};

soil_simulator::Blade blade(o_pos, j_pos, b_pos, t_pos, 4.5);

This would create a blade ABCDEFGHIJKL with:

  • B = [0.75, -2.25, 1.5]

  • F = [0.9, -2.25, 0.2]

  • J = [1.6, -2.25, -0.4]

  • D = [0.75, 2.25, 1.5]

  • H = [0.9, 2.25, 0.2]

  • L = [1.6, 2.25, -0.4] and ACEGIK located at the same Y and Z coordinates that their corresponding vertex but with minus two cell lengths in the X direction.

Public Functions

inline Blade(std::vector<float> o_pos_init = {0.0, 0.0, 0.0}, std::vector<float> j_pos_init = {0.9, 0.0, 0.2}, std::vector<float> b_pos_init = {0.75, 0.0, 1.5}, std::vector<float> t_pos_init = {1.6, 0.0, -0.4}, float width = 4.5)

Constructor.

inline ~Blade()

Destructor.

class SimParam
#include <types.hpp>

Store all parameters related to the simulation.

Note

  • The value of max_iterations_ should be carefully selected. A higher number will result in a terrain_ closer to equilibrium at the end of each time step, but it may impact significantly the performance of the simulator. A value of 3 is suggested.

Usage:

soil_simulator::SimParam sim_param(0.85, 5, 4);

Public Functions

SimParam(float repose_angle = 0.85, int max_iterations = 10, int cell_buffer = 4)

Create a new instance of SimParam.

Requirements:

  • The repose_angle should be between 0.0 and pi / 2. The upper limit may be extended in the future.

  • The max_iterations should be greater or equal to zero.

  • The cell_buffer should be greater or equal to 2.

Parameters:
  • repose_angle – The repose angle of the considered soil. [rad]

  • max_iterations – The maximum number of relaxation iterations per step.

  • cell_buffer – The number of buffer cells surrounding the body and the relaxed terrain where soil equilibrium is checked.

inline ~SimParam()

Destructor.

Public Members

float repose_angle_

The repose angle of the considered soil. [rad].

int max_iterations_

The maximum number of relaxation iterations per step.

int cell_buffer_

The number of buffer cells surrounding the body and the relaxed terrain where soil equilibrium is checked.

class SimOut
#include <types.hpp>

Store all outputs of the simulation.

Convention

  • The terrain_ Matrix stores the height of the terrain at each XY position, see the Grid class for more details on the simulation grid.

  • The cells where a body wall is located is stored in body_. At each XY position, the first layer indicates the lowest height where a body wall is located while the second layer indicates the maximum height of this body wall. If a second body wall is located at the same XY position, its minimum and maximum height are indicated in the third and fourth layers, respectively.

  • For each body, there can be only two distinct body walls located at the same XY position. As a result, the number of layers in the body_ vector should be equal to four times the number of body.

  • Similarly, body_soil_ stores the location of the soil resting on a body wall. The structure of body_soil_ is identical to body_. An additional restriction is that the minimum height of the soil resting on the body must correspond to the maximum height of a body wall.

  • The locations where there is soil resting on the body are stored in body_soil_pos_ as a vector of body_soil struct.

  • The active areas (body_area_, relax_area_ and impact_area_) are assumed to be rectangular and to follow the grid geometry. They are thus stored as 2x2 Matrices where: [0, 0] corresponds to the minimum X index. [0, 1] corresponds to the maximum X index. [1, 0] corresponds to the minimum Y index. [1, 1] corresponds to the maximum Y index.

Note:

  • Currently, only one body at a time is supported, but this restriction may be removed in the future.

Usage:

soil_simulator::Grid grid(4.0, 4.0, 3.0, 0.05, 0.01);

soil_simulator::SimOut sim_out(grid);

This would create a flat terrain located at 0 height.

Public Functions

explicit SimOut(Grid grid = Grid())

Create a new instance of SimOut.

Parameters:

grid – Class that stores information related to the simulation grid.

inline ~SimOut()

Destructor.

Public Members

bool equilibrium_

Indicates whether the terrain is at equilibrium.

std::vector<std::vector<float>> terrain_

Height of the terrain. [m].

std::vector<std::vector<std::vector<float>>> body_

Store the vertical extension of all body walls for each XY position. [m]

std::vector<std::vector<std::vector<float>>> body_soil_

Store the vertical extension of all soil resting on a body wall for each XY position. [m]

std::vector<body_soil> body_soil_pos_

Store the information related to the soil resting on the body.

int body_area_[2][2]

Store the 2D bounding box of the body with a buffer determined by the parameter cell_buffer_ of SimParam.

int relax_area_[2][2]

Store the 2D bounding box of the area where soil has been relaxed with a buffer determined by the parameter cell_buffer_ of SimParam.

int impact_area_[2][2]

Store the union of body_area_ and relax_area_. It corresponds to the area where the soil equilibrium is checked.