hal_mahonyAHRS.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //=============================================================================================
  2. // MahonyAHRS.h
  3. //=============================================================================================
  4. //
  5. // Madgwick's implementation of Mayhony's AHRS algorithm.
  6. // See: http://www.x-io.co.uk/open-source-imu-and-ahrs-algorithms/
  7. //
  8. // Date Author Notes
  9. // 29/09/2011 SOH Madgwick Initial release
  10. // 02/10/2011 SOH Madgwick Optimised for reduced CPU load
  11. //
  12. //=============================================================================================
  13. #ifndef _hal_mahonyAHRS_h
  14. #define _hal_mahonyAHRS_h
  15. #include <stdbool.h>
  16. #include <stdint.h>
  17. #include <string.h>
  18. #include "sdk_common.h"
  19. #include "SEGGER_RTT.h"
  20. #include "usr_config.h"
  21. typedef struct t_MahonyAHRS{
  22. float twoKi; // 2 * integral gain (Ki)
  23. float twoKp;
  24. float q0, q1, q2, q3; // quaternion of sensor frame relative to auxiliary frame
  25. float integralFBx, integralFBy, integralFBz; // integral error terms scaled by Ki
  26. float invSampleFreq;
  27. float roll, pitch, yaw;
  28. float q[4],accN[4];
  29. }MahonyAHRS_t;
  30. void Mahony_Init(MahonyAHRS_t *P,float sampleFrequency);
  31. void Mahony_update(MahonyAHRS_t *P,float gx, float gy, float gz, float ax, float ay, float az, float mx, float my, float mz);
  32. void Mahony_send_ANO(uint8_t fun,uint8_t* p,int len);
  33. void Mahony_SetKp(MahonyAHRS_t *P,float twoKp);
  34. //float Mahony_GetRoll(void);
  35. //float Mahony_GetPitch(void);
  36. //float Mahony_GetYaw(void);
  37. //void Mahony_GetAccN(float* accn);
  38. #endif