Skip to content

Commit eaf86e9

Browse files
committed
flight and ground estimator now pull in gps covariance matrices
1 parent 113e0bf commit eaf86e9

2 files changed

Lines changed: 22 additions & 8 deletions

File tree

lib/controller/FlightEstimator.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "matlab_funcs.h"
22

3+
#include "GPS.h"
4+
35
#define RTK 1
46

57
Matrix9_9 FlightStateTransitionMat(Vector3 accel, Vector3 gyro, Matrix3_3 R_b2i) {
@@ -58,10 +60,15 @@ Vector19 FlightEstimator(Vector19 x_est, constantsASTRA_t constantsASTRA, Vector
5860
H.block<3, 3>(0, 3) = Matrix3_3::Identity();
5961
H.block<3, 3>(3, 6) = Matrix3_3::Identity();
6062

61-
// Measurement Covariance Matrix
62-
float gps_pos_covar = 0.2 * RTK + 10 * (1 - RTK);
63-
float gps_vel_covar = 0.75;
64-
Matrix6_6 R = (Vector6() << pow(gps_pos_covar, 2) * Vector3::Ones(), pow(gps_vel_covar, 2) * Vector3::Ones()).finished().asDiagonal();
63+
Matrix3_3 gps_pos_covar;
64+
Matrix3_3 gps_vel_covar;
65+
66+
GPS::get_pos_cov(gps_pos_covar);
67+
GPS::get_vel_cov(gps_vel_covar);
68+
69+
Matrix6_6 R = Matrix6_6::Zero();
70+
R.block<3, 3>(0, 0) = gps_pos_covar;
71+
R.block<3, 3>(3, 3) = gps_vel_covar;
6572

6673
// A priori covariance and Kalman gain
6774
Matrix9_6 L = P * H.transpose() * (H * P * H.transpose() + R).inverse();

lib/controller/GroundEstimator.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "matlab_funcs.h"
22

3+
#include "GPS.h"
4+
35
#define RTK 1
46

57
Matrix18_18 GroundStateTransitionMat(Vector3 accel, Vector3 gyro, Matrix3_3 R_b2i) {
@@ -83,10 +85,15 @@ Vector19 GroundEstimator(Vector19 x_est, constantsASTRA_t constantsASTRA, Vector
8385
H.block<3, 3>(0, 3) = Matrix3_3::Identity();
8486
H.block<3, 3>(3, 6) = Matrix3_3::Identity();
8587

86-
// Measurement Covariance Matrix
87-
float gps_pos_covar = 0.5 * RTK + 10 * (1 - RTK);
88-
float gps_vel_covar = 0.5;
89-
R = (Vector6() << pow(gps_pos_covar, 2) * Vector3::Ones(), pow(gps_vel_covar, 2) * Vector3::Ones()).finished().asDiagonal();
88+
Matrix3_3 gps_pos_covar;
89+
Matrix3_3 gps_vel_covar;
90+
91+
GPS::get_pos_cov(gps_pos_covar);
92+
GPS::get_vel_cov(gps_vel_covar);
93+
94+
Matrix6_6 R = Matrix6_6::Zero();
95+
R.block<3, 3>(0, 0) = gps_pos_covar;
96+
R.block<3, 3>(3, 3) = gps_vel_covar;
9097

9198
// A priori covariance and Kalman gain
9299
Matrix18_6 L = P * H.transpose() * (H * P * H.transpose() + R).inverse();

0 commit comments

Comments
 (0)