CalcUpdate Calculates the update for an individual sensor definition. 
  151  {
  152    
  153    GpsMeasurementType* meas = static_cast<GpsMeasurementType*>(measurement.get());
  155 
  156    
  158 
  159    
  160    GpsSensorStateType prior_sensor_state(prior_sensor_data->state_);
  161 
  162    
  163    
  164    Eigen::MatrixXd R_meas_dyn;
  166    {
  167      meas->get_meas_noise(&R_meas_dyn);
  168    }
  169    else
  170    {
  171      R_meas_dyn = this->
R_.asDiagonal();
 
  172    }
  173    const Eigen::Matrix<double, 3, 3> R_meas = R_meas_dyn;
  174 
  176    const int size_of_sensor_state = prior_sensor_state.cov_size_;
  177    const int size_of_full_error_state = size_of_core_state + size_of_sensor_state;
  178    const Eigen::MatrixXd P = prior_cov;
  179    assert(P.size() == size_of_full_error_state * size_of_full_error_state);
  180 
  181    
  182    
  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_ig = prior_sensor_state.p_ig_;
  186 
  187    const Eigen::Vector3d P_gw_w = prior_sensor_state.p_gw_w_;
  188    const Eigen::Matrix3d R_gw_w = prior_sensor_state.q_gw_w_.toRotationMatrix();
  189 
  190    
  191    const Eigen::Matrix3d Hp_pwi = R_gw_w;
  192    const Eigen::Matrix3d Hp_vwi = Eigen::Matrix3d::Zero();
  193    const Eigen::Matrix3d Hp_rwi = -R_gw_w * R_wi * 
Utils::Skew(P_ig);
 
  194    const Eigen::Matrix3d Hp_bw = Eigen::Matrix3d::Zero();
  195    const Eigen::Matrix3d Hp_ba = Eigen::Matrix3d::Zero();
  196 
  197    const Eigen::Matrix3d Hp_pig = R_gw_w * R_wi;
  198    const Eigen::Matrix3d Hp_pgw_w = Eigen::Matrix3d::Zero();  
  199    const Eigen::Matrix3d Hp_rgw_w = Eigen::Matrix3d::Zero();  
  200 
  201    
  202    
  203    Eigen::MatrixXd H(3, Hp_pwi.cols() + Hp_vwi.cols() + Hp_rwi.cols() + Hp_bw.cols() + Hp_ba.cols() + Hp_pig.cols() +
  204                             Hp_pgw_w.cols() + Hp_rgw_w.cols());
  205 
  206    H << Hp_pwi, Hp_vwi, Hp_rwi, Hp_bw, Hp_ba, Hp_pig, Hp_pgw_w, Hp_rgw_w;
  207 
  208    
  209    
  210    const Eigen::Vector3d p_est = P_gw_w + R_gw_w * (P_wi + R_wi * P_ig);
  211    residual_ = Eigen::MatrixXd(p_est.rows(), 1);
 
  213 
  214    
  216    const Eigen::MatrixXd correction = ekf.CalculateCorrection(&
chi2_);
 
  217    assert(correction.size() == size_of_full_error_state * 1);
  218 
  219    
  221    {
  223      return false;
  224    }
  225 
  226    Eigen::MatrixXd P_updated = ekf.CalculateCovUpdate();
  227    assert(P_updated.size() == size_of_full_error_state * size_of_full_error_state);
  229 
  230    
  233 
  234    
  235    const Eigen::MatrixXd sensor_correction = correction.block(size_of_core_state, 0, size_of_sensor_state, 1);
  236    const GpsSensorStateType corrected_sensor_state = 
ApplyCorrection(prior_sensor_state, sensor_correction);
 
  237 
  238    
  239    
  240    CoreType core_data;
  242    core_data.state_ = corrected_core_state;
  243 
  244    
  245    std::shared_ptr<GpsSensorData> sensor_data(std::make_shared<GpsSensorData>());
  246    sensor_data->set_cov(P_updated);
  247    sensor_data->state_ = corrected_sensor_state;
  248 
  249    BufferDataType state_entry(std::make_shared<CoreType>(core_data), sensor_data);
  250 
  252    {
  253      
  254    }
  255    else
  256    {
  257      
  258    }
  259 
  260    *new_state_data = state_entry;
  261 
  262    return true;
  263  }
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
Eigen::Matrix< double, 3, 1 > get_enu(mars::GpsCoordinates coordinates)
get_enu get current GPS reference coordinates
GpsSensorStateType ApplyCorrection(const GpsSensorStateType &prior_sensor_state, const Eigen::MatrixXd &correction)
Definition gps_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