Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Drive Class Reference

#include <Drive.h>

List of all members.


Detailed Description

This class provides methods to control the robot drive. The class is designed as a singleton class. This is to ensure that the drive initialization process is only executed once as multiple initializations will result in errors. So at any given time there is at most one instance of the class. The method Drive::getDrive() is used to access that instance. If not otherwise indicated the drive command are non-blocking. I.e. the method returns once the drive command has been passed to the robot drive. Only few methods are blocking and wait till the successful execution of the drive command before they return.
Author:
Jia L. Du


Public Member Functions

bool initialize ()
void setStandardSpeed (double speed, double omega)
void setPosition (double x, double y, double phi)
void getPosition (double &x, double &y, double &phi)
void driveWith (double speed, double omega)
void drive (double distance)
void driveCircle (double radius, double angle)
bool driveTo (double x, double y)
bool driveTo (double x, double y, double phi)
void turnRight (double angle)
void turnLeft (double angle)
void turnTo (double angle)
bool done ()
void wait ()
bool stalled ()
double getRotationAngleTo (double pointX, double pointY)
double getRotationAngle (double baseX, double baseY, double pointX, double pointY, double phi)
void driveCurveTo (double x, double y)
void turn (double angle)
void turnLeft ()
void turnRight ()
void driveCurve (double distanceOnCurve, double deltaPhi)
void stop ()
void driveStraight ()
void backup ()
double distanceTo (double x, double y)
bool commandCompleted ()
void local2global (double robotX, double robotY, double robotPhi, double localX, double localY, double &globalX, double &globalY)

Static Public Member Functions

Drive * getDrive ()

Protected Member Functions

 Drive ()
 ~Drive ()
bool release ()

Private Attributes

VWHandle vwDriveHandle
double standardSpeed
double standardOmega

Static Private Attributes

Drive drives [NUMBER_OF_ROBOTS]


Constructor & Destructor Documentation

Drive::Drive   [protected]
 

Drive::~Drive   [protected]
 


Member Function Documentation

void Drive::backup  
 

Makes robot backup with standard speed until a new drive command is issued

See also:
standardSpeed

bool Drive::commandCompleted  
 

After issuing a new drive command this method can be called to observe its execution. If the drive command is completed successfully true is returned. If the drive stalls during execution the drive is stopped and false is returned

Returns:
true if drive command completed successfully

double Drive::distanceTo double    x,
double    y
 

Calculates the distance from the current robot position to the passed point

Returns:
distance in meter

bool Drive::done  
 

Used to check whether the last driving command has terminated. Attention: if you use any commands that have no termination criterion, e.g. driveWith, driveStraight, backup, ... this method will return false even if the robot is still in motion!

Returns:
true if no driving command active

void Drive::drive double    distance
 

Lets the robot drive straight the given distance

Parameters:
distance The distance to drive

void Drive::driveCircle double    radius,
double    angle
 

Lets the robot drive in circles

Parameters:
radius The radius of the circle to drive along
angle How far the robot is to drive on the circle (e.g. 180 degrees means half a circle)

void Drive::driveCurve double    distanceOnCurve,
double    deltaPhi
 

Drives a curve segment of length distanceOnCurve with overall vehicle turn of deltaPhi. standardSpeed is used as driving speed

Parameters:
distanceOnCurve The total distance that will be covered driving the curve
deltaPhi By how much the robot should have turned after completion of the curve (e.g. 180 degrees means half a circle)
See also:
standardSpeed

void Drive::driveCurveTo double    x,
double    y
 

Drives to the passed position in a curve. If the angle from the current position to the point is 0 it drives straight if the angle to the point is >= 135 then it turns to the point and drives straight

Parameters:
x x coordinate of the point to drive to
y y coordinate of the point to drive to

void Drive::driveStraight  
 

Makes robot drive straight with standard speed until a new drive command is issued

See also:
standardSpeed

bool Drive::driveTo double    x,
double    y,
double    phi
 

Drives the robot to the indicated point. The robot turns into the direction of the point and drives to the point in a straight line. Then it turns to the demanded angle. This is a blocking call, it returns only after completion of the driving sequence

Parameters:
x x value of the position to drive to
y y value of the position to drive to
phi angle to turn to at the destination point
Returns:
true if position successfully reached

bool Drive::driveTo double    x,
double    y
 

Drives the robot to the indicated point. The robot turns into the direction of the point and drives to the point in a straight line. This is a blocking call, it returns only after completion of the driving sequence

Parameters:
x x value of the position to drive to
y y value of the position to drive to
Returns:
true if position successfully reached

void Drive::driveWith double    speed,
double    omega
 

Lets the robot drive with the given speed and omega until a new drive or turn command is given.

Parameters:
speed The speed to drive with
omega The speed to turn with (degree/second)

Drive * Drive::getDrive   [static]
 

This method is used to get the instance of this singleton class

Returns:
A pointer to the instance

void Drive::getPosition double &    x,
double &    y,
double &    phi
 

