Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages | Examples

ArLMS2xx Class Reference

#include <ArLMS2xx.h>

Inheritance diagram for ArLMS2xx:

ArLaser ArRangeDeviceThreaded ArRangeDevice List of all members.

Detailed Description

Interface to a SICK LMS-200 laser range device.

This class processes incoming data from a SICK LMS-200 laser rangefinding device in a background thread, and provides it through the standard ArRangeDevice API, to be used via ArRobot (see ArRobot::addRangeDevice()), used by an ArAction, or used directly.

An ArSick instance must be connected to the laser through a serial port (or simulator): the typical procedure is to allow your ArSimpleConnector to configure the laser based on the robot connection type and command line parameters; then initiate the ArSick background thread; and finally connect ArSick to the laser device. For example:

  ArRobot robot;
  ArSick laser;
  ArSimpleConnector connector(...);
  ...
   Setup the simple connector and connect to the robot --
   see the example programs.
  ...
  connector.setupLaser(&laser);
  laser.runAsync();
  if(!laser.blockingConnect())
  {
    // Error...
    ...
  }
  ...

The most important methods in this class are the constructor, runAsync(), blockingConnect(), getSensorPosition(), isConnected(), addConnectCB(), asyncConnect(), configure(), in addition to the ArRangeDevice interface.

Note:
The "extra int" on the raw readings returned by ArRangeDevice::getRawReadings() is like other laser devices and is the reflectance value, if enabled, ranging between 0 and 255.


Public Member Functions

 ArLMS2xx (int laserNumber, const char *name="lms2xx", bool appendLaserNumberToName=true)
 Constructor.
bool asyncConnect (void)
 Connect to the laser asyncronously.
virtual bool blockingConnect (void)
 Connect to the laser while blocking.
virtual bool disconnect (void)
 Disconnect from the laser.
virtual bool isConnected (void)
 Sees if this is connected to the laser.
virtual bool isTryingToConnect (void)
virtual void * runThread (void *arg)
virtual void setDeviceConnection (ArDeviceConnection *conn)
 Sets the device connection.
virtual void setRobot (ArRobot *robot)
virtual ~ArLMS2xx ()
 Destructor.

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 Member Functions

void dropConnection (void)
void failedConnect (void)
bool finishParams (void)
int internalConnectHandler (void)
 An internal function, single loop event to connect to laser.
bool internalConnectSim (void)
bool internalRunOnRobot (void)
 internal function to runOnRobot so that ArSick can do that while this class won't
virtual bool laserCheckParams (void)
virtual void laserSetName (const char *name)
void madeConnection (void)
void processPacket (ArLMS2xxPacket *packet, ArPose pose, ArPose encoderPose, unsigned int counter, bool deinterlace, ArPose deinterlaceDelta)
void runOnce (bool lockRobot)
void sensorInterpCallback (void)
bool sickGetIsUsingSim (void)
 Internal function that gets whether the laser is simulated or not (just for the old ArSick).
void sickSetIsUsingSim (bool usingSim)
 Internal function that sets whether the laser is simulated or not (just for the old ArSick).
bool simPacketHandler (ArRobotPacket *packet)
void switchState (State state)
 Internal function for switching states.

Protected Attributes

ArRetFunctorC< bool, ArLMS2xxmyAriaExitCB
std::list< ArSensorReading * > * myAssembleReadings
std::list< ArSensorReading * > * myCurrentReadings
double myIncrementAmount
bool myInterlaced
bool myInterpolation
std::list< ArSensorReading
* >::iterator 
myIter
ArLMS2xxPacketReceiver myLMS2xxPacketReceiver
int myNumReflectorBits
double myOffsetAmount
ArLMS2xxPacket myPacket
std::list< ArLMS2xxPacket * > myPackets
bool myProcessImmediately
ArFunctorC< ArLMS2xxmyRobotConnectCB
bool myRunInOwnThread
bool myRunningOnRobot
ArFunctorC< ArLMS2xxmySensorInterpCB
unsigned int mySimPacketCounter
ArTransform mySimPacketEncoderTrans
ArRetFunctor1C< bool, ArLMS2xx,
ArRobotPacket * > 
mySimPacketHandler
ArPose mySimPacketStart
ArTransform mySimPacketTrans
bool myStartConnect
State myState
ArMutex myStateMutex
ArTime myStateStart
unsigned int myTotalNumReadings
bool myUseSim
unsigned int myWhichReading


Member Enumeration Documentation

enum ArLMS2xx::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

bool ArLMS2xx::asyncConnect void   )  [virtual]
 

Connect to the laser asyncronously.

This does not lock the laser, but you should lock the laser before you try to connect. Also note that if you are connecting to the simulator 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 runOnRobot() used.

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

Implements ArLaser.

bool ArLMS2xx::blockingConnect void   )  [virtual]
 

Connect to the laser while blocking.

Locks this class (using lockDevice()), tries to make a connection, then unlocks. If connecting to the simulator, then it will commands to the simulator instead of connecting over the configured serial port.

Note:
If you have previously locked the laser with lockDevice(), then you must unlock with unlockDevice() before calling this function.

Since the simulated laser uses the robot connection instead of a separate, new connection, this ArLMS2xx object must have been added to the robot using ArRobot::addRangeDevice(), and the robot connection must be connected and running (e.g. in a background thread via ArRobot::runAsync()) for blockingConnect() to be able to successfully connect to the simulator.

Returns:
true if a connection was successfully made, false otherwise

Implements ArLaser.

bool ArLMS2xx::disconnect void   )  [virtual]
 

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.

Returns:
true if it could disconnect from the laser cleanly

Implements ArLaser.

bool ArLMS2xx::finishParams void   )  [protected]
 

Finishes getting the unset parameters from the robot then setting some internal variables that need it

bool ArLMS2xx::internalConnectSim void   )  [protected]
 

Sends the commands to the sim to start up the connection

Returns:
true if the commands were sent, false otherwise

bool ArLMS2xx::internalRunOnRobot void   )  [protected]
 

internal function to runOnRobot so that ArSick can do that while this class won't

This alternate method of operation sets up a sensor interpretation task on the robot object, instead of in a background thread. 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() this laser before calling this if other things are running already.

void * ArLMS2xx::runThread void *  arg  )  [virtual]
 

The internal function used by the ArRangeDeviceThreaded

Implements ArRangeDeviceThreaded.

void ArLMS2xx::sensorInterpCallback void   )  [protected]
 

MPL changing this since it seems -1 is left out of everything


The documentation for this class was generated from the following files:
Generated on Thu Jan 7 10:34:42 2010 for Aria by  doxygen 1.4.2