CalcUpdate Calculates the update for an individual sensor definition.
149 PressureMeasurementType* meas =
static_cast<PressureMeasurementType*
>(measurement.get());
156 PressureSensorStateType prior_sensor_state(prior_sensor_data->state_);
160 Eigen::MatrixXd R_meas_dyn;
163 meas->get_meas_noise(&R_meas_dyn);
167 R_meas_dyn = this->
R_.asDiagonal();
169 const Eigen::Matrix<double, 1, 1> R_meas = R_meas_dyn;
172 const int size_of_sensor_state = prior_sensor_state.cov_size_;
173 const int size_of_full_error_state = size_of_core_state + size_of_sensor_state;
174 const Eigen::MatrixXd P = prior_cov;
175 assert(P.size() == size_of_full_error_state * size_of_full_error_state);
178 typedef Eigen::Matrix<double, 1, 3> Matrix13d_t;
179 typedef Eigen::Matrix<double, 1, 1> Matrix1d_t;
180 const Matrix1d_t I_1{ 1 };
181 const Matrix13d_t I_el3{ 0, 0, 1 };
182 const Matrix13d_t Z_el3{ 0, 0, 0 };
183 const Eigen::Vector3d P_wi = prior_core_state.p_wi_;
184 const Eigen::Matrix3d R_wi = prior_core_state.q_wi_.toRotationMatrix();
185 const Eigen::Vector3d P_ip = prior_sensor_state.p_ip_;
186 const Eigen::Vector3d bias_p = Eigen::Vector3d(0, 0, prior_sensor_state.bias_p_);
189 const Matrix13d_t Hp_pwi = I_el3;
190 const Matrix13d_t Hp_vwi = Z_el3;
191 const Eigen::Matrix3d Hp_rwi3 = -R_wi *
Utils::Skew(P_ip);
192 const Matrix13d_t Hp_rwi = I_el3 * Hp_rwi3;
193 const Matrix13d_t Hp_bw = Z_el3;
194 const Matrix13d_t Hp_ba = Z_el3;
197 const Eigen::Matrix3d Hp_pip3 = R_wi;
198 const Matrix13d_t Hp_pip = I_el3 * Hp_pip3;
199 const Matrix1d_t Hp_biasp = I_1;
202 Eigen::MatrixXd H(1, Hp_pwi.cols() + Hp_vwi.cols() + Hp_rwi.cols() + Hp_bw.cols() + Hp_ba.cols() + Hp_pip.cols() +
205 H << Hp_pwi, Hp_vwi, Hp_rwi, Hp_bw, Hp_ba, Hp_pip, Hp_biasp;
209 const Eigen::Vector3d h_est3 = P_wi + R_wi * P_ip + bias_p;
210 const Matrix1d_t h_est = I_el3 * h_est3;
211 residual_ = Eigen::MatrixXd(h_est.rows(), 1);
216 const Eigen::MatrixXd correction = ekf.CalculateCorrection(&
chi2_);
217 assert(correction.size() == size_of_full_error_state * 1);
226 Eigen::MatrixXd P_updated = ekf.CalculateCovUpdate();
227 assert(P_updated.size() == size_of_full_error_state * size_of_full_error_state);
235 const Eigen::MatrixXd sensor_correction = correction.block(size_of_core_state, 0, size_of_sensor_state, 1);
236 const PressureSensorStateType corrected_sensor_state =
ApplyCorrection(prior_sensor_state, sensor_correction);
242 core_data.state_ = corrected_core_state;
245 std::shared_ptr<PressureSensorData> sensor_data(std::make_shared<PressureSensorData>());
246 sensor_data->set_cov(P_updated);
247 sensor_data->state_ = corrected_sensor_state;
249 BufferDataType state_entry(std::make_shared<CoreType>(core_data), sensor_data);
260 *new_state_data = state_entry;
bool passed_
Determine if the test is performed or not.
Definition: ekf.h:84
bool do_test_
Upper critival value.
Definition: ekf.h:83
void PrintReport(const std::string &name)
PrintReport Print a formated report e.g. if the test did not pass.
static constexpr int size_error_
Definition: core_state_type.h:38
static CoreStateType ApplyCorrection(CoreStateType state_prior, Eigen::Matrix< double, CoreStateType::size_error_, 1 > correction)
ApplyCorrection.
Definition: core_state_type.h:46
Matrix1d get_height(Pressure pressure)
Converts the given pressure measurement to a height (distance) value.
PressureSensorStateType ApplyCorrection(const PressureSensorStateType &prior_sensor_state, const Eigen::MatrixXd &correction)
Definition: pressure_sensor_class.h:265
bool use_dynamic_meas_noise_
True if dynamic noise values from measurements should be used.
Definition: sensor_abs_class.h:29
Eigen::VectorXd R_
Measurement noise "squared".
Definition: update_sensor_abs_class.h:32
Eigen::MatrixXd residual_
Definition: update_sensor_abs_class.h:31
static Eigen::MatrixXd EnforceMatrixSymmetry(const Eigen::Ref< const Eigen::MatrixXd > &mat_in)
EnforceMatrixSymmetry.
static Eigen::Matrix3d Skew(const Eigen::Vector3d &v)
skew generate the skew symmetric matrix of v
Eigen::Matrix< double, CoreStateType::size_error_, 1 > CoreStateVector
Definition: core_state_type.h:135