210 AttitudeMeasurementType* meas =
static_cast<AttitudeMeasurementType*
>(measurement.get());
214 Eigen::Vector2d rp_meas = meas->attitude_.get_rp();
217 AttitudeSensorStateType prior_sensor_state(prior_sensor_data->state_);
221 Eigen::MatrixXd R_meas_dyn;
224 meas->get_meas_noise(&R_meas_dyn);
228 R_meas_dyn = this->
R_.asDiagonal();
230 const Eigen::Matrix<double, 2, 2> R_meas = R_meas_dyn;
233 const int size_of_sensor_state = prior_sensor_state.cov_size_;
234 const int size_of_full_error_state = size_of_core_state + size_of_sensor_state;
235 const Eigen::MatrixXd P = prior_cov;
236 assert(P.size() == size_of_full_error_state * size_of_full_error_state);
239 typedef Eigen::Matrix<double, 2, 3> Matrix23d_t;
241 I_23 << 1., 0., 0., 0., 1., 0.;
242 const Matrix23d_t Z_23 = Matrix23d_t::Zero();
243 const Eigen::Matrix3d R_wi = prior_core_state.q_wi_.toRotationMatrix();
244 const Eigen::Matrix3d R_aw = prior_sensor_state.q_aw_.toRotationMatrix();
245 const Eigen::Matrix3d R_ib = prior_sensor_state.q_ib_.toRotationMatrix();
248 const Matrix23d_t Hr_pwi = Z_23;
249 const Matrix23d_t Hr_vwi = Z_23;
250 const Matrix23d_t Hr_rwi = R_ib.transpose().block(0, 0, 2, 3);
251 const Matrix23d_t Hr_bw = Z_23;
252 const Matrix23d_t Hr_ba = Z_23;
254 const Matrix23d_t Hr_raw = (R_ib.transpose() * R_wi.transpose()).block(0, 0, 2, 3);
255 const Matrix23d_t Hr_rib = I_23;
259 Eigen::MatrixXd H(2, Hr_pwi.cols() + Hr_vwi.cols() + Hr_rwi.cols() + Hr_bw.cols() + Hr_ba.cols() + Hr_raw.cols() +
261 H << Hr_pwi, Hr_vwi, Hr_rwi, Hr_bw, Hr_ba, Hr_raw, Hr_rib;
266 const Eigen::Vector2d rp_est(rpy_est(0), rpy_est(1));
267 residual_ = Eigen::MatrixXd(rp_est.rows(), 1);
272 const Eigen::MatrixXd correction = ekf.CalculateCorrection(&
chi2_);
273 assert(correction.size() == size_of_full_error_state * 1);
282 Eigen::MatrixXd P_updated = ekf.CalculateCovUpdate();
283 assert(P_updated.size() == size_of_full_error_state * size_of_full_error_state);
291 const Eigen::MatrixXd sensor_correction = correction.block(size_of_core_state, 0, size_of_sensor_state, 1);
292 const AttitudeSensorStateType corrected_sensor_state =
ApplyCorrection(prior_sensor_state, sensor_correction);
298 core_data.state_ = corrected_core_state;
301 std::shared_ptr<AttitudeSensorData> sensor_data(std::make_shared<AttitudeSensorData>());
302 sensor_data->set_cov(P_updated);
303 sensor_data->state_ = corrected_sensor_state;
305 BufferDataType state_entry(std::make_shared<CoreType>(core_data), sensor_data);
316 *new_state_data = state_entry;
AttitudeSensorStateType ApplyCorrection(const AttitudeSensorStateType &prior_sensor_state, const Eigen::MatrixXd &correction)
Definition: attitude_sensor_class.h:434
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
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::Vector3d RPYFromRotMat(const Eigen::Matrix3d &rot_mat)
RPYFromRotMat derives the roll pitch and yaw angle from a rotation matrix (in that order)
Eigen::Matrix< double, CoreStateType::size_error_, 1 > CoreStateVector
Definition: core_state_type.h:135