2025-08-18 15:49:27 -05:00
|
|
|
/*
|
|
|
|
|
* IMU.hpp
|
|
|
|
|
*
|
|
|
|
|
* Created on: Aug 17, 2025
|
|
|
|
|
* Author: jakoboberbuchner
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef AUTOPILOT_SHARED_DATA_IMU_HPP_
|
|
|
|
|
#define AUTOPILOT_SHARED_DATA_IMU_HPP_
|
|
|
|
|
|
2025-09-08 09:34:39 -05:00
|
|
|
#include <stdint.h>
|
2025-08-18 15:49:27 -05:00
|
|
|
|
2025-09-08 09:34:39 -05:00
|
|
|
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
|
2025-08-18 15:49:27 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* AUTOPILOT_SHARED_DATA_IMU_HPP_ */
|