Main Page   Class Hierarchy   Compound List   Compound Members  

ArSick Class Reference

The sick driver. More...

#include <ArSick.h>

Inheritance diagram for ArSick::

ArRangeDeviceThreaded ArRangeDevice ArASyncTask ArThread List of all members.

Public Types

enum  BaudRate { BAUD9600, BAUD19200, BAUD38400 }
enum  Degrees { DEGREES180, DEGREES100 }
enum  Increment { INCREMENT_ONE, INCREMENT_HALF }

Public Methods

 ArSick (size_t currentBufferSize=361, size_t cumulativeBufferSize=1448, const char *name="laser")
 Constructor.

 ~ArSick (void)
 Destructor.

void configure (bool useSim=false, bool powerControl=true, bool laserFlipped=false, BaudRate baud=BAUD38400, Degrees deg=DEGREES180, Increment incr=INCREMENT_ONE)
 Configure the laser before connecting to it. More...

void configureShort (bool useSim=false, BaudRate baud=BAUD38400, Degrees deg=DEGREES180, Increment incr=INCREMENT_ONE)
 Shorter configure for the laser. More...

void setSensorPosition (double x, double y, double th)
 Sets the position of the laser on the robot.

void setSensorPosition (ArPose pose)
 Sets the position of the laser on the robot.

ArPose getSensorPosition ()
 Gets the position of the laser on the robot.

double getSensorPositionX ()
 Gets the X position of the laser on the robot.

double getSensorPositionY ()
 Gets the Y position of the laser on the robot.

double getSensorPositionTh ()
 Gets the heading of the laser on the robot.

bool blockingConnect (void)
 Connect to the laser while blocking. More...

bool asyncConnect (void)
 Connect to the laser asyncronously. More...

bool disconnect (bool doNotLockRobotForSim=false)
 Disconnect from the laser. More...

void setDeviceConnection (ArDeviceConnection *conn)
 Sets the device connection.

ArDeviceConnectiongetDeviceConnection (void)
 Gets the device connection.

bool isConnected (void)
 Sees if this is connected to the laser.

bool tryingToConnect (void)
 Sees if this is trying to connect to the laser at the moment.

bool runOnRobot (void)
 Runs the laser off of the robot, advised. More...

int getSickPacCount ()
 Gets the number of laser packets received in the last second.

void addConnectCB (ArFunctor *functor, ArListPos::Pos position)
 Adds a connect callback. More...

void remConnectCB (ArFunctor *functor)
 Adds a disconnect callback. More...

void addFailedConnectCB (ArFunctor *functor, ArListPos::Pos position)
 Adds a callback for when a connection to the robot is failed. More...

void remFailedConnectCB (ArFunctor *functor)
 Removes a callback for when a connection to the robot is failed. More...

void addDisconnectNormallyCB (ArFunctor *functor, ArListPos::Pos position)
 Adds a callback for when disconnect is called while connected. More...

void remDisconnectNormallyCB (ArFunctor *functor)
 Removes a callback for when disconnect is called while connected. More...

void addDisconnectOnErrorCB (ArFunctor *functor, ArListPos::Pos position)
 Adds a callback for when disconnection happens because of an error. More...

void remDisconnectOnErrorCB (ArFunctor *functor)
 Removes a callback for when disconnection happens because of an error. More...

void setConnectionTimeoutTime (int mSecs)
 Sets the time without a response until connection assumed lost. More...

int getConnectionTimeoutTime (void)
 Gets the time without a response until connection assumed lost. More...

ArTime getLastReadingTime (void)
 Gets the time data was last receieved.

void setFilterNearDist (double dist)
 Sets the distance which two readings must be less than to be ignored.

double getFilterNearDist (void)
 Gets the distance which two readings must be less than to be ignored.

bool isUsingSim (void)
 Gets whether the laser is simulated or not.

bool isControllingPower (void)
 Gets whether the computer is controling laser power or not.

bool isLaserFlipped (void)
 Gets whether the laser is flipped over or not.

Degrees getDegrees (void)
 Gets the degrees the laser is scanning.

Increment getIncrement (void)
 Gets the amount each scan increments.

bool simPacketHandler (ArRobotPacket *packet)
 The packet handler for when connected to the simulator.

void sensorInterpCallback (void)
 The function called if the laser isn't running in its own thread and isn't simulated.

bool internalConnectSim (void)
 An internal function. More...

int internalConnectHandler (void)
 An internal function, single loop event to connect to laser. More...

virtual void * runThread (void *arg)
 The internal function used by the ArRangeDeviceThreaded.

void processPacket (ArSickPacket *packet, ArPose pose, ArPose encoderPose, unsigned int counter)
 The internal function which processes the sickPackets.

void runOnce (bool lockRobot)
 The internal function that gets does the work.

virtual void setRobot (ArRobot *robot)
 Sets the robot this device is attached to.

