Skip to content

Commit

Permalink
More stable integration of IMU twist information in the context of Li…
Browse files Browse the repository at this point in the history
…DAR odometry
  • Loading branch information
jlblancoc committed Jan 10, 2025
1 parent 471f6a2 commit d73963e
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions mola_state_estimation_simple/src/StateEstimationSimple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ void StateEstimationSimple::reset()
{
// reset:
state_ = State();

MRPT_LOG_INFO_STREAM("reset() called");
}

void StateEstimationSimple::fuse_odometry(
Expand All @@ -77,6 +79,8 @@ void StateEstimationSimple::fuse_odometry(
}
// copy:
state_.last_odom_obs = odom;

MRPT_LOG_DEBUG_STREAM("fuse_odometry: odom=" << odom.asString());
}

void StateEstimationSimple::fuse_imu(const mrpt::obs::CObservationIMU& imu)
Expand All @@ -89,22 +93,11 @@ void StateEstimationSimple::fuse_imu(const mrpt::obs::CObservationIMU& imu)
!imu.has(mrpt::obs::TIMUDataIndex::IMU_WZ))
{
MRPT_LOG_THROTTLE_INFO(5.0, "Ignoring IMU reading since it has no angular velocity data");
}

const auto stateNow = this->estimated_navstate(imu.timestamp, "frame_ignored");
if (!stateNow)
{
MRPT_LOG_INFO_FMT(
"Ignoring IMU reading at t=%f due to missing former navstate estimation.",
mrpt::Clock::toDouble(imu.timestamp));
return;
}

mrpt::poses::CPose3DPDFGaussian curPosePDF;
curPosePDF.copyFrom(stateNow->pose);

// Set new pose as current pose:
this->fuse_pose(imu.timestamp, curPosePDF, "frame_ignored");
// Do not predict a new pose for this timestamp, so we can use the last *real*
// call to fuse_pose() from an outter source.

// and now overwrite twist (wx,wy,wz) part from IMU data:
mrpt::math::TTwist3D imuReading;
Expand All @@ -118,13 +111,17 @@ void StateEstimationSimple::fuse_imu(const mrpt::obs::CObservationIMU& imu)
state_.last_twist->wx = imuReading.wx;
state_.last_twist->wy = imuReading.wy;
state_.last_twist->wz = imuReading.wz;

MRPT_LOG_DEBUG_STREAM("fuse_imu(): new twist: " << state_.last_twist->asString());
}

void StateEstimationSimple::fuse_gnss(const mrpt::obs::CObservationGPS& gps)
{
// This estimator will just ignore GPS.
// Refer to the smoother for a more versatile estimator.
(void)gps;

MRPT_LOG_DEBUG_STREAM("fuse_gnss(): ignored in this class");
}

void StateEstimationSimple::fuse_pose(
Expand All @@ -148,6 +145,12 @@ void StateEstimationSimple::fuse_pose(
return;
}

MRPT_LOG_DEBUG_STREAM("fuse_pose(): dt=" << dt << " pose=" << pose.mean);
if (state_.last_twist)
{
MRPT_LOG_DEBUG_STREAM("fuse_pose(): twist before=" << state_.last_twist->asString());
}

if (dt < params.max_time_to_use_velocity_model && state_.last_pose)
{
auto& tw = state_.last_twist.emplace();
Expand All @@ -166,6 +169,11 @@ void StateEstimationSimple::fuse_pose(
}
else { state_.last_twist.reset(); }

if (state_.last_twist)
{
MRPT_LOG_DEBUG_STREAM("fuse_pose(): twist after= " << state_.last_twist->asString());
}

// save for next iter:
state_.last_pose = pose;
state_.last_pose_obs_tim = timestamp;
Expand Down

0 comments on commit d73963e

Please sign in to comment.