17 #ifndef POSE_MEASUREMENTMANAGER_H
18 #define POSE_MEASUREMENTMANAGER_H
26 #include <msf_updates/pose_sensor_handler/pose_sensorhandler.h>
27 #include <msf_updates/pose_sensor_handler/pose_measurement.h>
28 #include <msf_updates/SinglePoseSensorConfig.h>
30 namespace msf_pose_sensor {
32 typedef msf_updates::SinglePoseSensorConfig
Config_T;
37 msf_updates::EKFState> {
38 typedef PoseSensorHandler<msf_updates::pose_measurement::PoseMeasurement,
40 friend class PoseSensorHandler<msf_updates::pose_measurement::PoseMeasurement,
48 bool distortmeas =
false;
71 shared_ptr<msf_core::IMUHandler_ROS<msf_updates::EKFState> >
imu_handler_;
83 config.pose_noise_meas_q);
85 if ((level & msf_updates::SinglePoseSensor_INIT_FILTER)
86 && config.core_init_filter ==
true) {
87 init(config.pose_initial_scale);
88 config.core_init_filter =
false;
91 if ((level & msf_updates::SinglePoseSensor_SET_HEIGHT)
92 && config.core_set_height ==
true) {
93 Eigen::Matrix<double, 3, 1>
p =
pose_handler_->getPositionMeasurement();
96 "No measurements received yet to initialize position. Height init "
100 double scale = p[2] / config.core_height;
102 config.core_set_height =
false;
106 void init(
double scale)
const {
107 Eigen::Matrix<double, 3, 1>
p,
v,
b_w,
b_a, g, w_m, a_m,
p_ic, p_vc,
p_wv;
108 Eigen::Quaternion<double>
q,
q_wv,
q_ic, q_cv;
129 "initial measurement pos:["<<p_vc.transpose()<<
"] orientation: "<<
STREAMQUAT(q_cv));
132 if (p_vc.norm() == 0)
134 "No measurements received yet to initialize position - using [0 0 0]");
137 "No measurements received yet to initialize attitude - using [1 0 0 0]");
139 ros::NodeHandle pnh(
"~");
140 pnh.param(
"pose_sensor/init/p_ic/x", p_ic[0], 0.0);
141 pnh.param(
"pose_sensor/init/p_ic/y", p_ic[1], 0.0);
142 pnh.param(
"pose_sensor/init/p_ic/z", p_ic[2], 0.0);
144 pnh.param(
"pose_sensor/init/q_ic/w", q_ic.w(), 1.0);
145 pnh.param(
"pose_sensor/init/q_ic/x", q_ic.x(), 0.0);
146 pnh.param(
"pose_sensor/init/q_ic/y", q_ic.y(), 0.0);
147 pnh.param(
"pose_sensor/init/q_ic/z", q_ic.z(), 0.0);
154 q = (q_ic * q_cv.conjugate() *
q_wv).conjugate();
158 p = p_wv + q_wv.conjugate().toRotationMatrix() * p_vc / scale
159 - q.toRotationMatrix() *
p_ic;
163 shared_ptr < msf_core::MSF_InitMeasurement<EKFState_T>
172 Eigen::Matrix<double, 1, 1>::Constant(scale));
179 meas->get_w_m() = w_m;
180 meas->get_a_m() = a_m;
181 meas->time = ros::Time::now().toSec();
191 Eigen::Matrix<double, 1, 1> scale;
200 const msf_core::Vector3 nqwvv = msf_core::Vector3::Constant(
202 const msf_core::Vector3 npwvv = msf_core::Vector3::Constant(
204 const msf_core::Vector3 nqicv = msf_core::Vector3::Constant(
206 const msf_core::Vector3 npicv = msf_core::Vector3::Constant(
208 const msf_core::Vector1 n_L = msf_core::Vector1::Constant(
216 (dt * nqwvv.cwiseProduct(nqwvv)).asDiagonal();
218 (dt * npwvv.cwiseProduct(npwvv)).asDiagonal();
220 (dt * nqicv.cwiseProduct(nqicv)).asDiagonal();
222 (dt * npicv.cwiseProduct(npicv)).asDiagonal();
234 Eigen::Matrix<double, EKFState_T::nErrorStatesAtCompileTime, 1>& correction)
const {
241 Eigen::Matrix<double, EKFState_T::nErrorStatesAtCompileTime, 1>& correction)
const {
249 <<
". Correcting to 0.1");
250 Eigen::Matrix<double, 1, 1> L_;