void dropConnection (void)
 Internal function, shouldn't be used, drops the conn because of error.

void failedConnect (void)
 Internal function, shouldn't be used, denotes the conn failed.

void madeConnection (void)
 Internal function, shouldn't be used, does the after conn stuff.

void robotConnectCallback (void)
 Internal function, shouldn't be used, gets params from the robot.


Protected Types

enum  State {
  STATE_NONE, STATE_INIT, STATE_WAIT_FOR_POWER_ON, STATE_CHANGE_BAUD,
  STATE_CONFIGURE, STATE_WAIT_FOR_CONFIGURE_ACK, STATE_INSTALL_MODE, STATE_WAIT_FOR_INSTALL_MODE_ACK,
  STATE_SET_MODE, STATE_WAIT_FOR_SET_MODE_ACK, STATE_START_READINGS, STATE_WAIT_FOR_START_ACK,
  STATE_CONNECTED
}

Protected Methods

void filterReadings ()
 Internal function for filtering the raw readings and updating buffers. More...

void switchState (State state)
 Internal function for switching states.


Detailed Description

The sick driver.


Member Enumeration Documentation

enum ArSick::BaudRate
 

Enumeration values:
BAUD9600  9600 Baud.
BAUD19200  19200 Baud.
BAUD38400  38400 Baud.

enum ArSick::Degrees
 

Enumeration values:
DEGREES180  180 Degrees.
DEGREES100  100 Degrees.

enum ArSick::Increment
 

Enumeration values:
INCREMENT_ONE  One degree increments.
INCREMENT_HALF  Half a degree increments.

enum ArSick::State [protected]
 

Enumeration values:
STATE_NONE  Nothing, haven't tried to connect or anything.
STATE_INIT  Initializing the laser.
STATE_WAIT_FOR_POWER_ON  Waiting for power on.
STATE_CHANGE_BAUD  Change the baud, no confirm here.
STATE_CONFIGURE  Send the width and increment to the laser.
STATE_WAIT_FOR_CONFIGURE_ACK  Wait for the configuration Ack.
STATE_INSTALL_MODE  Switch to install mode.
STATE_WAIT_FOR_INSTALL_MODE_ACK  Wait until its switched to install mode.
STATE_SET_MODE  Set the mode (mm/cm) and extra field bits.
STATE_WAIT_FOR_SET_MODE_ACK  Waiting for set-mode ack.
STATE_START_READINGS  Switch to monitoring mode.
STATE_WAIT_FOR_START_ACK  Waiting for the switch-mode ack.
STATE_CONNECTED  We're connected and getting readings.


Member Function Documentation

void ArSick::addConnectCB ArFunctor   functor,
ArListPos::Pos    position
 

Adds a connect callback.

Adds a connect callback, which is an ArFunctor, created as an ArFunctorC. The entire list of connect callbacks is called when a connection is made with the laser. If you have some sort of module that adds a callback, that module must remove the callback when the module is removed.

Parameters:
functorfunctor  created from ArFunctorC which refers to the function to call.
position  whether to place the functor first or last
See also:
remConnectCB

void ArSick::addDisconnectNormallyCB ArFunctor   functor,
ArListPos::Pos    position
 

Adds a callback for when disconnect is called while connected.

Adds a disconnect normally callback,which is an ArFunctor, created as an ArFunctorC. This whole list of disconnect normally callbacks is called when something calls disconnect if the instance isConnected. If there is no connection and disconnect is called nothing is done. If you have some sort of module that adds a callback, that module must remove the callback when the module is removed.

Parameters:
functor  functor created from ArFunctorC which refers to the function to call.
position  whether to place the functor first or last
See also:
remFailedConnectCB

void ArSick::addDisconnectOnErrorCB ArFunctor   functor,
ArListPos::Pos    position
 

Adds a callback for when disconnection happens because of an error.

Adds a disconnect on error callback, which is an ArFunctor, created as an ArFunctorC. This whole list of disconnect on error callbacks is called when ARIA loses connection to a laser because of an error. This can occur if the physical connection (ie serial cable) between the laser and the computer is severed/disconnected, or if the laser is turned off. Note that if the link between the two is lost the ARIA assumes it is temporary until it reaches a timeout value set with setConnectionTimeoutTime. If you have some sort of module that adds a callback, that module must remove the callback when the module removed.

Parameters:
functor  functor created from ArFunctorC which refers to the function to call.
position  whether to place the functor first or last
See also:
remFailedConnectCB

void ArSick::addFailedConnectCB ArFunctor   functor,
ArListPos::Pos    position
 

Adds a callback for when a connection to the robot is failed.

Adds a failed connect callback,which is an ArFunctor, created as an ArFunctorC. This whole list of failed connect callbacks is called when an attempt is made to connect to the laser, but fails. The usual reason for this failure is either that there is no laser/sim where the connection was tried to be made. If you have some sort of module that adds a callback, that module must remove the callback when the module removed.

