libstp
Robotics library for Botball
Loading...
Searching...
No Matches
IMU.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4
5#include "hal/IIMU.hpp"
6
7namespace libstp::hal::imu
8{
15 class IMU : public IIMU
16 {
17#ifdef SAFETY_CHECKS_ENABLED
18 static bool imuInstanceCreated;
19#endif
20 public:
22 IMU();
23
24 ~IMU() override;
25
36 static std::shared_ptr<IMU> instance();
37
39 void read(float* accel, float* gyro, float* magneto) override;
41 void getAngularVelocity(float* gyro) override;
43 void calibrate() override;
45 [[nodiscard]] float getHeading() override;
47 void getLinearAcceleration(float* linear_accel) override;
49 void getQuaternion(float* quat) override;
51 void getIntegratedVelocity(float* vel) override;
53 void resetIntegratedVelocity() override;
54
56 bool waitForReady(int timeout_ms = 1000) override;
57 };
58}
void read(float *accel, float *gyro, float *magneto) override
Read accel, gyro, and magnetometer data into caller-owned buffers.
bool waitForReady(int timeout_ms=1000) override
Wait for the platform to report that initial orientation data is ready.
void getAngularVelocity(float *gyro) override
Read angular velocity in radians per second into a caller-owned buffer.
static std::shared_ptr< IMU > instance()
void resetIntegratedVelocity() override
Reset the platform's integrated-velocity accumulator if supported.
float getHeading() override
Return the current heading in radians using libstp sign conventions.
void getLinearAcceleration(float *linear_accel) override
Read gravity-compensated acceleration into a caller-owned buffer.
void getQuaternion(float *quat) override
Read the DMP fused orientation quaternion [w,x,y,z] into a buffer.
IMU()
Construct the platform IMU implementation.
void getIntegratedVelocity(float *vel) override
Read firmware-integrated velocity when the platform provides it.
void calibrate() override
Run whatever calibration behavior the active platform exposes.
Interface for IMU abstraction.
Definition IIMU.hpp:97