Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Try to address #25 unstable frequency #30

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Try to address #25 unstable frequency #30

wants to merge 9 commits into from

Conversation

versatran01
Copy link
Collaborator

@versatran01 versatran01 commented Aug 22, 2019

  1. Use the idea from Use the relative timestamp from the device. #28 to fix the unstable timestamp, see Unstable generated frequency #25 for details.
    Add a parameter time_alpha to compute final timestamp as
    t1 = a * dt_ros + (1-a) * dt_dev + t0
    time_alpha defaults to 0 which is the fix from Use the relative timestamp from the device. #28.
    User can check /imu/dt for the difference between 2 consecutive time stamps and /imu/dnow for the deviation from ros time.

  2. Various cleanup.

  3. Use binary group 1 only.

  4. Remove ypr publisher

Normally I would just merge this, but since there are other people using this driver, it would be nice if someone could review this PR.
@IanTheEngineer @clalancette @Triocrossing
Thanks.

@clalancette
Copy link
Collaborator

@versatran01 Thanks for the change! I was on vacation last week, but I'll take a look at it this week.

Copy link
Collaborator

@clalancette clalancette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've got quite a few comments in here, but my last one is the biggest and most important.

CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Show resolved Hide resolved
README.md Show resolved Hide resolved
pnh_.param("compensated", compensated_, false);
pnh_.param("time_alpha", time_alpha_, 0.0);
ROS_INFO("time_alpha: %f", time_alpha_);
time_alpha_ = std::max(0.0, std::min(time_alpha_, 1.0));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I understand that time_alpha needs to be between 0.0 and 1.0, but it is annoying to the user to quietly change the data behind their back. If they entered in 2.0, then they'll just quietly get 1.0, which may not be what they are expecting. I think it would be better to raise an exception and fail the constructor here.

// delta time from ros
const int64_t dt_ros = (ros_time_now - ros_time_last_).toNSec();
// filtered delta time
const int64_t dt_filtered = dt_ros * time_alpha_ + dt_dev * (1 - time_alpha_);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So time_alpha seems to be a measure of the relative "goodness" of each of the time sources. If time_alpha == 0, then we trust the delta from the IMU 100%. If time_alpha == 1, then we trust the delta from ROS time 100%. This gives us flexibility, but the two problems I see with it are:

  1. ROS time is definitely going to be wrong at times. USB can cause batching behavior where we get significantly shorter time between callbacks interrupts than we are expecting (I've seen 5ms, rather than the expected 10ms), and latency in the kernel can cause the callback to be delayed for significant amounts of time (I've seen 16ms instead of the expected 10ms). Thus, I don't think time_alpha can accurately capture these arbitrary differences.
  2. Following on from the above point, I don't see how a user would be able to tune this for accurate measurements. Other than the delta reported from the IMU, there is no data available for them to see how to tune it. And if we are depending on the delta reported by the IMU, we may as well just use that for our dt anyway.

I have a totally different suggestion here. Instead of trying to do this tuning, what if we periodically re-sync the "zero" time of both the ROS time and the IMU delta? That is, every 5 seconds (say), we re-zero them both. That means that they should never drift too far apart, but it also means that for the more common case of the delta, we are trusting the device to give us good data. Thoughts on that approach?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the re-sync idea, wouldn't this still cause jumps in timestamps (at the point of resyncing)?

From the plot in #25, it shows a time drift of 2ms / 500s. This means the drift will be 16ms after about an hour.

And since the time zero is from ros time, this is already wrong in the first place, so I don't see how one could fix this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants