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

An extended Kalman filter that fuses everything a small differential drive robot senses: wheel encoders, a gyroscope, infrared elements and a camera that see a line on the floor, and ultrasonic range sensors. More...

#include <diff_drive_ekf.h>

Classes

struct  Parameters
struct  Pose
struct  RangeSensor
 Where an ultrasonic sensor is on the robot, relative to the centre of the axle, and what it hears. More...

Public Member Functions

 DiffDriveEKF (const DiffDriveMap &map, const Pose &start, const Parameters &parameters, const std::array< real_t, 3 > &start_sigma={0.02, 0.02, 0.005})
void predict (real_t distance, real_t gyro_z, real_t dt)
 Predict over dt [s] in which the encoders say the robot drove distance [m] and the gyroscope read gyro_z [rad/s].
EKFUpdateResult update_line (const std::vector< std::array< real_t, 2 > > &points, real_t sigma)
 Correct with points where the line is, relative to the centre of the axle [m], forward and to the left, each with the standard deviation sigma [m].
EKFUpdateResult update_range (const RangeSensor &sensor, real_t measured)
 Correct with the reading [m] of a range sensor. A reading at the sensor's max_range, no echo, or where the map has nothing in range, is not used.
real_t predicted_range (const RangeSensor &sensor, const Pose &pose) const
 What the sensor should read with the robot at pose.
Pose pose () const
real_t gyro_bias () const
const DynMat< real_t > & covariance () const
 The covariance of (x, y, yaw, bias).
const Parameters & parameters () const noexcept
const DiffDriveMap & map () const noexcept

Detailed Description

An extended Kalman filter that fuses everything a small differential drive robot senses: wheel encoders, a gyroscope, infrared elements and a camera that see a line on the floor, and ultrasonic range sensors.

The encoders and the gyroscope predict, see DiffDriveGyroModel; on their own they drift, as dead reckoning does. The other sensors correct, against a DiffDriveMap:

  • the line: a point where the infrared elements or the camera see the line, relative to the robot, should be on the track. Its signed distance to the track, \(h(x)\), is measured as 0. Across the line this fixes the position, and with points at different distances ahead, the camera's, the heading too; along the line it says nothing;
  • ranges: an ultrasonic sensor at a known place on the robot should measure the shortest of its rays to the walls and boxes of the map, cast across its beam as the sensor hears them. Ahead and behind along a straight this fixes the position along the track.

Every update goes through the gate of ExtendedKalmanFilter: a measurement that the estimate cannot explain, such as an echo from something not on the map, is not used. The Jacobians of the measurements are worked out by central differences.

Constructor & Destructor Documentation

◆ DiffDriveEKF()

bitsim::estimation::DiffDriveEKF::DiffDriveEKF ( const DiffDriveMap & map,
const Pose & start,
const Parameters & parameters,
const std::array< real_t, 3 > & start_sigma = {0.02, 0.02, 0.005} )
Parameters
mapWhat the robot knows of its world
startWhere it starts, as it is placed
parametersThe noises and the gate
start_sigmaThe standard deviations of the start: position [m], heading [rad] and gyroscope bias [rad/s]

Member Function Documentation

◆ covariance()

The covariance of (x, y, yaw, bias).

◆ gyro_bias()

◆ map()

const DiffDriveMap & bitsim::estimation::DiffDriveEKF::map ( ) const
inlinenoexcept

◆ parameters()

const Parameters & bitsim::estimation::DiffDriveEKF::parameters ( ) const
inlinenoexcept

◆ pose()

◆ predict()

Predict over dt [s] in which the encoders say the robot drove distance [m] and the gyroscope read gyro_z [rad/s].

◆ predicted_range()

What the sensor should read with the robot at pose.

◆ update_line()

EKFUpdateResult bitsim::estimation::DiffDriveEKF::update_line ( const std::vector< std::array< real_t, 2 > > & points,
real_t sigma )

Correct with points where the line is, relative to the centre of the axle [m], forward and to the left, each with the standard deviation sigma [m].

◆ update_range()

EKFUpdateResult bitsim::estimation::DiffDriveEKF::update_range ( const RangeSensor & sensor,
real_t measured )

Correct with the reading [m] of a range sensor. A reading at the sensor's max_range, no echo, or where the map has nothing in range, is not used.


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