Returns the current position of the robot

Parameters:
x The x value of the robot position
y The y value of the robot position
phi The angle (in degree) of the robot position

double Drive::getRotationAngle double    baseX,
double    baseY,
double    pointX,
double    pointY,
double    phi
 

Calculates the angle of an vector (base and point), adjusted by an angle phi. Example: if you pass (0.0, 0.0, 1.0, 1.0, 0.0) the vector has an angle of -45.0 degrees in the robot coordinate system. Example: if your robot's current orientation is + 90 degrees you can pass (0.0, 0.0, 1.0, 1.0, 90.0) and you will get -135 as result. So you know you have to turn by -135 to face -45

Parameters:
baseX x coordinate of the vector's base point
baseY y coordinate of the vector's base point
pointX x coordinate of the point the vector's pointing to
pointY y coordinate of the point the vector's pointing to
phi adjust the vector's angle by phi (i.e. phi is subtracted from the vector's angle)
Returns:
The angle that the robot has to turn to face the passed point (in degree, between (-180, 180])

double Drive::getRotationAngleTo double    pointX,
double    pointY
 

Calculates the rotation angle from the current robot position (x,y,phi) to a point. Example: if your robot's current orientation is +0 degrees and you pass (1.0, 1.0) you will get -45 as result. So you know you have to turn by -45 to face (1,1) Example: if your robot's current orientation is + 90 degrees and you pass (1.0, 1.0) you will get -135 as result. So you know you have to turn by -135 to face (1,1)

Parameters:
pointX x coordinate of the point we want to turn to
pointY y coordinate of the point we want to turn to
Returns:
The angle that the robot has to turn to face the passed point (in degree, between (-180, 180])

bool Drive::initialize  
 

Initializes the drive for usage. Should automatically be called by the constructor. But as the EyeSim simulator is not able to execute RoBIOS library functions in class constructors, we have declared this method as public and need to call this method manually in main

Returns:
true if successful

void Drive::local2global double    robotX,
double    robotY,
double    robotPhi,
double    localX,
double    localY,
double &    globalX,
double &    globalY
 

Converts a vector from local coordinates (i.e. relative to a robot position) to global coordinates (i.e. relative to (0,0))

Parameters:
robotX x position of robot
robotY y position of robot
robotPhi x phi of robot
localX x coordinate of vector relative to passed robot position
localY y coordinate of vector relative to passed robot position
globalX x coordinate of vector relative to (0,0)
globalY y coordinate of vector relative to (0,0)

bool Drive::release   [protected]
 

Releases the drive after usage. Is automatically called by the destructor

Returns:
true if successful

void Drive::setPosition double    x,
double    y,
double    phi
 

Changes the coordinate system of the robot

Parameters:
x The x value of the robot in the new coordinate system
y The y value of the robot in the new coordinate system
phi The angle (in degree) of the robot in the new coordinate system

void Drive::setStandardSpeed double    speed,
double    omega
 

Used to set the standard speed and the standard turning speed that will be used for the driving commands

Parameters:
speed The standard speed that is to be used (in meter per second)
omega The standard turning speed that is to be used (in degree per second)

bool Drive::stalled  
 

Checks whether the robot has hit an object and at least one of the wheels is blocking. Because the stalled information is not always correct when using real robots (for example stalled is true when the robot is just starting up) this method uses an internal counter. Only if a certain threshold is exceeded this method will return true. To reset the counter it is advised to always call Drive::stop if the drive was stalled before

Returns:
true if at least one of the wheels is blocking

void Drive::stop  
 

Stops the robot by setting its speed to (0,0)

void Drive::turn double    angle
 

Turns robot by the indicated angle (angle>0 means counter-clockwise, angle<0 means clockwise)

Parameters:
angle The angle (in degree) to turn

void Drive::turnLeft  
 

Lets the robot turn counter-clockwise with the standard omega until a new drive or turn command is given

void Drive::turnLeft double    angle
 

Turns robot left by the indicated angle

Parameters:
angle The angle (in degree) to turn

void Drive::turnRight  
 

Lets the robot turn clockwise with the standard omega until a new drive or turn command is given

void Drive::turnRight double    angle
 

Turns robot right by the indicated angle

Parameters:
angle The angle (in degree) to turn

void Drive::turnTo double    angle
 

Turns the robot to the indicated angle

Parameters:
angle The angle (in degree) to turn to

void Drive::wait  
 

Blocks the calling thread until the robot has finished the current driving command


Member Data Documentation

Drive Drive::drives [static, private]
 

The single instance that exists of this class

See also:
Drive::getDrive()

double Drive::standardOmega [private]
 

Stores the standard turning speed that is used for all driving commands (in degree per second)

double Drive::standardSpeed [private]
 

Stores the standard speed that is used for all driving commands

VWHandle Drive::vwDriveHandle [private]
 

Used internally to access the robot drive


Generated on Mon Aug 26 18:34:09 2002 for Cube Clustering by doxygen1.3-rc3