SignedDistanceField.hpp
Go to the documentation of this file.
1 /*
2  * SignedDistanceField.h
3  *
4  * Created on: Jul 10, 2020
5  * Author: Ruben Grandia
6  * Institute: ETH Zurich
7  */
8 
9 #pragma once
10 
11 #include <vector>
12 
13 #include <Eigen/Dense>
14 
17 
18 #include "Gridmap3dLookup.hpp"
19 
20 namespace grid_map {
21 
35  public:
36  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
37  using Derivative3 = Eigen::Vector3d;
38 
47  SignedDistanceField(const GridMap& gridMap, const std::string& elevationLayer, double minHeight, double maxHeight);
48 
54  double value(const Position3& position) const noexcept;
55 
61  Derivative3 derivative(const Position3& position) const noexcept;
62 
68  std::pair<double, Derivative3> valueAndDerivative(const Position3& position) const noexcept;
69 
70  size_t size() const noexcept;
71 
72  const std::string& getFrameId() const noexcept;
73 
74  Time getTime() const noexcept;
75 
81  void filterPoints(std::function<void(const Position3&, float, const Derivative3&)> func, size_t decimation = 1) const;
82 
83  private:
88  void computeSignedDistance(const Matrix& elevation);
89 
103  void computeLayerSdfandDeltaX(const Matrix& elevation, Matrix& currentLayer, Matrix& dxTranspose, Matrix& sdfTranspose, Matrix& tmp,
104  Matrix& tmpTranspose, float height, float resolution, float minHeight, float maxHeight) const;
105 
114  void emplacebackLayerData(const Matrix& signedDistance, const Matrix& dxTranspose, const Matrix& dy, const Matrix& dz);
115 
117  using node_data_t = std::array<float, 4>;
118 
120  static double distance(const node_data_t& nodeData) noexcept { return nodeData[0]; }
121 
123  static float distanceFloat(const node_data_t& nodeData) noexcept { return nodeData[0]; }
124 
126  static Derivative3 derivative(const node_data_t& nodeData) noexcept { return {nodeData[1], nodeData[2], nodeData[3]}; }
127 
130 
132  std::vector<node_data_t> data_;
133 
135  std::string frameId_;
136 
139 };
140 
141 } // namespace grid_map
const std::string & getFrameId() const noexcept
static float distanceFloat(const node_data_t &nodeData) noexcept
signed_distance_field::Gridmap3dLookup gridmap3DLookup_
Object encoding the 3D grid.
Time timestamp_
Timestamp of the grid map (nanoseconds).
uint64_t Time
double value(const Position3 &position) const noexcept
static Derivative3 derivative(const node_data_t &nodeData) noexcept
std::pair< double, Derivative3 > valueAndDerivative(const Position3 &position) const noexcept
std::string frameId_
Frame id of the grid map.
void computeSignedDistance(const Matrix &elevation)
Eigen::MatrixXf Matrix
static double distance(const node_data_t &nodeData) noexcept
Derivative3 derivative(const Position3 &position) const noexcept
void computeLayerSdfandDeltaX(const Matrix &elevation, Matrix &currentLayer, Matrix &dxTranspose, Matrix &sdfTranspose, Matrix &tmp, Matrix &tmpTranspose, float height, float resolution, float minHeight, float maxHeight) const
Eigen::Vector3d Position3
std::array< float, 4 > node_data_t
Data structure to store together {signed distance value, derivative}.
void filterPoints(std::function< void(const Position3 &, float, const Derivative3 &)> func, size_t decimation=1) const
std::vector< node_data_t > data_
Object encoding the signed distance value and derivative in the grid.
SignedDistanceField(const GridMap &gridMap, const std::string &elevationLayer, double minHeight, double maxHeight)
void emplacebackLayerData(const Matrix &signedDistance, const Matrix &dxTranspose, const Matrix &dy, const Matrix &dz)


grid_map_sdf
Author(s): Takahiro Miki , Péter Fankhauser
autogenerated on Wed Jul 5 2023 02:23:42