MVSim
Lightweight simulator for 2.5D vehicles and robots
IMU.h
1 /*+-------------------------------------------------------------------------+
2  | MultiVehicle simulator (libmvsim) |
3  | |
4  | Copyright (C) 2014-2026 Jose Luis Blanco Claraco |
5  | Copyright (C) 2017 Borys Tymchenko (Odessa Polytechnic University) |
6  | Distributed under 3-clause BSD License |
7  | See COPYING |
8  +-------------------------------------------------------------------------+ */
9 
10 #pragma once
11 
12 #include <mrpt/obs/CObservationIMU.h>
13 #include <mrpt/poses/CPose3D.h>
14 #include <mrpt/random.h>
15 #include <mvsim/Sensors/ImuNoiseModel.h>
16 #include <mvsim/Sensors/SensorBase.h>
17 
18 #include <mutex>
19 
20 namespace mvsim
21 {
30 class IMU : public SensorBase
31 {
32  DECLARES_REGISTER_SENSOR(IMU)
33  public:
34  IMU(Simulable& parent, const rapidxml::xml_node<char>* root);
35 
36  // See docs in base class
37  virtual void loadConfigFrom(const rapidxml::xml_node<char>* root) override;
38 
39  virtual void simul_pre_timestep(const TSimulContext& context) override;
40  virtual void simul_post_timestep(const TSimulContext& context) override;
41 
42  void registerOnServer(mvsim::Client& c) override;
43 
44  protected:
45  void internalGuiUpdate(
46  const mrpt::optional_ref<mrpt::opengl::COpenGLScene>& viz,
47  [[maybe_unused]] const mrpt::optional_ref<mrpt::opengl::COpenGLScene>& physical,
48  [[maybe_unused]] bool childrenOnly) override;
49 
50  void notifySimulableSetPose(const mrpt::math::TPose3D& newPose) override;
51 
52  mrpt::math::TPose3D getRelativePose() const override { return obs_model_.sensorPose.asTPose(); }
53  void setRelativePose(const mrpt::math::TPose3D& p) override
54  {
55  obs_model_.sensorPose = mrpt::poses::CPose3D(p);
56  }
57 
58  void internal_simulate_imu(const TSimulContext& context);
59 
60  double orientationStdNoise_ = 0.005;
61 
64 
65  bool measure_orientation_ = false;
66 
67  // Store here all default parameters. This obj will be copied as a
68  // "pattern" to fill it with actual data.
69  mrpt::obs::CObservationIMU obs_model_;
70 
71  std::mutex last_obs_cs_;
72 
74  mrpt::obs::CObservationIMU::Ptr last_obs_;
75 
76  mrpt::opengl::CSetOfObjects::Ptr gl_sensor_origin_, gl_sensor_origin_corner_;
77 
78  mrpt::random::CRandomGenerator rng_;
79 };
80 } // namespace mvsim
Definition: Client.h:49
Definition: IMU.h:31
virtual void simul_pre_timestep(const TSimulContext &context) override
bool measure_orientation_
If true, the IMU will also measure orientation.
Definition: IMU.h:65
void setRelativePose(const mrpt::math::TPose3D &p) override
Definition: IMU.h:53
double orientationStdNoise_
[rad]
Definition: IMU.h:60
virtual void simul_post_timestep(const TSimulContext &context) override
virtual void loadConfigFrom(const rapidxml::xml_node< char > *root) override
ImuNoiseModel noiseModel_
Definition: IMU.h:63
mrpt::math::TPose3D getRelativePose() const override
Definition: IMU.h:52
mrpt::obs::CObservationIMU::Ptr last_obs_
Definition: IMU.h:74
Stochastic IMU error model based on Forster et al. (2016).
Definition: ImuNoiseModel.h:52
Virtual base class for all sensors.
Definition: SensorBase.h:35
Definition: Simulable.h:40
Definition: basic_types.h:58