#include <SignedDistanceField.hpp>
Public Types | |
using | Derivative3 = Eigen::Vector3d |
Public Member Functions | |
Derivative3 | derivative (const Position3 &position) const noexcept |
void | filterPoints (std::function< void(const Position3 &, float, const Derivative3 &)> func, size_t decimation=1) const |
const std::string & | getFrameId () const noexcept |
Time | getTime () const noexcept |
SignedDistanceField (const GridMap &gridMap, const std::string &elevationLayer, double minHeight, double maxHeight) | |
size_t | size () const noexcept |
double | value (const Position3 &position) const noexcept |
std::pair< double, Derivative3 > | valueAndDerivative (const Position3 &position) const noexcept |
Private Types | |
using | node_data_t = std::array< float, 4 > |
Data structure to store together {signed distance value, derivative}. More... | |
Private Member Functions | |
void | computeLayerSdfandDeltaX (const Matrix &elevation, Matrix ¤tLayer, Matrix &dxTranspose, Matrix &sdfTranspose, Matrix &tmp, Matrix &tmpTranspose, float height, float resolution, float minHeight, float maxHeight) const |
void | computeSignedDistance (const Matrix &elevation) |
void | emplacebackLayerData (const Matrix &signedDistance, const Matrix &dxTranspose, const Matrix &dy, const Matrix &dz) |
Static Private Member Functions | |
static Derivative3 | derivative (const node_data_t &nodeData) noexcept |
static double | distance (const node_data_t &nodeData) noexcept |
static float | distanceFloat (const node_data_t &nodeData) noexcept |
Private Attributes | |
std::vector< node_data_t > | data_ |
Object encoding the signed distance value and derivative in the grid. More... | |
std::string | frameId_ |
Frame id of the grid map. More... | |
signed_distance_field::Gridmap3dLookup | gridmap3DLookup_ |
Object encoding the 3D grid. More... | |
Time | timestamp_ |
Timestamp of the grid map (nanoseconds). More... | |
This class creates a dense 3D signed distance field grid for a given elevation map. The 3D grid uses the same resolution as the 2D map. i.e. all voxels are of size (resolution x resolution x resolution). The size of the 3D grid is the same as the map in XY direction. The size in Z direction is specified in the constructor.
During the creation of the class all values and derivatives are pre-computed in one go. This makes repeated lookups very cheap. Querying a point outside of the constructed grid will result in linear extrapolation.
The distance value and derivatives (dx,dy,dz) per voxel are stored next to each other in memory to support fast lookup during interpolation, where we need all 4 values simultaneously. The entire dense grid is stored as a flat vector, with the indexing outsourced to the Gridmap3dLookup class.
Definition at line 34 of file SignedDistanceField.hpp.
using grid_map::SignedDistanceField::Derivative3 = Eigen::Vector3d |
Definition at line 37 of file SignedDistanceField.hpp.
|
private |
Data structure to store together {signed distance value, derivative}.
Definition at line 117 of file SignedDistanceField.hpp.
grid_map::SignedDistanceField::SignedDistanceField | ( | const GridMap & | gridMap, |
const std::string & | elevationLayer, | ||
double | minHeight, | ||
double | maxHeight | ||
) |
Create a signed distance field and its derivative for an elevation layer in the grid map.
gridMap | : Input map to create the SDF for. |
elevationLayer | : Name of the elevation layer. |
minHeight | : Desired starting height of the 3D SDF grid. |
maxHeight | : Desired ending height of the 3D SDF grid. (Will be rounded up to match the resolution) |
Definition at line 25 of file SignedDistanceField.cpp.
|
private |
Simultaneously compute the signed distance and derivative in x direction at a given height
elevation | [in] : elevation data |
currentLayer | [out] : signed distance values |
dxTranspose | [out] : derivative in x direction (the matrix is transposed) |
sdfTranspose | [tmp] : temporary variable to reuse between calls (allocated on first use) |
tmp | [tmp] : temporary variable (allocated on first use) |
tmpTranspose | [tmp] : temporary variable (allocated on first use) |
height | [in] : height the signed distance is created for. |
resolution | [in] : resolution of the map. |
minHeight | [in] : smallest height value in the elevation data. |
maxHeight | [in] : largest height value in the elevation data. |
Definition at line 156 of file SignedDistanceField.cpp.
|
private |
Implementation of the signed distance field computation in this class.
elevation |
Definition at line 80 of file SignedDistanceField.cpp.
|
noexcept |
Get the signed distance derivative at a 3D position.
position | : 3D position in the frame of the gridmap. |
Definition at line 66 of file SignedDistanceField.cpp.
|
inlinestaticprivatenoexcept |
Helper function to extract the sdf derivative
Definition at line 126 of file SignedDistanceField.hpp.
|
inlinestaticprivatenoexcept |
Helper function to extract the sdf value
Definition at line 120 of file SignedDistanceField.hpp.
|
inlinestaticprivatenoexcept |
Helper function to extract the sdf value as float
Definition at line 123 of file SignedDistanceField.hpp.
|
private |
Add the computed signed distance values and derivatives at a particular height to the grid. Adds the layer to the back of data_
signedDistance | : signed distance values. |
dxTranspose | : x components of the derivative (matrix is transposed). |
dy | : y components of the derivative. |
dz | : z components of the derivative. |
Definition at line 165 of file SignedDistanceField.cpp.
void grid_map::SignedDistanceField::filterPoints | ( | std::function< void(const Position3 &, float, const Derivative3 &)> | func, |
size_t | decimation = 1 |
||
) | const |
Calls a function on each point in the signed distance field. The points are processed in the order they are stored in memory.
func | : function taking the node position, signed distance value, and signed distance derivative. |
decimation | : specifies how many points are returned. 1: all points, 2: every second point, etc. |
Definition at line 186 of file SignedDistanceField.cpp.
|
noexcept |
Definition at line 178 of file SignedDistanceField.cpp.
|
noexcept |
Definition at line 182 of file SignedDistanceField.cpp.
|
noexcept |
Definition at line 174 of file SignedDistanceField.cpp.
|
noexcept |
Get the signed distance value at a 3D position.
position | : 3D position in the frame of the gridmap. |
Definition at line 58 of file SignedDistanceField.cpp.
|
noexcept |
Get both the signed distance value and derivative at a 3D position.
position | : 3D position in the frame of the gridmap. |
Definition at line 72 of file SignedDistanceField.cpp.
|
private |
Object encoding the signed distance value and derivative in the grid.
Definition at line 132 of file SignedDistanceField.hpp.
|
private |
Frame id of the grid map.
Definition at line 135 of file SignedDistanceField.hpp.
|
private |
Object encoding the 3D grid.
Definition at line 129 of file SignedDistanceField.hpp.
|
private |
Timestamp of the grid map (nanoseconds).
Definition at line 138 of file SignedDistanceField.hpp.