#include <ArLMS2xx.h>
Inheritance diagram for ArLMS2xx:
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.
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, ArLMS2xx > | myAriaExitCB |
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< ArLMS2xx > | myRobotConnectCB |
bool | myRunInOwnThread |
bool | myRunningOnRobot |
ArFunctorC< ArLMS2xx > | mySensorInterpCB |
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 |
|
|
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.
Implements ArLaser. |
|
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.
Implements ArLaser. |
|
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.
Implements ArLaser. |
|
Finishes getting the unset parameters from the robot then setting some internal variables that need it |
|
Sends the commands to the sim to start up the connection
|
|
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. |
|
The internal function used by the ArRangeDeviceThreaded Implements ArRangeDeviceThreaded. |
|
MPL changing this since it seems -1 is left out of everything |