bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
bitsim::estimation::DiffDriveOdometry Class Reference

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

Detailed Description

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.

Constructor & Destructor Documentation

◆ DiffDriveOdometry()

bitsim::estimation::DiffDriveOdometry::DiffDriveOdometry ( real_t wheel_radius,
real_t axle_length )
Parameters
wheel_radiusThe radius of the wheels [m]
axle_lengthThe distance between the wheels [m]

Member Function Documentation

◆ axle_length()

real_t bitsim::estimation::DiffDriveOdometry::axle_length ( ) const
inlinenoexcept

◆ distance()

real_t bitsim::estimation::DiffDriveOdometry::distance ( ) const
inlinenoexcept
Returns
The length of the path driven since reset() [m]. Turning on the spot adds nothing

◆ pose()

const Pose & bitsim::estimation::DiffDriveOdometry::pose ( ) const
inlinenoexcept

◆ reset()

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].

◆ update() [1/2]

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.

Parameters
left_angleThe angle of the left wheel now [rad]
right_angleThe angle of the right wheel now [rad]

◆ update() [2/2]

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.

Parameters
left_angleThe angle of the left wheel now [rad]
right_angleThe angle of the right wheel now [rad]
headingThe heading now, for example from a gyroscope [rad]

◆ wheel_radius()

real_t bitsim::estimation::DiffDriveOdometry::wheel_radius ( ) const
inlinenoexcept

The documentation for this class was generated from the following files: