mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-28 05:23:34 +08:00
EKF: Add method to set diagonals in covariance matrix
This commit is contained in:
@@ -596,9 +596,13 @@ private:
|
|||||||
// zero the specified range of columns in the state covariance matrix
|
// zero the specified range of columns in the state covariance matrix
|
||||||
void zeroCols(float (&cov_mat)[_k_num_states][_k_num_states], uint8_t first, uint8_t last);
|
void zeroCols(float (&cov_mat)[_k_num_states][_k_num_states], uint8_t first, uint8_t last);
|
||||||
|
|
||||||
// zero the specified range of off diagonals the state covariance matrix
|
// zero the specified range of off diagonals in the state covariance matrix
|
||||||
void zeroOffDiag(float (&cov_mat)[_k_num_states][_k_num_states], uint8_t first, uint8_t last);
|
void zeroOffDiag(float (&cov_mat)[_k_num_states][_k_num_states], uint8_t first, uint8_t last);
|
||||||
|
|
||||||
|
// zero the specified range of off diagonals in the state covariance matrix
|
||||||
|
// set the diagonals to the supplied value
|
||||||
|
void setDiag(float (&cov_mat)[_k_num_states][_k_num_states], uint8_t first, uint8_t last, float variance);
|
||||||
|
|
||||||
// calculate the measurement variance for the optical flow sensor
|
// calculate the measurement variance for the optical flow sensor
|
||||||
float calcOptFlowMeasVar();
|
float calcOptFlowMeasVar();
|
||||||
|
|
||||||
|
|||||||
@@ -1227,6 +1227,20 @@ void Ekf::zeroOffDiag(float (&cov_mat)[_k_num_states][_k_num_states], uint8_t fi
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Ekf::setDiag(float (&cov_mat)[_k_num_states][_k_num_states], uint8_t first, uint8_t last, float variance)
|
||||||
|
{
|
||||||
|
// zero rows and columns
|
||||||
|
zeroRows(cov_mat, first, last);
|
||||||
|
zeroCols(cov_mat, first, last);
|
||||||
|
|
||||||
|
// set diagonals
|
||||||
|
uint8_t row;
|
||||||
|
for (row = first; row <= last; row++) {
|
||||||
|
cov_mat[row][row] = variance;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool Ekf::global_position_is_valid()
|
bool Ekf::global_position_is_valid()
|
||||||
{
|
{
|
||||||
// return true if we are not doing unconstrained free inertial navigation and the origin is set
|
// return true if we are not doing unconstrained free inertial navigation and the origin is set
|
||||||
|
|||||||
Reference in New Issue
Block a user