bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
chrono_imu_backend.h
Go to the documentation of this file.
1#ifndef BITSIM_SENSORS_BACKENDS_CHRONO_IMU_BACKEND_H
2#define BITSIM_SENSORS_BACKENDS_CHRONO_IMU_BACKEND_H
3
4#include "bitsim/bitsim_config.h"
5
6#ifdef BITSIM_CHRONO
7
9
10#include <chrono/physics/ChBody.h>
11
12#include <array>
13#include <memory>
14#include <random>
15#include <string>
16#include <vector>
17
18namespace bitsim
19{
20namespace sensors::backends
21{
22
39{
40 public:
41 static const std::string BACKEND_TYPE;
42
46 struct Errors
47 {
48 std::array<real_t, 3> gyro_bias{0.0, 0.0, 0.0};
52
57 void read(const nlohmann::json &j);
58 };
59
64
65 explicit CHRONO_IMUBackend(std::shared_ptr<chrono::ChBody> body);
66
67 const Errors &errors() const noexcept { return errors_; }
68 void set_errors(const Errors &errors);
69
74 void load(const nlohmann::json &j) override;
75
82 std::vector<real_t> read_values() override;
83
84 private:
85 Errors errors_;
86 std::mt19937 generator_{42};
87};
88
89} // namespace sensors::backends
90} // namespace bitsim
91
92#endif
93#endif // BITSIM_SENSORS_BACKENDS_CHRONO_IMU_BACKEND_H
CHRONO_IMUBackend()
Constructor. Attach a body with set_chrono_body() before reading.
Definition chrono_imu_backend.cpp:30
const Errors & errors() const noexcept
Definition chrono_imu_backend.h:67
void set_errors(const Errors &errors)
Definition chrono_imu_backend.cpp:38
std::vector< real_t > read_values() override
Read the accelerometer and the gyroscope.
Definition chrono_imu_backend.cpp:56
static const std::string BACKEND_TYPE
Definition chrono_imu_backend.h:41
void load(const nlohmann::json &j) override
Read the settings, see IMUBackendBase::load(), and the errors, see Errors::read().
Definition chrono_imu_backend.cpp:48
IMUBackendBase(const std::string &backend_type)
Definition imu_backend_base.h:92
Definition camera_backend_base.h:19
Definition dc_motor_backend_base.h:9
std::size_t uint_t
uint_t
Definition bitsim_types.h:40
double real_t
real_t
Definition bitsim_types.h:20
How the IMU errs.
Definition chrono_imu_backend.h:47
real_t accel_noise
standard deviation [m/s^2]
Definition chrono_imu_backend.h:50
void read(const nlohmann::json &j)
Read the keys gyro_bias, gyro_noise, accel_noise and seed, all optional.
Definition chrono_imu_backend.cpp:18
std::array< real_t, 3 > gyro_bias
[rad/s]
Definition chrono_imu_backend.h:48
uint_t seed
Definition chrono_imu_backend.h:51
real_t gyro_noise
standard deviation [rad/s]
Definition chrono_imu_backend.h:49