mars_lib 0.1.0.2abe2576fe7f
Modular and Robust Sensor-Fusion
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
mars::AttitudeSensorClass Class Reference

#include </home/runner/work/mars_lib/mars_lib/source/mars/include/mars/sensors/attitude/attitude_sensor_class.h>

+ Inheritance diagram for mars::AttitudeSensorClass:
+ Collaboration diagram for mars::AttitudeSensorClass:

Public Member Functions

EIGEN_MAKE_ALIGNED_OPERATOR_NEW AttitudeSensorClass (const std::string &name, std::shared_ptr< CoreState > core_states, AttitudeSensorType type=AttitudeSensorType::RPY_TYPE)
 
virtual ~AttitudeSensorClass ()=default
 
AttitudeSensorStateType get_state (const std::shared_ptr< void > &sensor_data)
 
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 sensor is responsible to cast its own data type
 
void set_initial_calib (std::shared_ptr< void > calibration)
 set_initial_calib Sets the calibration of an individual sensor
 
BufferDataType Initialize (const Time &timestamp, std::shared_ptr< void >, std::shared_ptr< CoreType > latest_core_data)
 Initialize the state of an individual sensor.
 
bool CalcUpdate (const Time &timestamp, 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.
 
bool CalcUpdateRP (const Time &, const std::shared_ptr< void > &measurement, const CoreStateType &prior_core_state, const std::shared_ptr< void > &latest_sensor_data, const Eigen::MatrixXd &prior_cov, BufferDataType *new_state_data)
 
bool CalcUpdateRPY (const Time &, const std::shared_ptr< void > &measurement, const CoreStateType &prior_core_state, const std::shared_ptr< void > &latest_sensor_data, const Eigen::MatrixXd &prior_cov, BufferDataType *new_state_data)
 
AttitudeSensorStateType ApplyCorrection (const AttitudeSensorStateType &prior_sensor_state, const Eigen::MatrixXd &correction)
 
- Public Member Functions inherited from mars::SensorInterface
virtual EIGEN_MAKE_ALIGNED_OPERATOR_NEW ~SensorInterface ()=default
 

Private Attributes

AttitudeSensorType attitude_type_ { AttitudeSensorType::RPY_TYPE }
 

Additional Inherited Members

- Public Attributes inherited from mars::UpdateSensorAbsClass
EIGEN_MAKE_ALIGNED_OPERATOR_NEW int aux_states_
 
int aux_error_states_
 
int ref_to_nav_
 
Eigen::MatrixXd residual_
 
Eigen::VectorXd R_
 Measurement noise "squared".
 
Eigen::MatrixXd F_
 
Eigen::MatrixXd H_
 
Eigen::MatrixXd Q_
 
std::shared_ptr< void > initial_calib_ { nullptr }
 
bool initial_calib_provided_ { false }
 True if an initial calibration was provided.
 
Chi2 chi2_
 
std::shared_ptr< CoreStatecore_states_
 
- Public Attributes inherited from mars::SensorAbsClass
int id_ { -1 }
 
std::string name_
 Name of the individual sensor instance.
 
bool is_initialized_ { false }
 True if the sensor has been initialized.
 
bool do_update_ { true }
 True if updates should be performed with the sensor.
 
int type_ { -1 }
 Future feature, holds information such as position or orientation for highlevel decissions.
 
bool const_ref_to_nav_ { true }
 True if the reference should not be estimated.
 
bool ref_to_nav_given_ { false }
 True if the reference to the navigation frame is given by initial calibration.
 
bool use_dynamic_meas_noise_ { false }
 True if dynamic noise values from measurements should be used.
 

Constructor & Destructor Documentation

◆ AttitudeSensorClass()

EIGEN_MAKE_ALIGNED_OPERATOR_NEW mars::AttitudeSensorClass::AttitudeSensorClass ( const std::string &  name,
std::shared_ptr< CoreState core_states,
AttitudeSensorType  type = AttitudeSensorType::RPY_TYPE 
)
inline
70 {
71 name_ = name;
72 core_states_ = std::move(core_states);
73 const_ref_to_nav_ = false;
75
76 // set sensor type
77 attitude_type_ = type;
78
79 // chi2
80 switch (attitude_type_)
81 {
83 chi2_.set_dof(2);
84 break;
86 chi2_.set_dof(3);
87 break;
88 default:
89 std::cout << "Warning: [" << this->name_
90 << "] Unexpected type for AttitudeSensorClass.\n"
91 "Assuming roll-pitch-yaw measurement."
92 << std::endl;
94 chi2_.set_dof(3);
95 break;
96 }
97
98 // Sensor specific information
99 // setup_sensor_properties();
100 std::cout << "Created: [" << this->name_ << "] Sensor (type: " << attitude_type_ << ")" << std::endl;
101 }
AttitudeSensorType attitude_type_
Definition attitude_sensor_class.h:63
void set_dof(const int &value)
set_dof Set degree of freedom for the X2 distribution
std::string name_
Name of the individual sensor instance.
Definition sensor_abs_class.h:23
bool const_ref_to_nav_
True if the reference should not be estimated.
Definition sensor_abs_class.h:27
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
Chi2 chi2_
Definition update_sensor_abs_class.h:40
@ RPY_TYPE
full orientation, roll, pitch, and yaw
@ RP_TYPE
aviation attitude, roll and pitch only
+ Here is the call graph for this function:

◆ ~AttitudeSensorClass()

virtual mars::AttitudeSensorClass::~AttitudeSensorClass ( )
virtualdefault

Member Function Documentation

◆ get_state()

AttitudeSensorStateType mars::AttitudeSensorClass::get_state ( const std::shared_ptr< void > &  sensor_data)
inline
106 {
107 AttitudeSensorData data = *static_cast<AttitudeSensorData*>(sensor_data.get());
108 return data.state_;
109 }
BindSensorData< AttitudeSensorStateType > AttitudeSensorData
Definition attitude_sensor_class.h:34

◆ get_covariance()

Eigen::MatrixXd mars::AttitudeSensorClass::get_covariance ( const std::shared_ptr< void > &  sensor_data)
inlinevirtual

get_covariance Resolves a void pointer to the covariance matrix of the corresponding sensor type Each sensor is responsible to cast its own data type

Parameters
sensor_data
Returns
Covariance matrix contained in the sensor data struct

Implements mars::SensorInterface.

112 {
113 AttitudeSensorData data = *static_cast<AttitudeSensorData*>(sensor_data.get());
114 return data.get_full_cov();
115 }
+ Here is the call graph for this function:

◆ set_initial_calib()

void mars::AttitudeSensorClass::set_initial_calib ( std::shared_ptr< void >  calibration)
inlinevirtual

set_initial_calib Sets the calibration of an individual sensor

Parameters
calibration

Implements mars::SensorInterface.

118 {
119 initial_calib_ = calibration;
121 }
std::shared_ptr< void > initial_calib_
Definition update_sensor_abs_class.h:37

◆ Initialize()

BufferDataType mars::AttitudeSensorClass::Initialize ( const Time timestamp,
std::shared_ptr< void >  measurement,
std::shared_ptr< CoreType latest_core_data 
)
inlinevirtual

Initialize the state of an individual sensor.

Parameters
timestampcurrent timestamp
measurementcurrent sensor measurement
latest_core_data
Returns

Implements mars::SensorInterface.

125 {
126 // AttitudeMeasurementType measurement = *static_cast<AttitudeMeasurementType*>(sensor_data.get());
127
128 AttitudeSensorData sensor_state;
129 std::string calibration_type;
130
131 if (this->initial_calib_provided_)
132 {
133 calibration_type = "Given";
134
135 AttitudeSensorData calib = *static_cast<AttitudeSensorData*>(initial_calib_.get());
136
137 sensor_state.state_ = calib.state_;
138 sensor_state.sensor_cov_ = calib.sensor_cov_;
139 }
140 else
141 {
142 // calibration_type = "Auto";
143
144 // Eigen::Vector3d p_wp(measurement.position_);
145 // Eigen::Quaterniond q_wp(measurement.orientation_);
146
147 // Eigen::Vector3d p_wi(latest_core_data->state_.p_wi_);
148 // Eigen::Quaterniond q_wi(latest_core_data->state_.q_wi_);
149 // Eigen::Matrix3d r_wi(q_wi.toRotationMatrix());
150
151 // Eigen::Vector3d p_ip = r_wi.transpose() * (p_wp - p_wi);
152 // Eigen::Quaterniond q_ip = q_wi.conjugate() * q_wp;
153
154 // // Calibration, position / rotation imu-pose
155 // sensor_state.state_.p_ip_ = p_ip;
156 // sensor_state.state_.q_ip_ = q_ip;
157
158 // // The covariance should enclose the initialization with a 3 Sigma bound
159 // Eigen::Matrix<double, 6, 1> std;
160 // std << 1, 1, 1, (35 * M_PI / 180), (35 * M_PI / 180), (35 * M_PI / 180);
161 // sensor_state.sensor_cov_ = std.cwiseProduct(std).asDiagonal();
162 }
163
164 // Bypass core state for the returned object
165 BufferDataType result(std::make_shared<CoreType>(*latest_core_data.get()),
166 std::make_shared<AttitudeSensorData>(sensor_state));
167
168 // TODO
169 // sensor_data.ref_to_nav = 0; //obj.calc_ref_to_nav(measurement, latest_core_state);
170
171 is_initialized_ = true;
172
173 std::cout << "Info: Initialized [" << name_ << "] with [" << calibration_type << "] Calibration at t=" << timestamp
174 << std::endl;
175
177 {
178 std::cout << "Info: [" << name_ << "] Calibration(rounded):" << std::endl;
179 std::cout << "\tOrientation[deg]: ["
180 << sensor_state.state_.q_aw_.toRotationMatrix().eulerAngles(0, 1, 2).transpose() * (180 / M_PI) << " ]"
181 << std::endl;
182 }
183
184 return result;
185 }
bool is_initialized_
True if the sensor has been initialized.
Definition sensor_abs_class.h:24

◆ CalcUpdate()

bool mars::AttitudeSensorClass::CalcUpdate ( const Time timestamp,
std::shared_ptr< void >  measurement,
const CoreStateType prior_core_state_data,
std::shared_ptr< void >  latest_sensor_data,
const Eigen::MatrixXd &  prior_cov,
BufferDataType new_state_data 
)
inlinevirtual

CalcUpdate Calculates the update for an individual sensor definition.

Parameters
timestampcurrent timestamp
measurementcurrent sensor measurement
prior_core_state_data
latest_sensor_data
prior_covPrior covariance containing core, sensor and sensor cross covariance
new_state_dataUpdated state data
Returns
True if the update was successful, false if the update was rejected

Implements mars::SensorInterface.

190 {
191 switch (attitude_type_)
192 {
194 return CalcUpdateRP(timestamp, measurement, prior_core_state, latest_sensor_data, prior_cov, new_state_data);
196 return CalcUpdateRPY(timestamp, measurement, prior_core_state, latest_sensor_data, prior_cov, new_state_data);
197 default:
198 std::cout << "Error: [" << this->name_ << "] Cannot perform update (unknown type)" << std::endl;
199 return false;
200 }
201
202 return false;
203 }
bool CalcUpdateRP(const Time &, const std::shared_ptr< void > &measurement, const CoreStateType &prior_core_state, const std::shared_ptr< void > &latest_sensor_data, const Eigen::MatrixXd &prior_cov, BufferDataType *new_state_data)
Definition attitude_sensor_class.h:205
bool CalcUpdateRPY(const Time &, const std::shared_ptr< void > &measurement, const CoreStateType &prior_core_state, const std::shared_ptr< void > &latest_sensor_data, const Eigen::MatrixXd &prior_cov, BufferDataType *new_state_data)
Definition attitude_sensor_class.h:321
+ Here is the call graph for this function:

◆ CalcUpdateRP()

bool mars::AttitudeSensorClass::CalcUpdateRP ( const Time ,
const std::shared_ptr< void > &  measurement,
const CoreStateType prior_core_state,
const std::shared_ptr< void > &  latest_sensor_data,
const Eigen::MatrixXd &  prior_cov,
BufferDataType new_state_data 
)
inline
208 {
209 // Cast the sensor measurement and prior state information
210 AttitudeMeasurementType* meas = static_cast<AttitudeMeasurementType*>(measurement.get());
211 AttitudeSensorData* prior_sensor_data = static_cast<AttitudeSensorData*>(latest_sensor_data.get());
212
213 // Decompose sensor measurement
214 Eigen::Vector2d rp_meas = meas->attitude_.get_rp();
215
216 // Extract sensor state
217 AttitudeSensorStateType prior_sensor_state(prior_sensor_data->state_);
218
219 // Generate measurement noise matrix and check
220 // if noisevalues from the measurement object should be used
221 Eigen::MatrixXd R_meas_dyn;
222 if (meas->has_meas_noise && use_dynamic_meas_noise_)
223 {
224 meas->get_meas_noise(&R_meas_dyn);
225 }
226 else
227 {
228 R_meas_dyn = this->R_.asDiagonal();
229 }
230 const Eigen::Matrix<double, 2, 2> R_meas = R_meas_dyn;
231
232 const int size_of_core_state = CoreStateType::size_error_;
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);
237
238 // Calculate the measurement jacobian H
239 typedef Eigen::Matrix<double, 2, 3> Matrix23d_t;
240 Matrix23d_t I_23;
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();
246
247 // Orientation
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;
253
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;
256
257 // Assemble the jacobian for the orientation (horizontal)
258 // H_r = [Hr_pwi Hr_vwi Hr_rwi Hr_bw Hr_ba Hr_mag Hr_rim];
259 Eigen::MatrixXd H(2, Hr_pwi.cols() + Hr_vwi.cols() + Hr_rwi.cols() + Hr_bw.cols() + Hr_ba.cols() + Hr_raw.cols() +
260 Hr_rib.cols());
261 H << Hr_pwi, Hr_vwi, Hr_rwi, Hr_bw, Hr_ba, Hr_raw, Hr_rib;
262
263 // Calculate the residual z = z~ - (estimate)
264 // Orientation
265 const Eigen::Vector3d rpy_est = mars::Utils::RPYFromRotMat(R_aw * R_wi * R_ib);
266 const Eigen::Vector2d rp_est(rpy_est(0), rpy_est(1));
267 residual_ = Eigen::MatrixXd(rp_est.rows(), 1);
268 residual_ = rp_meas - rp_est;
269
270 // Perform EKF calculations
271 mars::Ekf ekf(H, R_meas, residual_, P);
272 const Eigen::MatrixXd correction = ekf.CalculateCorrection(&chi2_);
273 assert(correction.size() == size_of_full_error_state * 1);
274
275 // Perform Chi2 test
276 if (!chi2_.passed_ && chi2_.do_test_)
277 {
279 return false;
280 }
281
282 Eigen::MatrixXd P_updated = ekf.CalculateCovUpdate();
283 assert(P_updated.size() == size_of_full_error_state * size_of_full_error_state);
284 P_updated = Utils::EnforceMatrixSymmetry(P_updated);
285
286 // Apply Core Correction
287 CoreStateVector core_correction = correction.block(0, 0, CoreStateType::size_error_, 1);
288 CoreStateType corrected_core_state = CoreStateType::ApplyCorrection(prior_core_state, core_correction);
289
290 // Apply Sensor Correction
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);
293
294 // Return Results
295 // CoreState data
296 CoreType core_data;
297 core_data.cov_ = P_updated.block(0, 0, CoreStateType::size_error_, CoreStateType::size_error_);
298 core_data.state_ = corrected_core_state;
299
300 // SensorState data
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;
304
305 BufferDataType state_entry(std::make_shared<CoreType>(core_data), sensor_data);
306
308 {
309 // corrected_sensor_data.ref_to_nav = prior_ref_to_nav;
310 }
311 else
312 {
313 // TODO also estimate ref to nav
314 }
315
316 *new_state_data = state_entry;
317
318 return true;
319 }
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
Definition ekf.h:92
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
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CalcUpdateRPY()

