bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
imu_sensor.h
Go to the documentation of this file.
1#ifndef BITSIM_SENSORS_IMU_SENSOR_H
2#define BITSIM_SENSORS_IMU_SENSOR_H
3
8
9#include <array>
10#include <memory>
11#include <string>
12#include <vector>
13
14namespace bitsim
15{
16namespace sensors
17{
18
31class IMUSensor final : public SensorBase
32{
33 public:
34 static const std::string SENSOR_TYPE;
35
40 static std::shared_ptr<IMUSensor> create(const std::string &backend_type,
41 const std::string &name);
42
43 explicit IMUSensor(std::shared_ptr<backends::IMUBackendBase> backend,
44 const std::string &name = consts::INVALID_STR);
45
49 void init() override;
50
54 const std::vector<real_t> &read_values() override;
55
56 std::string backend_type_str() const override { return backend_->backend_type_str(); }
57
58 std::string sensor_units() const override { return backend_->sensor_units(); }
59
60 std::shared_ptr<backends::SensorBackendBase> backend_ptr() const override { return backend_; }
61
62 std::shared_ptr<backends::IMUBackendBase> imu_backend() const noexcept { return backend_; }
63
67 std::array<real_t, 3> acceleration() const;
68
72 std::array<real_t, 3> angular_velocity() const;
73
74 private:
75 std::shared_ptr<backends::IMUBackendBase> backend_;
76};
77
78} // namespace sensors
79} // namespace bitsim
80
81#endif // BITSIM_SENSORS_IMU_SENSOR_H
The basic types of bitsim. Code outside this file names Eigen's matrix and vector types only through ...
std::array< real_t, 3 > angular_velocity() const
Definition imu_sensor.cpp:55
const std::vector< real_t > & read_values() override
Read the backend, if the sensor is enabled.
Definition imu_sensor.cpp:33
void init() override
Enable the sensor, reading zeros until the first read.
Definition imu_sensor.cpp:27
std::string sensor_units() const override
Definition imu_sensor.h:58
std::array< real_t, 3 > acceleration() const
Definition imu_sensor.cpp:50
static std::shared_ptr< IMUSensor > create(const std::string &backend_type, const std::string &name)
A sensor with a new backend of the given type, see backends::IMUBackendBase::create.
Definition imu_sensor.cpp:12
std::shared_ptr< backends::IMUBackendBase > imu_backend() const noexcept
Definition imu_sensor.h:62
std::string backend_type_str() const override
Definition imu_sensor.h:56
IMUSensor(std::shared_ptr< backends::IMUBackendBase > backend, const std::string &name=consts::INVALID_STR)
Definition imu_sensor.cpp:18
std::shared_ptr< backends::SensorBackendBase > backend_ptr() const override
Definition imu_sensor.h:60
static const std::string SENSOR_TYPE
Definition imu_sensor.h:34
SensorBase(const std::string &sensor_type, const std::string &sensor_name=bitsim::consts::INVALID_STR)
Definition sensor_base.h:134
const std::string INVALID_STR
Invalid string.
Definition bitsim_consts.h:21
Definition infrared_line_follower.h:9
Definition dc_motor_backend_base.h:9