Parameters:
functor  functor created from ArFunctorC which refers to the function to call.
position  whether to place the functor first or last
See also:
remFailedConnectCB

bool ArSick::asyncConnect void   
 

Connect to the laser asyncronously.

This does not lockDevice the laser, but you should lockDevice the laser before you try to connect. Also note that if you are connecting to the sim the laser MUST be unlocked so that this can lock the laser and send the commands to the sim. To be connected successfully, either the useSim must be set from configure (and the laser must be connected to a simulator, or this will return true but connection will fail), the device must have been run or runasync, or the device must have been runOnLaser.

Returns:
true if a connection will be able to be tried, false otherwise
See also:
configure, ArRangeDeviceThreaded::run, ArRangeDeviceThreaded::runAsync, runOnRobot

bool ArSick::blockingConnect void   
 

Connect to the laser while blocking.

lockDevice s the laser, and then makes a connection. If it is connecting to the simulator (set with the useSim flag in configure) then it will lock the laser and send the commands to the sim. If where you are calling from has the laser locked, make sure you unlock it before calling this function.

Returns:
true if a connection was made, false otherwise

void ArSick::configure bool    useSim = false,
bool    powerControl = true,
bool    laserFlipped = false,
BaudRate    baud = BAUD38400,
Degrees    deg = DEGREES180,
Increment    incr = INCREMENT_ONE
 

Configure the laser before connecting to it.

You must lockDevice the laser or not have the laser being poked at by multiple threads before you use htis function call

void ArSick::configureShort bool    useSim = false,
BaudRate    baud = BAUD38400,
Degrees    deg = DEGREES180,
Increment    incr = INCREMENT_ONE
 

Shorter configure for the laser.

You must lockDevice the laser or not have the laser being poked at by multiple threads before you use htis function call

bool ArSick::disconnect bool    doNotLockRobotForSim = false
 

Disconnect from the laser.

Disconnects from the laser. You should lockDevice the laser before calling this function. Also if you are using the simulator it will lock the robot so it can send the command to the simulator, so you should make sure the robot is unlocked.

Parameters:
doNotLockRobotForSim  if this is true, this will not lock the robot if its trying to send a command to the sim... ONLY do this if you are calling this from within the robots sync loop (ie from a sync task, sensor interp task, or user task)
Returns:
true if it could disconnect from the laser cleanly

void ArSick::filterReadings   [protected]
 

Internal function for filtering the raw readings and updating buffers.

filter readings here, from raw current buffer to filtered current buffer of the range device object, and then to the cumulative buffer

current buffer filtering is to eliminate max (null) readings, and compress close readings

cumulative buffer filtering is to replace readings within the scope of the current sensor set

int ArSick::getConnectionTimeoutTime void   
 

Gets the time without a response until connection assumed lost.

Gets the number of seconds to go without response from the laser until it is assumed tha tthe connection with the laser has been broken and the disconnect on error events will happen.

int ArSick::internalConnectHandler void   
 

An internal function, single loop event to connect to laser.

Returns:
0 if its still trying to connect, 1 if it connected, 2 if it failed

bool ArSick::internalConnectSim void   
 

An internal function.

Sends the commands to the sim to start up the connection

Returns:
true if the commands were sent, false otherwise

void ArSick::remConnectCB ArFunctor   functor
 

Adds a disconnect callback.

Parameters:
functor  the functor to remove from the list of connect callbacks
See also:
addConnectCB

void ArSick::remDisconnectNormallyCB ArFunctor   functor
 

Removes a callback for when disconnect is called while connected.

Parameters:
functor  the functor to remove from the list of connect callbacks
See also:
addDisconnectNormallyCB

void ArSick::remDisconnectOnErrorCB ArFunctor   functor
 

Removes a callback for when disconnection happens because of an error.

Parameters:
functor  the functor to remove from the list of connect callbacks
See also:
addDisconnectOnErrorCB

void ArSick::remFailedConnectCB ArFunctor   functor
 

Removes a callback for when a connection to the robot is failed.

Parameters:
functor  the functor to remove from the list of connect callbacks
See also:
addFailedConnectCB

bool ArSick::runOnRobot void   
 

Runs the laser off of the robot, advised.

This sets up a sensor interp task on the robot, which is where the robot will be driven from. Note that the device must have been added to the robot already so that the device has a pointer to the robot. You should lock the robot and lockDevice the laser before doing this if other things are running already.

void ArSick::setConnectionTimeoutTime int    mSecs
 

Sets the time without a response until connection assumed lost.

Sets the number of seconds to go without a response from the laser until it is assumed that the connection with the laser has been broken and the disconnect on error events will happen.

Parameters:
seconds  if seconds is 0 then the connection timeout feature will be disabled, otherwise disconnect on error will be triggered after this number of seconds...


The documentation for this class was generated from the following files:
Generated on Tue Nov 12 17:44:05 2002 for Aria by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001