Skip to content

Commit b8ae18a

Browse files
committed
updated mqekf
1 parent f2bb911 commit b8ae18a

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

MIDAS/src/gnc/mqekf.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
void QuaternionMEKF::initialize(RocketSystems *args)
1616
{
17-
float Pq0 = 1e-4;
18-
float Pb0 = 1e-1;
17+
float Pq0 = 1e-4; // test it
18+
float Pb0 = 1e-1; // test it
1919
sigma_a = {accel_noise_density_x * sqrt(20.0f) * 1.0e-6 * 9.81, accel_noise_density_y * sqrt(20.0f) * 1.0e-6 * 9.81, accel_noise_density_z * sqrt(20.0f) * 1.0e-6 * 9.81}; // ug/sqrt(Hz) *sqrt(hz). values are from datasheet
2020
sigma_g = {gyro_RMS_noise * pow(1.0f, -3.0f) * pi / 180.0f * pow(20.0f, 0.5f), gyro_RMS_noise * pow(1.0f, -3.0f) * pi / 180.0f * pow(20.0f, 0.5f), gyro_RMS_noise * pow(1.0f, -3.0f) * pi / 180.0f * pow(20.0f, 0.5f)};
2121
sigma_m = {mag_noise * 1.0e-4 / sqrt(3), mag_noise * 1.0e-4 / sqrt(3), mag_noise * 1.0e-4 / sqrt(3)}; // 0.4 mG -> T, it is 0.4 total so we divide by sqrt3 // 0.4 mG -> T, it is 0.4 total so we divide by sqrt3
@@ -148,6 +148,13 @@ void QuaternionMEKF::measurement_update(Acceleration const &accel, Magnetometer
148148
mag(0, 0) = mag_input.mx;
149149
mag(1, 0) = mag_input.my;
150150
mag(2, 0) = mag_input.mz;
151+
152+
if (acc(0) < 0 ) // Check if the norm of the accelerometer measurement is in boost
153+
{
154+
Eigen::Matrix<float, 3, 3> Rm = sigma_m.array().square().matrix().asDiagonal();
155+
measurement_update_partial(mag, magnetometer_measurement_func(), Rm);
156+
return;
157+
}
151158

152159
Eigen::Matrix<float, 3, 1> const v1hat = accelerometer_measurement_func();
153160
Eigen::Matrix<float, 3, 1> const v2hat = magnetometer_measurement_func();
@@ -178,7 +185,7 @@ void QuaternionMEKF::measurement_update(Acceleration const &accel, Magnetometer
178185
// x * A = b
179186
// Which can be solved with the code below
180187
Eigen::FullPivLU<Eigen::Matrix<float, 6, 6>> lu(s); // LU decomposition of s
181-
if (lu.isInvertible())
188+
if (lu.determinant() != 0)
182189
{
183190
Eigen::Matrix<float, 6, 6> const K = P * C.transpose() * lu.inverse(); // gain
184191

@@ -219,7 +226,7 @@ void QuaternionMEKF::measurement_update_partial(
219226

220227
// K = P * C.T * s^-1
221228
Eigen::FullPivLU<Eigen::Matrix<float, 3, 3>> lu(s);
222-
if (lu.isInvertible())
229+
if (lu.determinant() != 0)
223230
{
224231
Eigen::Matrix<float, 6, 3> const K = P * C.transpose() * lu.inverse();
225232

0 commit comments

Comments
 (0)