uas-ugv/main/ugv_io_mpu.hh

46 lines
605 B
C++
Raw Normal View History

2019-01-17 19:44:14 -08:00
#pragma once
#include <stdint.h>
#include <MPU.hpp>
namespace ugv {
namespace io {
2019-01-17 19:59:13 -08:00
struct Vec3f {
float x;
float y;
float z;
Vec3f();
Vec3f(float x, float y, float z);
2019-01-17 22:04:30 -08:00
Vec3f(const mpud::float_axes_t &axes);
2019-01-17 19:59:13 -08:00
};
2019-01-17 19:44:14 -08:00
struct MpuData {
// G's
2019-01-17 19:59:13 -08:00
Vec3f accel;
2019-01-17 19:44:14 -08:00
// degrees/s
2019-01-17 19:59:13 -08:00
Vec3f gyro_rate;
2019-01-17 19:44:14 -08:00
// flux density uT
2019-01-17 19:59:13 -08:00
Vec3f mag;
2019-01-17 19:44:14 -08:00
};
class MPU {
public:
explicit MPU();
~MPU();
void Init();
2019-01-30 19:50:51 -08:00
void Calibrate();
2019-01-17 19:44:14 -08:00
void GetData(MpuData &data);
private:
2019-01-17 22:04:30 -08:00
mpud::mpu_bus_t *mpu_bus_;
2019-01-17 19:44:14 -08:00
mpud::MPU * mpu_;
mpud::raw_axes_t accel_, gyro_, mag_;
};
} // namespace io
} // namespace ugv