supereight
Loading...
Searching...
No Matches
sensor.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2020-2024 Smart Robotics Lab, Imperial College London, Technical University of Munich
3 * SPDX-FileCopyrightText: 2020-2022 Nils Funk
4 * SPDX-FileCopyrightText: 2020-2022 Sotiris Papatheodorou
5 * SPDX-FileCopyrightText: 2022-2024 Simon Boche
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#ifndef SE_SENSOR_HPP
10#define SE_SENSOR_HPP
11
12#include <limits>
17#include <se/common/yaml.hpp>
18#include <se/image/image.hpp>
19
20namespace se {
21
25template<typename DerivedT>
27 public:
29 struct Config {
31 int width = 0;
32
34 int height = 0;
35
38 float near_plane = 0.01f;
39
44 float far_plane = 10.0f;
45
47 Eigen::Isometry3f T_BS = Eigen::Isometry3f::Identity();
48
56 std::vector<float> pixel_voxel_ratio_per_scale = {1.5f, 3.0f, 6.0f};
57
61 void readYaml(const std::string& filename);
62
64 {
65 return Config{static_cast<int>(width / downsampling_factor),
66 static_cast<int>(height / downsampling_factor),
69 T_BS,
71 }
72
73 // The definition of this function MUST be inside the definition of Config for template
74 // argument deduction to work.
75 friend std::ostream& operator<<(std::ostream& os, const Config& c)
76 {
77 os << str_utils::value_to_pretty_str(c.width, "width") << " px\n";
78 os << str_utils::value_to_pretty_str(c.height, "height") << " px\n";
79 os << str_utils::value_to_pretty_str(c.near_plane, "near_plane") << " m\n";
80 os << str_utils::value_to_pretty_str(c.far_plane, "far_plane") << " m\n";
81 os << str_utils::eigen_matrix_to_pretty_str(c.T_BS.matrix(), "T_BS") << "\n";
82 return os;
83 }
84
85 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
86 };
87
88 template<typename ConfigT>
90
91 SensorBase(const DerivedT& d);
92
105 int computeIntegrationScale(const Eigen::Vector3f& block_centre_S,
106 const float map_res,
107 const int last_scale,
108 const int min_scale,
109 const int max_block_scale) const;
110
117 float nearDist(const Eigen::Vector3f& ray_S) const;
118
125 float farDist(const Eigen::Vector3f& ray_S) const;
126
133 float measurementFromPoint(const Eigen::Vector3f& point_S) const;
134
136 bool pointInFrustum(const Eigen::Vector3f& point_S) const;
137
140 bool pointInFrustumInf(const Eigen::Vector3f& point_S) const;
141
146 bool sphereInFrustum(const Eigen::Vector3f& centre_S, const float radius) const;
147
152 bool sphereInFrustumInf(const Eigen::Vector3f& centre_S, const float radius) const;
153
155 static std::string type();
156
160 Eigen::Isometry3f T_BS;
161 std::vector<float> pixel_voxel_ratio_per_scale;
162
163 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
164
165 private:
166 // Make sure the derived class and the template parameter are the same (i.e. prevent class D1 : Base<D2>)
167 SensorBase(){};
168 friend DerivedT;
169
170 // Simplify access to derived member functions
171 const DerivedT* underlying() const;
172};
173
174} // namespace se
175
176#include "impl/sensor_impl.hpp"
177#include "leica_lidar.hpp"
178#include "ouster_lidar.hpp"
179#include "pinhole_camera.hpp"
180
181#endif // SE_SENSOR_HPP
Definition image.hpp:19
int height() const
Definition image.hpp:76
int width() const
Definition image.hpp:71
Base class for all sensor models used for integrating measurements.
Definition sensor.hpp:26
bool sphereInFrustumInf(const Eigen::Vector3f &centre_S, const float radius) const
Return whether a sphere with centre_S and radius, expressed in the sensor frame, is at least partiall...
int computeIntegrationScale(const Eigen::Vector3f &block_centre_S, const float map_res, const int last_scale, const int min_scale, const int max_block_scale) const
Return the integration scale for an se::Block at block_centre_S.
bool pointInFrustum(const Eigen::Vector3f &point_S) const
Return whether point_S, expressed in the sensor frame, is inside the sensor frustum.
SensorBase(const DerivedT &d)
float farDist(const Eigen::Vector3f &ray_S) const
Return the maximum distance along ray_S, expressed in the sensor frame, that can be measured.
static std::string type()
Return the underlying sensor type as a string.
float near_plane
Definition sensor.hpp:158
bool left_hand_frame
Definition sensor.hpp:157
bool pointInFrustumInf(const Eigen::Vector3f &point_S) const
Return whether point_S, expressed in the sensor frame, is inside the sensor frustum but without consi...
float far_plane
Definition sensor.hpp:159
bool sphereInFrustum(const Eigen::Vector3f &centre_S, const float radius) const
Return whether a sphere with centre_S and radius, expressed in the sensor frame, is at least partiall...
SensorBase(const ConfigT &c)
std::vector< float > pixel_voxel_ratio_per_scale
Definition sensor.hpp:161
Eigen::Isometry3f T_BS
Definition sensor.hpp:160
float measurementFromPoint(const Eigen::Vector3f &point_S) const
Return the depth measurement that would result form point_S, expressed in the sensor frame,...
float nearDist(const Eigen::Vector3f &ray_S) const
Return the minimum distance along ray_S, expressed in the sensor frame, that can be measured.
std::string value_to_pretty_str(const ValueT &val, const std::string &val_name="", const std::string &val_unit="", const int width=default_width)
Convert a matrix name, value and unit to a standardised string output.
std::string eigen_matrix_to_pretty_str(const EigenMatrixT &M, const std::string &M_name="", const int width=default_width)
Convert a matrix name and Eigen::Matrix value to a standardised string output.
Helper wrapper to allocate and de-allocate octants in the octree.
Definition bounded_vector.hpp:14
Configuration parameters common for all sensor models.
Definition sensor.hpp:29
float near_plane
The sensor's near plane in metres.
Definition sensor.hpp:38
void readYaml(const std::string &filename)
Reads the struct members from the "sensor" node of a YAML file.
std::vector< float > pixel_voxel_ratio_per_scale
The pixel-size to voxel-size ratio thresholds, in ascendig order and in physical coordinates,...
Definition sensor.hpp:56
int height
The height of images produced by the sensor in pixels.
Definition sensor.hpp:34
float far_plane
The sensor's far plane in metres.
Definition sensor.hpp:44
int width
The width of images produced by the sensor in pixels.
Definition sensor.hpp:31
Eigen::Isometry3f T_BS
The transformation from the sensor frame S to the body frame B.
Definition sensor.hpp:47
Config operator/(const float downsampling_factor) const
Definition sensor.hpp:63
friend std::ostream & operator<<(std::ostream &os, const Config &c)
Definition sensor.hpp:75