13 #ifndef PRESSURE_SENSOR_CLASS_H
14 #define PRESSURE_SENSOR_CLASS_H
36 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
52 std::cout <<
"Created: [" << this->
name_ <<
"] Sensor" << std::endl;
86 std::cout <<
"Info: [" <<
name_ <<
"] Set pressure reference: \n" << pressure << std::endl;
90 std::cout <<
"Warning: [" <<
name_ <<
"] "
91 <<
"Trying to set pressure reference but reference was already set. Action has no effect." << std::endl;
96 std::shared_ptr<CoreType> latest_core_data)
106 std::cout <<
"Info: [" <<
name_ <<
"] Set pressure reference: \n" << pressure << std::endl;
110 std::string calibration_type;
114 calibration_type =
"Given";
123 calibration_type =
"Auto";
124 std::cout <<
"Pressure calibration AUTO init not implemented yet" << std::endl;
129 BufferDataType result(std::make_shared<CoreType>(*latest_core_data.get()),
130 std::make_shared<PressureSensorData>(sensor_state));
134 std::cout <<
"Info: Initialized [" <<
name_ <<
"] with [" << calibration_type <<
"] Calibration at t=" << timestamp
137 std::cout <<
"Info: [" <<
name_ <<
"] Calibration(rounded):" << std::endl;
138 std::cout <<
"\tPosition[m]: [" << sensor_state.
state_.p_ip_.transpose() <<
" ]" << std::endl;
139 std::cout <<
"\tBias[m]: " << sensor_state.
state_.bias_p_ << std::endl;
145 std::shared_ptr<void> latest_sensor_data,
const Eigen::MatrixXd& prior_cov,
160 Eigen::MatrixXd 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);
217 assert(correction.size() == size_of_full_error_state * 1);
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);
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;
266 const Eigen::MatrixXd& correction)
270 corrected_sensor_state.
p_ip_ = prior_sensor_state.
p_ip_ + correction.block(0, 0, 3, 1);
271 corrected_sensor_state.
bias_p_ = prior_sensor_state.
bias_p_ + correction(3);
273 return corrected_sensor_state;
bool has_meas_noise
Definition: measurement_base_class.h:23
bool get_meas_noise(Eigen::MatrixXd *meas_noise)
get the measurement noise associated with the current sensor measurement
Definition: measurement_base_class.h:25
int cov_size_
Definition: base_states.h:25
The BaseSensorData class binds the sensor state and covariance matrix.
Definition: bind_sensor_data.h:29
EIGEN_MAKE_ALIGNED_OPERATOR_NEW T state_
Definition: bind_sensor_data.h:30
Eigen::MatrixXd get_full_cov() const
get_full_cov builds the full covariance matrix
Definition: bind_sensor_data.h:63
Eigen::MatrixXd sensor_cov_
covariance of the sensor states
Definition: bind_sensor_data.h:37
The BufferDataType binds the core and sensor state in form of a shared void pointer.
Definition: buffer_data_type.h:36
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 set_dof(const int &value)
set_dof Set degree of freedom for the X2 distribution
void PrintReport(const std::string &name)
PrintReport Print a formated report e.g. if the test did not pass.
Definition: core_state_type.h:21
static constexpr int size_error_
Definition: core_state_type.h:38
Eigen::Vector3d p_wi_
Definition: core_state_type.h:27
Eigen::Quaternion< double > q_wi_
Definition: core_state_type.h:29
static CoreStateType ApplyCorrection(CoreStateType state_prior, Eigen::Matrix< double, CoreStateType::size_error_, 1 > correction)
ApplyCorrection.
Definition: core_state_type.h:46
Definition: core_type.h:19
CoreStateMatrix cov_
Definition: core_type.h:22
CoreStateType state_
Definition: core_type.h:21
Eigen::MatrixXd CalculateCovUpdate()
CalculateCovUpdate Updating the state covariance after the state update.
Eigen::MatrixXd CalculateCorrection()
Kalman gain.
Definition: pressure_conversion.h:194
void set_pressure_reference(Pressure pressure)
Setter function to set the reference pressure after construction of object.
Matrix1d get_height(Pressure pressure)
Converts the given pressure measurement to a height (distance) value.
Definition: pressure_measurement_type.h:24
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Pressure pressure_
Raw pressure measurement [Pascal] including the ambient temperature in [K].
Definition: pressure_measurement_type.h:28
Definition: pressure_sensor_class.h:34
BufferDataType Initialize(const Time ×tamp, std::shared_ptr< void > sensor_data, std::shared_ptr< CoreType > latest_core_data)
Initialize the state of an individual sensor.
Definition: pressure_sensor_class.h:95
bool CalcUpdate(const Time &, std::shared_ptr< void > measurement, const CoreStateType &prior_core_state, std::shared_ptr< void > latest_sensor_data, const Eigen::MatrixXd &prior_cov, BufferDataType *new_state_data)
CalcUpdate Calculates the update for an individual sensor definition.
Definition: pressure_sensor_class.h:144
PressureSensorStateType get_state(std::shared_ptr< void > sensor_data)
Definition: pressure_sensor_class.h:57
PressureSensorClass(const std::string &name, std::shared_ptr< CoreState > core_states)
Definition: pressure_sensor_class.h:41
void set_pressure_reference(const double &pressure, const double &temperature)
Definition: pressure_sensor_class.h:75
Eigen::MatrixXd get_covariance(const std::shared_ptr< void > &sensor_data)
get_covariance Resolves a void pointer to the covariance matrix of the corresponding sensor type Each...
Definition: pressure_sensor_class.h:63
EIGEN_MAKE_ALIGNED_OPERATOR_NEW PressureConversion pressure_conversion_
Definition: pressure_sensor_class.h:38
void set_initial_calib(std::shared_ptr< void > calibration)
set_initial_calib Sets the calibration of an individual sensor
Definition: pressure_sensor_class.h:69
void set_pressure_reference(const mars::Pressure &pressure)
Definition: pressure_sensor_class.h:80
bool pressure_reference_is_set_
Definition: pressure_sensor_class.h:39
PressureSensorStateType ApplyCorrection(const PressureSensorStateType &prior_sensor_state, const Eigen::MatrixXd &correction)
Definition: pressure_sensor_class.h:265
virtual ~PressureSensorClass()=default
Definition: pressure_sensor_state_type.h:22
double bias_p_
bias of pressure sensor
Definition: pressure_sensor_state_type.h:27
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Eigen::Vector3d p_ip_
translation between IMU and Pressure sensor
Definition: pressure_sensor_state_type.h:26
std::string name_
Name of the individual sensor instance.
Definition: sensor_abs_class.h:23
bool is_initialized_
True if the sensor has been initialized.
Definition: sensor_abs_class.h:24
bool const_ref_to_nav_
True if the reference should not be estimated.
Definition: sensor_abs_class.h:27
bool use_dynamic_meas_noise_
True if dynamic noise values from measurements should be used.
Definition: sensor_abs_class.h:29
Definition: update_sensor_abs_class.h:24
bool initial_calib_provided_
True if an initial calibration was provided.
Definition: update_sensor_abs_class.h:38
std::shared_ptr< CoreState > core_states_
Definition: update_sensor_abs_class.h:42
Eigen::VectorXd R_
Measurement noise "squared".
Definition: update_sensor_abs_class.h:32
std::shared_ptr< void > initial_calib_
Definition: update_sensor_abs_class.h:37
Chi2 chi2_
Definition: update_sensor_abs_class.h:40
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
The Pressure struct describes the raw pressure measurement used for conversion later.
Definition: pressure_conversion.h:25
Type type_
type of the measurement
Definition: pressure_conversion.h:66
double data_
measurement data
Definition: pressure_conversion.h:64
@ GAS
pressure measruement is in gas medium, e.g., air
double temperature_K_
ambient temperature when measurement data was observed
Definition: pressure_conversion.h:65