|
bitsim
Model, simulate, estimate and control robots in C++
|
Dead reckoning for a differential drive robot from its wheel encoders. More...
#include <diff_drive_odometry.h>
Classes | |
| struct | Pose |
| A pose in the plane: the point halfway between the wheels and the heading from the x axis [m, m, rad]. More... | |
Public Member Functions | |
| DiffDriveOdometry (real_t wheel_radius, real_t axle_length) | |
| void | reset (const Pose &pose, real_t left_angle, real_t right_angle) |
| Start from a pose, with the wheels at the given angles [rad]. | |
| const Pose & | update (real_t left_angle, real_t right_angle) |
| Move the pose by what the wheels turned since the last update, heading included. | |
| const Pose & | update (real_t left_angle, real_t right_angle, real_t heading) |
| Move the pose by the distance the wheels drove, along a heading measured otherwise. | |
| const Pose & | pose () const noexcept |
| real_t | distance () const noexcept |
| real_t | wheel_radius () const noexcept |
| real_t | axle_length () const noexcept |
Dead reckoning for a differential drive robot from its wheel encoders.
Between two updates the left and right wheels turn by \(\Delta\theta_L\) and \(\Delta\theta_R\), so with wheel radius \(r\) and the wheels \(L\) apart the robot drives and turns by
\[\Delta s = \frac{r (\Delta\theta_L + \Delta\theta_R)}{2}, \qquad \Delta\psi = \frac{r (\Delta\theta_R - \Delta\theta_L)}{L} \]
and its pose moves along the heading halfway through the step:
\[x \mathrel{+}= \Delta s \cos\bar\psi, \quad y \mathrel{+}= \Delta s \sin\bar\psi, \quad \bar\psi = \psi + \Delta\psi / 2 \]
The heading can come from the wheels too, update(left, right), or from another sensor such as a gyroscope, update(left, right, heading). Wheels that slip, or a radius or axle length that is a little off, turn into errors of the heading that grow without bound; a gyroscope does better for heading.
| bitsim::estimation::DiffDriveOdometry::DiffDriveOdometry | ( | real_t | wheel_radius, |
| real_t | axle_length ) |
| wheel_radius | The radius of the wheels [m] |
| axle_length | The distance between the wheels [m] |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
| void bitsim::estimation::DiffDriveOdometry::reset | ( | const Pose & | pose, |
| real_t | left_angle, | ||
| real_t | right_angle ) |
Start from a pose, with the wheels at the given angles [rad].
| const DiffDriveOdometry::Pose & bitsim::estimation::DiffDriveOdometry::update | ( | real_t | left_angle, |
| real_t | right_angle ) |
Move the pose by what the wheels turned since the last update, heading included.
| left_angle | The angle of the left wheel now [rad] |
| right_angle | The angle of the right wheel now [rad] |
| const DiffDriveOdometry::Pose & bitsim::estimation::DiffDriveOdometry::update | ( | real_t | left_angle, |
| real_t | right_angle, | ||
| real_t | heading ) |
Move the pose by the distance the wheels drove, along a heading measured otherwise.
| left_angle | The angle of the left wheel now [rad] |
| right_angle | The angle of the right wheel now [rad] |
| heading | The heading now, for example from a gyroscope [rad] |
|
inlinenoexcept |