supereight
sensor.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2020-2022 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-License-Identifier: BSD-3-Clause
6  */
7 
8 #ifndef SE_SENSOR_HPP
9 #define SE_SENSOR_HPP
10 
11 #include <limits>
12 
14 #include "se/common/math_util.hpp"
15 #include "se/common/projection.hpp"
16 #include "se/common/yaml.hpp"
17 #include "se/image/image.hpp"
18 
19 
20 
21 namespace se {
22 
26  int width = 0;
27 
30  int height = 0;
31 
34  float near_plane = 0.0f;
35 
38  float far_plane = std::numeric_limits<float>::infinity();
39 
42  Eigen::Matrix4f T_BS = Eigen::Matrix4f::Identity();
43 
47  void readYaml(const std::string& filename);
48 
49  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
50 };
51 
52 
53 
54 template<typename DerivedT>
55 class SensorBase {
56  public:
57  template<typename ConfigT>
58  SensorBase(const ConfigT& c);
59 
60  SensorBase(const DerivedT& d);
61 
73  template<typename ValidPredicate>
74  bool projectToPixelValue(const Eigen::Vector3f& point_S,
75  const se::Image<float>& img,
76  float& img_value,
77  ValidPredicate valid_predicate) const;
78 
90  template<typename ValidPredicate>
91  bool getPixelValue(const Eigen::Vector2f& pixel_f,
92  const se::Image<float>& img,
93  float& img_value,
94  ValidPredicate valid_predicate) const;
111  int computeIntegrationScale(const Eigen::Vector3f& block_centre_S,
112  const float map_res,
113  const int last_scale,
114  const int min_scale,
115  const int max_block_scale) const;
116 
130  float nearDist(const Eigen::Vector3f& ray_S) const;
131 
145  float farDist(const Eigen::Vector3f& ray_S) const;
146 
156  float measurementFromPoint(const Eigen::Vector3f& point_S) const;
157 
162  bool pointInFrustum(const Eigen::Vector3f& point_S) const;
163 
171  bool pointInFrustumInf(const Eigen::Vector3f& point_S) const;
172 
181  bool sphereInFrustum(const Eigen::Vector3f& centre_S, const float radius) const;
182 
190  bool sphereInFrustumInf(const Eigen::Vector3f& centre_S, const float radius) const;
191 
195  static std::string type();
196 
198  float near_plane;
199  float far_plane;
200  Eigen::Matrix4f T_BS;
201 
202  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
203 
204  private:
205  // Make sure the derived class and the template parameter are the same (i.e. prevent class D1 : Base<D2>)
206  SensorBase(){};
207  friend DerivedT;
208 
209  // Simplify access to derived member functions
210  DerivedT& underlying();
211  const DerivedT& underlying() const;
212 };
213 
214 
215 
216 } // namespace se
217 
218 #include "impl/sensor_impl.hpp"
219 #include "ouster_lidar.hpp"
220 #include "pinhole_camera.hpp"
221 
222 #endif // SE_SENSOR_HPP
float near_plane
Definition: sensor.hpp:198
bool left_hand_frame
Definition: sensor.hpp:197
float near_plane
The sensor&#39;s near plane in metres.
Definition: sensor.hpp:34
void readYaml(const std::string &filename)
Reads the struct members from the "sensor" node of a YAML file.
int height
The height of images produced by the sensor in pixels.
Definition: sensor.hpp:30
Eigen::Matrix4f T_BS
Definition: sensor.hpp:200
float far_plane
The sensor&#39;s far plane in metres.
Definition: sensor.hpp:38
int width
The width of images produced by the sensor in pixels.
Definition: sensor.hpp:26
Definition: sensor.hpp:55
float far_plane
Definition: sensor.hpp:199
Definition: sensor.hpp:23
Eigen::Matrix4f T_BS
The transformation from the sensor frame S to the body frame B.
Definition: sensor.hpp:42
Helper wrapper to allocate and de-allocate octants in the octree.
Definition: colour_utils.hpp:17