This commit is contained in:
Jakob Oberbuchner
2025-09-08 09:34:39 -05:00
parent 5bd01b926e
commit 299c2c970b

46
IMU.hpp
View File

@@ -8,7 +8,53 @@
#ifndef AUTOPILOT_SHARED_DATA_IMU_HPP_ #ifndef AUTOPILOT_SHARED_DATA_IMU_HPP_
#define AUTOPILOT_SHARED_DATA_IMU_HPP_ #define AUTOPILOT_SHARED_DATA_IMU_HPP_
#include <stdint.h>
namespace IMU {
enum class Orientation {
ENU = 0, // +X = East, +Y = North, +Z = up
NED = 1, // +X = North, +Y = East, +Z = down
};
struct Data {
int16_t magX = 0;
int16_t magY = 0;
int16_t magZ = 0;
int16_t temp = 0;
int16_t accX = 0;
int16_t accY = 0;
int16_t accZ = 0;
int16_t gyrX = 0;
int16_t gyrY = 0;
int16_t gyrZ = 0;
float temperature;
Orientation orientation = Orientation::ENU;
uint8_t* imuDataPtr( void ) {
return (uint8_t*)&temp;
}
uint8_t* magDataPtr( void ) {
return (uint8_t*)&magX;
}
void calcTemperature( void ) {
temperature = (((float)temp / 256.0f) + 25.0f);
}
};
} // namespace IMU