player_kerl.h File Reference

Functions to control a robot in Player. More...

This graph shows which files directly or indirectly include this file:


Data Structures

struct  PlayerClient

Defines

#define GETROBOT
#define UPDATE(robotId)
#define TESTSOCKET(cli)   if(cli->client->sock < 0) return NOSOCKET;

Functions

int createRobot (char *address, int port, int index, char *robotID)
int destroyRobot (char *robotID)
int move (char *robotID, double speed, double rotation)
int moveCoordinate (char *robotID, double x, double y)
int rotateDegrees (char *robotID, double degrees)
int update (char *robotID)
int getPosition (char *robotID, double *px, double *py, double *pa)
int laserResultsSize (char *robotID, int *numberOfResults)
int readLaserResults (char *robotID, double *laserResults, double *laserBearings, int *size)
int moveCoordinate (char *robotID, double px, double py, double pa)
int travelDistance (char *robotID, double distance)
int queryRobot (char *robotID, ClientQuery *query)
PlayerClient_getClient (char *robotID)

Detailed Description

Functions to control a robot in Player.

Author:
Thomas Lorentsen, Sten Gruener
This holds the player side of the code. Provides functions to control a player robot This should not contain any erlang related code

Each robot will be contained in a map where there key is its name or robot identification. Using a name provides a more user friendly way of identifiying robots as a user could choose a name they wish to use.


Define Documentation

#define GETROBOT

Value:

client = _getClient(robotID);\
if(client == NULL) return NOSUCHCLIENT;
Return the robot, otherwise return NOSUCHCLIENT

#define TESTSOCKET ( cli   )     if(cli->client->sock < 0) return NOSOCKET;

Client socket validity test

#define UPDATE ( robotId   ) 

Value:

int re = update(robotId);\
if(re != SUCCESS)return re;
Update function


Function Documentation

_getClient ( char *  robotID  ) 

Parameters:
robotID an identification for the robot returns a client with this name
robotID an identification for the robot returns a client with this name returns null if client does not exist

createRobot ( char *  address,
int  port,
int  index,
char *  robotID 
)

Parameters:
address the address player is listening on
port the port player is listening on
index is the internal playerstage id
robotID an identification for the robot
Returns:
0 on success Use this to create a new robot connection. Once the robot has been created it can then be controlled with any other function. A robotID identifies the robot created so it can be controlled. It must be a unique id otherwise this function will return a none zero. Function will need to allocate memory needed and add the robot to a map of robots.
If needed this function will also initate devices so that they can be used

destroyRobot ( char *  robotID  ) 

Parameters:
robotID an identification for the robot
Returns:
0 on success This will destroy the robot so it can no longer be controlled until it is recreated. Function will need to reallocate the memory used by the robot after it has been stopped.

getPosition ( char *  robotID,
double *  px,
double *  py,
double *  pa 
)

Parameters:
robotID an identification for the robot
px the x position read
py the y position read
pa the angle read
Returns:
0 if successfully set values Sets the values pass to the positions read from the odometer

laserResultsSize ( char *  robotID,
int *  numberOfResults 
)

Parameters:
robotID an identification for the robot
numberOfResults sets this value to the number of lasers Simply sets the amount of lasers there are to read. This will need to be called before calling readLaserResults so you can allocate memory for lasers

move ( char *  robotID,
double  speed,
double  rotation 
)

Parameters:
robotID an identification for the robot
speed The speed the robot will move in m/s
rotation in rad/s
Returns:
0 on success Tells the robot to move forward at a certain speed. To stop the robot moving forward pass 0 as the speed.
Parameters:
robotID an identification for the robot
speed The speed the robot will move in m/s
rotation in deg/s
Returns:
0 on success Tells the robot to move forward at a certain speed. To stop the robot moving forward pass 0 as the speed.

moveCoordinate ( char *  robotID,
double  px,
double  py,
double  pa 
)

Parameters:
robotID an identification for the robot
px the wished x position
py the wished y position
pa the wished angle in radiants
Moves robot to wished coordinates.

moveCoordinate ( char *  robotID,
double  x,
double  y 
)

Parameters:
robotID an identification for the robot
x The x coordinate to move to
y the y coordinate to move to Move to this position on the map. This is relative to robot current position

queryRobot ( char *  robotID,
ClientQuery query 
)

Parameters:
robotID Robot identifier
query Query to run Runs a query on a robot and returns a tuple containing useful information about it.
Runs a query on a robot and returns a tuple containing useful information about it.

readLaserResults ( char *  robotID,
double *  laserResults,
double *  laserBearings,
int *  size 
)

Parameters:
robotID an identification for the robot
laserResults the array to put laser results into
laserBearings the bearings of each laser
size the number of laser results to read, use laserResultsSize to find this value Sets both the laser result and the bearing Remember to allocate sizeof(double)*size in laserResults and laserBearings before passing them through

rotateDegrees ( char *  robotID,
double  degrees 
)

Parameters:
robotID an identification for the robot
degrees the amount of degrees to rotate by Rotates the robot by this amount of degrees. This is relative to robot current position This function is none blocking so you will have to detect when the robot has stopped rotating.

travelDistance ( char *  robotID,
double  distance 
)

Parameters:
robotID an identification for the robot
distance distance to go
Lets robot move in current direction for given distance.

update ( char *  robotID  ) 

Parameters:
robotID an identification for the robot
Returns:
0 on success Notifies Player to update devices. This function is none blocking so you may not get updated results as soon as you read a device.


Generated on Thu Aug 13 23:20:22 2009 for KERL by  doxygen 1.5.8