Main Page | Class List | Class Members

HokuyoURG Class Reference

HokuyoURG is used to perform a laser rangefinder scan (and associated simple processing on that scan). More...

#include <HokuyoURG.h>

List of all members.

Public Member Functions

 HokuyoURG (int=1, int=19200, int=44, int=725, int=3, bool=true)
bool scan (void)
 perform a scan within the specified range of angles and resolution
bool scanSnd (void)
 snd request for a scan
bool scanRcv (void)
 rcv and parse results from a scan
unsigned int getRangeByEl (const int &)
 get the given range reading
unsigned int getRangeByBearing (const float &)
 get the range at the given bearing
int getNumRangeVals (void)
 get the number of range values to be returned. this corresponds to the number of relevant elements in dist
bool isLastScanSuccess (void)
 returns boolean indicating success (or not) of last scan
float stepToAngUnits (int steps)
 convert step units to to angle units (deg)
float stepnumToBearing (float step)
 convert step to angle (deg)
float indexToStepnum (int index)
 returns the middle step in the cluster (may be between clusters)
float indexToBearing (int index)
 convert the index of the array dist[] to an angle (deg) of the range scan
float bearingToStepnum (float ang)
 convert a bearing (deg) to corresponding step num
float angToStepUnits (float ang)
 convert angle units (deg) to step units
float bearingToIndex (float bearing)
 convert the index of the array dist[] to a bearing (deg) of the range scan
bool calcForceVector (void)
 calculate the force vector experienced by the robot using the current scan data i.e. the repellance from objects
bool getForceVec (Crd< float > *)
 conduct a scan and then calculate force vector
void setupCones (const int &num)
 NOT IMPLEMENTED YET: divide space into 'num' cones, no space between cones.
bool setupCones (const int &num, const float &wd)
 divide space into 'num' cones, 'angWd' radians wide each
void setupCones (const std::vector< float > &vAngs)
 NOT IMPLEMENTED YET: divide space into cones centred at angles in 'vAngs', no space between cones.
void setupCones (const std::vector< float > &vAngs, const float &angWd)
 NOT IMPLEMENTED YET: divide space into cones centred at angles in 'vAngs', 'angWd' radians wide each.
int getClosestRange (const int &)
 get the closest range within cone
float getAvgRange (const int &)
 get the average range within cone

Public Attributes

Crd< float > fvec
 maximum of 769
CrdP< float > fvecP
 force vector

Static Public Attributes

const int rawMAX_gr = 4000
 maximum 255 -> corresponds to 4000mm (for fvec)


Detailed Description

HokuyoURG is used to perform a laser rangefinder scan (and associated simple processing on that scan).

The laser scans in the acw direction, from -135 degrees, to 135 degrees,
Where straight ahead is 0 degrees.

The range values are set in the public int array dist[]
( maximum element given by getNumRangeVals() )

The main functions to be used are:
General
----------------------
scan() : to perform a scan (this has a 50ms sleep)
scanSnd() and scanRcv() : if you want the sleep to be external
getNumRangeVals() : to get the maximum number of range values returned
indexToBearing() : to convert the range reading index into an angle
isLastScanSuccess() : to find out if the last scan was a success
There are other conversion functions for conversions between array index, laser scan step, and bearing.

The raw values are in (mm).

Force Vector Functions
----------------------
calcForceVector() : to calculate the force vector from the previous scan
getForceVec() : to scan and calculate force vector

Cone Functions
----------------------
The laser scan can be divided into conic segments using the setupCones() functions.
Then it is possible to obtain the closest or average range in a cone using: getClosestRange() and getAvgRange()


Constructor & Destructor Documentation

HokuyoURG::HokuyoURG int  com = 1,
int  baud = 19200,
int  pStrt = 44,
int  pEnd = 725,
int  pClstr = 3,
bool  pBDisp = true
 

initialise data structures and serial communications
calculate format of returned data (number of blocks (64 chars - 32 readings) and remainder (chars/readings))

Parameters:
com the comport to use (default 1)
baud the baud rate (default 19200)
pStrt the start step (44)
pEnd the end step (725)
pClstr the number of steps to cluster as one reading (3)
pBDisp flag to indicate if you want it to display text to console window


Member Function Documentation

bool HokuyoURG::calcForceVector void   ) 
 

calculate the force vector experienced by the robot using the current scan data i.e. the repellance from objects

Returns:
false, if there was no valid scan data, true if there was valid scan data

bool HokuyoURG::getForceVec Crd< float > *  fvPtr  ) 
 

conduct a scan and then calculate force vector

Parameters:
fvPtr a pointer to a Crd, which will be set with the force vector value
Returns:
true if successful (if there was a valid scan)

unsigned int HokuyoURG::getRangeByBearing const float &  bearing  ) 
 

get the range at the given bearing

there may be approximations if this is used. there may not be a range value for this bearing exactly

unsigned int HokuyoURG::getRangeByEl const int &  el  ) 
 

get the given range reading

warning: not protected by mutex. assume that the functions that call this take responsibility.

bool HokuyoURG::scan void   ) 
 

perform a scan within the specified range of angles and resolution

Sets an internal boolean to indicate success.

Returns:
true if successful, false if not successful

bool HokuyoURG::scanRcv void   ) 
 

rcv and parse results from a scan

Sets an internal boolean to indicate success.

Returns:
true if successful, false if not successful

bool HokuyoURG::scanSnd void   ) 
 

snd request for a scan

Returns:
true if successful, false if not successful

bool HokuyoURG::setupCones const int &  pNCones,
const float &  wd
 

divide space into 'num' cones, 'angWd' radians wide each

divide space into 'nCone' cones, 'angWd' degs wide each centred on 0 degrees (straigth ahead) if there is an uneven number of steps over the total arc, extra one at the end


The documentation for this class was generated from the following files:
Generated on Tue Jan 31 14:47:30 2006 for HokuyoURG by doxygen 1.3.8