bool mars::AttitudeSensorClass::CalcUpdateRPY ( const Time ,
const std::shared_ptr< void > &  measurement,
const CoreStateType prior_core_state,
const std::shared_ptr< void > &  latest_sensor_data,
const Eigen::MatrixXd &  prior_cov,
BufferDataType new_state_data 
)
inline
324 {
325 // Cast the sensor measurement and prior state information
326 AttitudeMeasurementType* meas = static_cast<AttitudeMeasurementType*>(measurement.get());
327 AttitudeSensorData* prior_sensor_data = static_cast<AttitudeSensorData*>(latest_sensor_data.get());
328
329 // Decompose sensor measurement
330 Eigen::Quaterniond q_meas = meas->attitude_.quaternion_;
331
332 // Extract sensor state
333 AttitudeSensorStateType prior_sensor_state(prior_sensor_data->state_);
334
335 // Generate measurement noise matrix
336 Eigen::MatrixXd R_meas_dyn;
337 if (meas->has_meas_noise && use_dynamic_meas_noise_)
338 {
339 meas->get_meas_noise(&R_meas_dyn);
340 }
341 else
342 {
343 R_meas_dyn = this->R_.asDiagonal();
344 }
345 const Eigen::Matrix<double, 3, 3> R_meas = R_meas_dyn;
346
347 const int size_of_core_state = CoreStateType::size_error_;
348 const int size_of_sensor_state = prior_sensor_state.cov_size_;
349 const int size_of_full_error_state = size_of_core_state + size_of_sensor_state;
350 const Eigen::MatrixXd P = prior_cov;
351 assert(P.size() == size_of_full_error_state * size_of_full_error_state);
352
353 // Calculate the measurement jacobian H
354 const Eigen::Matrix3d I_3 = Eigen::Matrix3d::Identity();
355 const Eigen::Matrix3d Z_3 = Eigen::Matrix3d::Zero();
356 const Eigen::Matrix3d R_wi = prior_core_state.q_wi_.toRotationMatrix();
357 // const Eigen::Matrix3d R_aw = prior_sensor_state.q_aw_.toRotationMatrix();
358 const Eigen::Matrix3d R_ib = prior_sensor_state.q_ib_.toRotationMatrix();
359
360 // Orientation
361 const Eigen::Matrix3d Hr_pwi = Z_3;
362 const Eigen::Matrix3d Hr_vwi = Z_3;
363 const Eigen::Matrix3d Hr_rwi = R_ib.transpose();
364 const Eigen::Matrix3d Hr_bw = Z_3;
365 const Eigen::Matrix3d Hr_ba = Z_3;
366
367 const Eigen::Matrix3d Hr_raw = R_ib.transpose() * R_wi.transpose();
368 const Eigen::Matrix3d Hr_rib = I_3;
369
370 // Assemble the jacobian for the orientation (horizontal)
371 // H_r = [Hr_pwi Hr_vwi Hr_rwi Hr_bw Hr_ba Hr_raw];
372 Eigen::MatrixXd H(3, Hr_pwi.cols() + Hr_vwi.cols() + Hr_rwi.cols() + Hr_bw.cols() + Hr_ba.cols() + Hr_raw.cols() +
373 Hr_rib.cols());
374 H << Hr_pwi, Hr_vwi, Hr_rwi, Hr_bw, Hr_ba, Hr_raw, Hr_rib;
375
376 // Calculate the residual z = z~ - (estimate)
377 // Orientation
378 const Eigen::Quaternion<double> q_est =
379 prior_sensor_state.q_aw_ * prior_core_state.q_wi_ * prior_sensor_state.q_ib_;
380 const Eigen::Quaternion<double> res_q = q_est.inverse() * q_meas;
381 residual_ = Eigen::MatrixXd(res_q.vec().rows(), 1);
382 residual_ << (2 * res_q.vec() / res_q.w());
383
384 // Perform EKF calculations
385 mars::Ekf ekf(H, R_meas, residual_, P);
386 const Eigen::MatrixXd correction = ekf.CalculateCorrection(&chi2_);
387 assert(correction.size() == size_of_full_error_state * 1);
388
389 // Perform Chi2 test
390 if (!chi2_.passed_ && chi2_.do_test_)
391 {
393 return false;
394 }
395
396 Eigen::MatrixXd P_updated = ekf.CalculateCovUpdate();
397 assert(P_updated.size() == size_of_full_error_state * size_of_full_error_state);
398 P_updated = Utils::EnforceMatrixSymmetry(P_updated);
399 // Apply Core Correction
400 CoreStateVector core_correction = correction.block(0, 0, CoreStateType::size_error_, 1);
401 CoreStateType corrected_core_state = CoreStateType::ApplyCorrection(prior_core_state, core_correction);
402
403 // Apply Sensor Correction
404 const Eigen::MatrixXd sensor_correction = correction.block(size_of_core_state, 0, size_of_sensor_state, 1);
405 const AttitudeSensorStateType corrected_sensor_state = ApplyCorrection(prior_sensor_state, sensor_correction);
406
407 // Return Results
408 // CoreState data
409 CoreType core_data;
410 core_data.cov_ = P_updated.block(0, 0, CoreStateType::size_error_, CoreStateType::size_error_);
411 core_data.state_ = corrected_core_state;
412
413 // SensorState data
414 std::shared_ptr<AttitudeSensorData> sensor_data(std::make_shared<AttitudeSensorData>());
415 sensor_data->set_cov(P_updated);
416 sensor_data->state_ = corrected_sensor_state;
417
418 BufferDataType state_entry(std::make_shared<CoreType>(core_data), sensor_data);
419
421 {
422 // corrected_sensor_data.ref_to_nav = prior_ref_to_nav;
423 }
424 else
425 {
426 // TODO also estimate ref to nav
427 }
428
429 *new_state_data = state_entry;
430
431 return true;
432 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ApplyCorrection()

AttitudeSensorStateType mars::AttitudeSensorClass::ApplyCorrection ( const AttitudeSensorStateType prior_sensor_state,
const Eigen::MatrixXd &  correction 
)
inline
436 {
437 // state + error state correction
438 // with quaternion from small angle approx -> new state
439
440 // q_aw [0,1,2] 0:2
441 // q_ib [3,4,5] 3:5
442
443 AttitudeSensorStateType corrected_sensor_state;
444
445 // select correct correction block
446 Eigen::Vector3d q_aw_correction, q_ib_correction;
447 switch (attitude_type_)
448 {
450 q_aw_correction << correction(0), correction(1), 0;
451 q_ib_correction << correction(2), correction(3), 0;
452 break;
454 q_aw_correction = correction.block(0, 0, 3, 1);
455 q_ib_correction = correction.block(3, 0, 3, 1);
456 break;
457 default:
458 std::cout << "Error: [" << this->name_ << "] Cannot perform correction (unknown type)" << std::endl;
459 q_aw_correction = Eigen::Vector3d::Zero();
460 q_ib_correction = Eigen::Vector3d::Zero();
461 break;
462 }
463
464 corrected_sensor_state.q_aw_ = Utils::ApplySmallAngleQuatCorr(prior_sensor_state.q_aw_, q_aw_correction);
465 corrected_sensor_state.q_ib_ = Utils::ApplySmallAngleQuatCorr(prior_sensor_state.q_ib_, q_ib_correction);
466
467 return corrected_sensor_state;
468 }
static Eigen::Quaterniond ApplySmallAngleQuatCorr(const Eigen::Quaterniond &q_prior, const Eigen::Vector3d &correction)
ApplySmallAngleQuatCorr.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ attitude_type_

AttitudeSensorType mars::AttitudeSensorClass::attitude_type_ { AttitudeSensorType::RPY_TYPE }
private

The documentation for this class was generated from the following file: