arduino-libraries / MadgwickAHRS

Arduino implementation of the MadgwickAHRS algorithm
465 stars 196 forks source link

Big modifications, but most importantly added NED and ENU frame supports. #40

Open CK-Explorer opened 1 year ago

CK-Explorer commented 1 year ago
  1. Added NED, ENU local reference frame supports. The original code was designed for NWU local reference frame, as observed from Eqs. 23 and 27 in his paper. So, for NED frame, Eq. 23 is changed to be equaled to [0 0 0 -1], while for ENU frame, Eq. 27 is changed to be equaled to [0 0 $b_x$ $b_z$]. These modifications lead to different matrices in Eqs. 25 and 26 for NED frame, while in Eqs. 29 and 30 for ENU frame.

  2. Added supports of passing different gyroscope reading's unit (rad or deg) based on user preference into Madgwick::update() and Madgwick::updateIMU().

  3. Added non-constant IMU's update frequency support by allowing users to use elapsed time, while constant frequency still supports.

NOTE: Changes 1 to 3 are achieved using template and functions overloading, but requires C++ 17 supports. For lower than C++ 17, "if ... " is used instead of "if constexpr ... ", which hinders those branches to be evaluated during compile-time. Hence, this might impact the performance.

  1. Added Madgwick::updateCore() and Madgwick::updateCoreIMU() to avoid some code duplications (maintainability purpose) for constant and non-constant frequency supports in Madgwick::update() and Madgwick::updateIMU() respectively.

  2. Added a getter function to obtain quaternion. Obtaining the quaternion is an essential feature of this filter, that avoids numerical instability in determining roll and yaw angles when pitch angle reaches +/-90 degree.

  3. Added setter functions for filter parameter (beta) and IMU's frequency separately.

  4. Added constructors overloading to initialize filter parameter (beta) and IMU's frequency.

  5. Added inline wrapper functions for degree to radians and vice-versa conversion (readability purpose).

  6. Rearranged some previous codes (readability purpose).

  7. Added comments.

CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.

github-actions[bot] commented 1 year ago

Memory usage change @ 0f1a83975708b67b51983ebc57b159b6880bff1e

Board flash % RAM for global variables %
Intel:arc32:arduino_101 :small_red_triangle: +576 - +576 +0.37 - +0.37 N/A N/A
Click for full report table Board|`examples/Visualize101`
flash|%|`examples/Visualize101`
RAM for global variables|% -|-|-|-|- `Intel:arc32:arduino_101`|576|0.37|N/A|N/A
Click for full report CSV ``` Board,examples/Visualize101
flash,%,examples/Visualize101
RAM for global variables,% Intel:arc32:arduino_101,576,0.37,N/A,N/A ```
github-actions[bot] commented 1 year ago

Memory usage change @ cddf13825c8c7def5250cf8eaf2d55a17c8921a0

Board flash % RAM for global variables %
Intel:arc32:arduino_101 :small_red_triangle: +812 - +812 +0.52 - +0.52 N/A N/A
Click for full report table Board|`examples/Visualize101`
flash|%|`examples/Visualize101`
RAM for global variables|% -|-|-|-|- `Intel:arc32:arduino_101`|812|0.52|N/A|N/A
Click for full report CSV ``` Board,examples/Visualize101
flash,%,examples/Visualize101
RAM for global variables,% Intel:arc32:arduino_101,812,0.52,N/A,N/A ```
github-actions[bot] commented 1 year ago

Memory usage change @ 1ebe2f0900d912bf1032d63610ec832aaf95951f

Board flash % RAM for global variables %
Intel:arc32:arduino_101 :small_red_triangle: +812 - +812 +0.52 - +0.52 N/A N/A
Click for full report table Board|`examples/Visualize101`
flash|%|`examples/Visualize101`
RAM for global variables|% -|-|-|-|- `Intel:arc32:arduino_101`|812|0.52|N/A|N/A
Click for full report CSV ``` Board,examples/Visualize101
flash,%,examples/Visualize101
RAM for global variables,% Intel:arc32:arduino_101,812,0.52,N/A,N/A ```