Khepera III Toolbox/The Toolbox/Modules/odometry track

The odometry_track module implements the odometry equations for a differential-drive vehicle and allows to track the robot's position (, , ) over time. Fosamax Class Action blog

Synopsis

edit
// Instantiate a track structure
struct sOdometryTrack ot;

// Initialize the module
odometry_track_init();

// Start tracking and set initial position
odometry_track_start(&ot);
ot.result.x = 0;
ot.result.y = 0;
ot.result.theta = 0;

// Main loop
while (1) {
    ...

    // Call this frequently to update the position estimate
    odometry_track_step(&ot);
    ... = ot.result.x;
    ... = ot.result.y;
    ... = ot.result.theta;

    ...
}

Description

edit

odometry_track_start sets up a sOdometryTrack structure and reads the odometry calibration values from /etc/khepera/odometry. If that file is not available (or does not contain a valid configuration), default values are used. After calling this function, the initial position can be changed by modifying the result fields of the structure. odometry_track_start also reads the current motor positions and should therefore be called immediately before entering the main loop.

Inside the main loop, odometry_track_step is called to read the new motor positions and update the position estimate in the result fields.

Calibration

edit

The default calibration values should give acceptable results on most Khepera III robots. Through a calibration procedure, the precision can be significantly improved, however.

Providing Motor Positions from Other Sources

edit

The functions mentioned above read the motor positions automatically with the khepera3_drive_getposition function. If this is not desired, the functions odometry_track_start_pos and odometry_track_step_pos can be used.