Continued Madgwick filter implementation

This commit is contained in:
dario
2024-06-25 23:39:29 +02:00
parent 3a9f2eff21
commit 2a0b244500
4 changed files with 67 additions and 13 deletions

View File

@@ -6,13 +6,15 @@
*/
#include <sta/math/algorithms/attitude/madgwick.hpp>
#include <sta/math/linalg/matrix.hpp>
namespace sta
{
namespace math
{
MadgwickFilter::MadgwickFilter(Quaternion state, uint32_t n, float alpha)
: state_{state.normalized()},
MadgwickFilter::MadgwickFilter(Quaternion state, Quaternion direction, uint32_t n, float alpha)
: state_{state},
direction_{direction},
n_{n},
alpha_{alpha}
{
@@ -24,9 +26,20 @@ namespace sta
state_ = state_ + 0.5f * (state_ * Quaternion(0, ox, oy, oz)) * dt;
}
Quaternion MadgwickFilter::objective(Quaternion q, Quaternion s)
{
return q.conjugate() * direction_ * q - s;
}
void MadgwickFilter::correct(float dx, float dy, float dz)
{
Quaternion q;
for (uint32_t i = 0; i < n_; i++)
{
}
}