bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
imu_backend_base.h
Go to the documentation of this file.
1#ifndef BITSIM_SENSORS_BACKENDS_IMU_BACKEND_BASE_H
2#define BITSIM_SENSORS_BACKENDS_IMU_BACKEND_BASE_H
3
4#include "bitsim/bitsim_config.h"
6#include "bitsim/extern/nlohmann/json/json.hpp"
8
9#include <array>
10#include <memory>
11#include <string>
12
13#ifdef BITSIM_CHRONO
14#include <any>
15#include <unordered_map>
16#endif
17
18namespace bitsim
19{
20namespace sensors::backends
21{
22
36{
37 public:
38 using Position = std::array<real_t, 3>;
39
47 static std::shared_ptr<IMUBackendBase> create(const std::string &backend_type);
48
52 const Position &position() const noexcept { return position_; }
53 void set_position(const Position &position) noexcept { position_ = position; }
54
58 std::string sensor_units() const override { return "M/S^2,RAD/S"; }
59
69 virtual void load(const nlohmann::json &j);
70
74 void load_from_json(const std::string &filename) override;
75
76#ifdef BITSIM_CHRONO
81 void
82 add_visual_shape(const std::unordered_map<std::string, std::any> &shape_properties) override;
83#endif
84
85 protected:
86 explicit IMUBackendBase(const std::string &backend_type);
87
88 private:
89 Position position_{0.0, 0.0, 0.0};
90};
91
92inline IMUBackendBase::IMUBackendBase(const std::string &backend_type)
93 : SensorBackendBase(backend_type)
94{
96}
97
98} // namespace sensors::backends
99} // namespace bitsim
100
101#endif // BITSIM_SENSORS_BACKENDS_IMU_BACKEND_BASE_H
The basic types of bitsim. Code outside this file names Eigen's matrix and vector types only through ...
void load_from_json(const std::string &filename) override
Read the settings from a JSON file, see load().
Definition imu_backend_base.cpp:62
std::array< real_t, 3 > Position
Definition imu_backend_base.h:38
void add_visual_shape(const std::unordered_map< std::string, std::any > &shape_properties) override
Draw the IMU as a small box on the body. The properties are x_length, y_length, z_length (float_t) an...
Definition imu_backend_base.cpp:73
std::string sensor_units() const override
Definition imu_backend_base.h:58
const Position & position() const noexcept
Definition imu_backend_base.h:52
static std::shared_ptr< IMUBackendBase > create(const std::string &backend_type)
Create a backend by the name a robot file gives it.
Definition imu_backend_base.cpp:19
virtual void load(const nlohmann::json &j)
Read the settings of the IMU from its section of a robot or sensor file, all optional:
Definition imu_backend_base.cpp:43
IMUBackendBase(const std::string &backend_type)
Definition imu_backend_base.h:92
void set_position(const Position &position) noexcept
Definition imu_backend_base.h:53
SensorBackendBase(const std::string &backend_type)
Constructor.
Definition sensor_backend_base.h:140
void set_n_read_values(uint_t n) noexcept
Set how many values the implementation returns.
Definition sensor_backend_base.h:114
Definition camera_backend_base.h:19
Definition dc_motor_backend_base.h:9