libnxter  0.1
Data Structures | Functions
Odometer2.nxc File Reference

Implements odometery for 2 wheels drive robot base using motor tachometers. More...

#include "Debug.nxc"
#include "Vector.nxc"
#include "Map.nxc"
Include dependency graph for Odometer2.nxc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Odometer2
 Odometer class for 2 wheels drive robot base that desribes wheel anatomy and positional integration. More...
 

Functions

safecall void Odometer2Step (Odometer2 &wheelBase)
 Updates current odometry position. More...
 
void Odometer2Init (Odometer2 &wheelBase, int leftWheelMotor, int rightWheelMotor, int axialLength, int wheelDiameter, int gearRatio, int initialLeftTacho, int initialRightTacho, bool enableDPosition, bool enableDeltaPosition)
 Initializes a 2 wheel drive odometer. More...
 
void Odometer2GetCumulativePosition (Odometer2 odometer, Vector &retPosition)
 Gets current cumulative position; position relative to the initial robot position (usually origin in world coordinate)
 
long Odometer2GetCumulativeSamplesCount (Odometer2 odometer)
 Gets the total number of sample counts used in cumulative position integration.
 
void Odometer2GetDeltaPosition (Odometer2 odometer, Vector &retPosition)
 Gets delta position integration; current position relative to the position when drift was corrected and delta cleared.
 
long Odometer2GetDeltaSamplesCount (Odometer2 odometer)
 Gets samples count used in current deta integration.
 
void Odometer2SetDriftCorrection (Odometer2 odometer, Vector &correction, Vector &retDeltaPosition)
 Corrects odometery drift at the position when last drift was corrected. More...
 

Detailed Description

Implements odometery for 2 wheels drive robot base using motor tachometers.

It maintains an integration of robot position based on peridic samples of tacho counts. Once the odometer is initialized, odometer2Step() needs to be called at regular interval (does not have to be precise intervals).

Definition in file Odometer2.nxc.

Function Documentation

void Odometer2Init ( Odometer2 wheelBase,
int  leftWheelMotor,
int  rightWheelMotor,
int  axialLength,
int  wheelDiameter,
int  gearRatio,
int  initialLeftTacho,
int  initialRightTacho,
bool  enableDPosition,
bool  enableDeltaPosition 
)

Initializes a 2 wheel drive odometer.

leftWheelMotor and rightWheelMotor are the left wheel and right wheel motors, wheelDiameter is the diameter of the wheels (in mm), gearRatio is the ratio of wheel rotational angle per tacho count (scaled by 100), initialLeftTacho and initialRightTahoc are the initial tacho counts. If enableDPosition is set true, it also maintains dx of current step, i.e. change in position since last step. If enableDeltaPosition is enabled, it also maintains deltaX, which is the position changed since last deta was cleared.

Definition at line 170 of file Odometer2.nxc.

References Odometer2::axialLength, Odometer2::gearRatio, Odometer2::leftWheelMotor, Odometer2::rightWheelMotor, VectorInit(), and Odometer2::wheelDiameter.

void Odometer2SetDriftCorrection ( Odometer2  odometer,
Vector correction,
Vector retDeltaPosition 
)
inline

Corrects odometery drift at the position when last drift was corrected.

The given correction vector is considered the corrected robot position at the time when delta was cleared (last drift correction). So, corrected commulative position is this vector plus the delta position. Current delta position is properly translated and added to corrected position to get current cumulative position. Delta is clear after the drift correction and its last value passed to retDeltaPosition.

Definition at line 249 of file Odometer2.nxc.

References Vector::theta, VectorGetDistance(), VectorInit(), and VectorTranslate().

safecall void Odometer2Step ( Odometer2 wheelBase)

Updates current odometry position.

Computes the amount by which wheel base moved from the change in tacho counts of its two motors and updates its intergral states.

This function should be called at regular intervals, not neccessarily at precise intervals, to keep odometer up to date. It firsts computes current change in position since last step (dx) and updates commulative and detla position integrals.

Definition at line 93 of file Odometer2.nxc.

References Odometer2::axialLength, Odometer2::gearRatio, Odometer2::leftWheelMotor, Odometer2::rightWheelMotor, Vector::theta, Odometer2::wheelDiameter, Vector::x, and Vector::y.

Referenced by VehicleSteerToAngle(), and VehicleStep().