23 #include "Eigen/Geometry" 30 #include "glog/logging.h" 33 namespace kalman_filter {
40 const Eigen::Quaterniond orientation =
48 CHECK_LT(rotation_vector.norm(), M_PI / 2.)
49 <<
"Sigma point is far from the mean, recovered delta may be incorrect.";
50 const Eigen::Quaterniond rotation =
52 const Eigen::Vector3d new_orientation =
63 const Eigen::Quaterniond origin_orientation =
68 const Eigen::Quaterniond target_orientation =
73 const Eigen::Vector3d rotation =
75 origin_orientation.inverse() * target_orientation);
84 const double delta_t) {
85 CHECK_GT(delta_t, 0.);
117 Eigen::Matrix<double, 6, 1>::Zero(), pose_and_covariance.
covariance);
118 Eigen::Matrix<double, 6, 6> linear_transform;
119 linear_transform << transform.
rotation().matrix(), Eigen::Matrix3d::Zero(),
120 Eigen::Matrix3d::Zero(), transform.
rotation().matrix();
121 return {transform * pose_and_covariance.
pose,
122 (linear_transform * distribution).GetCovariance()};
127 proto::PoseTrackerOptions options;
128 options.set_position_model_variance(
129 parameter_dictionary->
GetDouble(
"position_model_variance"));
130 options.set_orientation_model_variance(
131 parameter_dictionary->
GetDouble(
"orientation_model_variance"));
132 options.set_velocity_model_variance(
133 parameter_dictionary->
GetDouble(
"velocity_model_variance"));
134 options.set_imu_gravity_time_constant(
135 parameter_dictionary->
GetDouble(
"imu_gravity_time_constant"));
136 options.set_imu_gravity_variance(
137 parameter_dictionary->
GetDouble(
"imu_gravity_variance"));
138 options.set_num_odometry_states(
140 CHECK_GT(options.num_odometry_states(), 0);
145 State initial_state = State::Zero();
149 StateCovariance initial_covariance = 1e-9 * StateCovariance::Identity();
158 imu_tracker_(options.imu_gravity_time_constant(), time),
173 static_assert(
kMapPositionX == 0,
"Cannot extract PoseCovariance.");
174 static_assert(
kMapPositionY == 1,
"Cannot extract PoseCovariance.");
175 static_assert(
kMapPositionZ == 2,
"Cannot extract PoseCovariance.");
180 covariance->block<2, 2>(3, 3) +=
181 options_.imu_gravity_variance() * Eigen::Matrix2d::Identity();
185 const double delta_t)
const {
189 model_noise.diagonal() <<
191 options_.position_model_variance() * delta_t,
192 options_.position_model_variance() * delta_t,
193 options_.position_model_variance() * delta_t,
196 options_.orientation_model_variance() * delta_t,
197 options_.orientation_model_variance() * delta_t,
198 options_.orientation_model_variance() * delta_t,
201 options_.velocity_model_variance() * delta_t,
202 options_.velocity_model_variance() * delta_t,
203 options_.velocity_model_variance() * delta_t;
210 CHECK_LE(
time_, time);
216 [
this, delta_t](
const State& state) ->
State {
217 return ModelFunction(state, delta_t);
244 Eigen::Matrix<double, 6, 1>::Zero(), covariance);
247 [
this, &
pose](
const State& state) -> Eigen::Matrix<double, 6, 1> {
249 const Eigen::Vector3d delta_orientation =
252 const Eigen::Vector3d delta_translation =
254 Eigen::Matrix<double, 6, 1> return_value;
255 return_value << delta_translation, delta_orientation;
270 previous_odometry_state.odometer_pose.
inverse() * odometer_pose;
272 previous_odometry_state.state_pose * delta;
301 const double rotational_variance) {
302 const Eigen::Matrix3d translational =
303 Eigen::Matrix3d::Identity() * translational_variance;
304 const Eigen::Matrix3d rotational =
305 Eigen::Matrix3d::Identity() * rotational_variance;
309 translational, Eigen::Matrix3d::Zero(),
310 Eigen::Matrix3d::Zero(), rotational;
PoseCovariance covariance
void Observe(std::function< Eigen::Matrix< FloatType, K, 1 >(const StateType &)> h, const GaussianDistribution< FloatType, K > &delta)
PoseTracker(const proto::PoseTrackerOptions &options, common::Time time)
void AddImuLinearAccelerationObservation(common::Time time, const Eigen::Vector3d &imu_linear_acceleration)
int GetNonNegativeInt(const string &key)
void AddOdometryState(const OdometryState &odometry_state)
proto::PoseTrackerOptions CreatePoseTrackerOptions(common::LuaParameterDictionary *const parameter_dictionary)
const mapping::OdometryStateTracker::OdometryStates & odometry_states() const
void GetPoseEstimateMeanAndCovariance(common::Time time, transform::Rigid3d *pose, PoseCovariance *covariance)
const OdometryStates & odometry_states() const
double GetDouble(const string &key)
const Eigen::Matrix< T, N, 1 > & GetMean() const
Eigen::Matrix< double, 6, 6 > PoseCovariance
UniversalTimeScaleClock::time_point Time
const OdometryState & newest() const
Eigen::Quaterniond orientation() const
KalmanFilter::StateType State
void Predict(common::Time time)
static Distribution KalmanFilterInit()
PoseCovariance BuildPoseCovariance(const double translational_variance, const double rotational_variance)
void AddPoseObservation(common::Time time, const transform::Rigid3d &pose, const PoseCovariance &covariance)
void AddImuLinearAccelerationObservation(const Eigen::Vector3d &imu_linear_acceleration)
Distribution GetBelief(common::Time time)
mapping::ImuTracker imu_tracker_
KalmanFilter kalman_filter_
void Predict(std::function< StateType(const StateType &)> g, const GaussianDistribution< FloatType, N > &epsilon)
void AddImuAngularVelocityObservation(common::Time time, const Eigen::Vector3d &imu_angular_velocity)
void AddImuAngularVelocityObservation(const Eigen::Vector3d &imu_angular_velocity)
const GaussianDistribution< FloatType, N > & GetBelief() const
double ToSeconds(const Duration duration)
common::Time time() const
Eigen::Matrix< double, kDimension, kDimension > StateCovariance
mapping::OdometryStateTracker odometry_state_tracker_
const Eigen::Matrix< T, N, N > & GetCovariance() const
const Distribution BuildModelNoise(double delta_t) const
const proto::PoseTrackerOptions options_
void AddOdometerPoseObservation(common::Time time, const transform::Rigid3d &pose, const PoseCovariance &covariance)
GaussianDistribution< double, kDimension > Distribution
void Advance(common::Time time)
GaussianDistribution< T, N > operator*(const Eigen::Matrix< T, N, M > &lhs, const GaussianDistribution< T, M > &rhs)
std::deque< OdometryState > OdometryStates
transform::Rigid3d RigidFromState(const PoseTracker::State &state)