Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve diff_drive_controller odometry velocity and timestep handling #1394

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

josephduchesne
Copy link

@josephduchesne josephduchesne commented Nov 27, 2024

This PR updates diff_drive odometry class to

  • consistantly use velocity where it claims to (the odometry class no longer arbitrarily swaps between position delta and velocity without comments, despite parameter and/or method names claiming to take velocity).
  • use a consistant timestep (dt) in every method that makes use of it
  • rely on diff_drive_controller to decide which timestep source to use (avoiding existing and new cases where diff_drive_controller uses nominal timestep, and odometry uses

This was requested in #271, although I took a more expansive approach since the odometry class is was at high risk of new bugs due the unclear units of variables at play.

  • The result is that the class is very slightly less efficient (but still quite trivial) due to passing around a extra double.

  • The other result is that it is no longer possible for velocity based odometry updates calculated incorrectly when the timestep fails to keep up.

To prevent position based updates from now suffering the inverse of the velocity timestep/dt mismatch, the measured delta is used exclusively for position based updates (retaining the existing behavior), while the configured timestep is used for open and closed loop velocity updates. This decision is made by diff_drive_controller, and out of scope of the odometry class.

I also added a 1s throttled warning if there is a major mismatch between measured and configured timestep (+/-20%) since this would cause a slight accumulation of integration errors on curved paths (I believe), depending on velocity, curvature and mismatch size. This could probably be expanded to a more general diagnostics WARN output, since controller/odometry updates failing to keep up can be serious.

Similar requested period/measured period mismatches may be a nuisance for open loop (which is velocity based) and closed loop velocity based updates, but the impact is likely negligible (in this class).

use velocity where it claims to, and pass timestep
in to every method that makes use of it.

This was requested in ros-controls#271.

- The result is that the class is very slightly less efficient (but
still quite trivial) due to passing around a extra double.

- The other result is that it is no longer possible for velocity based
odometry updates calculated incorrectly when the timestep fails to keep up.

To prevent position based updates from now suffering the inverse of
the velocity timestep/dt mismatch, the measured delta is used exclusively
for position based updates (retaining the existing behavior), while the
configured timestep is used for open and closed loop velocity updates.

I also added a 1s throttled warning if there is a major mismatch between
measured and configured timestep (+/-20%) since this would cause a slight
accumulation of integration errors on curved paths (I believe), depending
on velocity, curvature and mismatch size.

Similar requested period/measured period mismatches may be a nuisance for
open loop (which is velocity based) and closed loop velocity based updates,
but the impact is likely negligible (in this class).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant