#include <ArSick.h>
Inheritance diagram for ArSick:
This class processes incoming data from a SICK 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.
demo.cpp, lineFinderExample.cpp, and triangleDriveToActionExample.cpp.
Definition at line 76 of file ArSick.h.
Public Types | |
enum | BaudRate { BAUD9600, BAUD19200, BAUD38400 } |
enum | Bits { BITS_1REFLECTOR, BITS_2REFLECTOR, BITS_3REFLECTOR } |
enum | Degrees { DEGREES180, DEGREES100 } |
enum | Increment { INCREMENT_ONE, INCREMENT_HALF } |
enum | Units { UNITS_1MM, UNITS_1CM, UNITS_10CM } |
Public Member Functions | |
void | addConnectCB (ArFunctor *functor, ArListPos::Pos position=ArListPos::LAST) |
Adds a connect callback. | |
void | addDataCB (ArFunctor *functor, ArListPos::Pos position=ArListPos::LAST) |
Adds a callback that is called whenever a laser packet is processed. | |
void | addDisconnectNormallyCB (ArFunctor *functor, ArListPos::Pos position=ArListPos::LAST) |
Adds a callback for when disconnect is called while connected. | |
void | addDisconnectOnErrorCB (ArFunctor *functor, ArListPos::Pos position=ArListPos::LAST) |
Adds a callback for when disconnection happens because of an error. | |
void | addFailedConnectCB (ArFunctor *functor, ArListPos::Pos position=ArListPos::LAST) |
Adds a callback for when a connection to the robot is failed. | |
void | addIgnoreReading (double ignoreReading) |
Adds a degree at which to ignore readings (within 1 degree). | |
virtual void | applyTransform (ArTransform trans, bool doCumulative=true) |
Applies a transform to the buffers. | |
ArSick (size_t currentBufferSize=361, size_t cumulativeBufferSize=0, const char *name="laser", bool addAriaExitCB=true) | |
Constructor. | |
bool | asyncConnect (void) |
Connect to the laser asyncronously. | |
bool | blockingConnect (void) |
Connect to the laser while blocking. | |
void | clearIgnoreReadings (void) |
Clears the degrees we ignore readings at. | |
void | configure (bool useSim=false, bool powerControl=true, bool laserFlipped=false, BaudRate baud=BAUD38400, Degrees deg=DEGREES180, Increment incr=INCREMENT_ONE) |
Use this to manually configure the laser before connecting to it. | |
void | configureShort (bool useSim=false, BaudRate baud=BAUD38400, Degrees deg=DEGREES180, Increment incr=INCREMENT_ONE) |
Shorter configure for the laser (settings are overridden by the .p file). | |
bool | disconnect (bool doNotLockRobotForSim=false) |
Disconnect from the laser. | |
void | dropConnection (void) |
void | failedConnect (void) |
Bits | getBits (void) |
Gets the Bits the laser is using. | |
int | getConnectionTimeoutTime (void) |
Gets the time without a response until connection assumed lost. | |
Degrees | getDegrees (void) |
Gets the degrees the laser is scanning. | |
ArDeviceConnection * | getDeviceConnection (void) |
Gets the device connection. | |
int | getFilterCleanCumulativeInterval (void) |
Cumulative readings are cleaned every this number of milliseconds. | |
double | getFilterCumulativeCleanDist (void) |
Cumulative readings that are this close to current beams are discarded. | |
double | getFilterCumulativeInsertMaxDist (void) |
Cumulative readings must be taken within this distance to the robot to be added. | |
int | getFilterCumulativeMaxAge (void) |
double | getFilterCumulativeMaxDist (void) |
You should see getMaxDistToKeepCumulative (it replaces this). | |
double | getFilterCumulativeNearDist (void) |
Cumulative readings closer than this are discarded as too close. | |
double | getFilterNearDist (void) |
Current readings closer than this are discarded as too close. | |
const std::list< double > * | getIgnoreReadings (void) const |
Gets the list of readings that we ignore. | |
Increment | getIncrement (void) |
Gets the amount each scan increments. | |
ArTime | getLastReadingTime (void) |
Gets the time data was last receieved. | |
unsigned int | getMinRange (void) |
Gets the minimum range for this device (defaults to 100 mm). | |
ArPose | getSensorPosition () |
Gets the position of the laser on the robot. | |
double | getSensorPositionTh () |
Gets the heading 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. | |
int | getSickPacCount () |
Gets the number of laser packets received in the last second. | |
Units | getUnits (void) |
Gets the Units the laser is using. | |
int | internalConnectHandler (void) |
An internal function, single loop event to connect to laser. | |
bool | internalConnectSim (void) |
bool | isConnected (void) |
Sees if this is connected to the laser. | |
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. | |
bool | isUsingSim (void) |
Gets whether the laser is simulated or not. | |
void | madeConnection (void) |
void | processPacket (ArSickPacket *packet, ArPose pose, ArPose encoderPose, unsigned int counter, bool deinterlace, ArPose deinterlaceDelta) |
void | remConnectCB (ArFunctor *functor) |
Adds a disconnect callback. | |
void | remDataCB (ArFunctor *functor) |
Removes a callback that is called whenever a laser packet is processed. | |
void | remDisconnectNormallyCB (ArFunctor *functor) |
Removes a callback for when disconnect is called while connected. | |
void | remDisconnectOnErrorCB (ArFunctor *functor) |
Removes a callback for when disconnection happens because of an error. | |
void | remFailedConnectCB (ArFunctor *functor) |
Removes a callback for when a connection to the robot is failed. | |
void | robotConnectCallback (void) |
void | runOnce (bool lockRobot) |
bool | runOnRobot (void) |
Runs the laser off of the robot. | |
virtual void * | runThread (void *arg) |
void | sensorInterpCallback (void) |
void | setConnectionTimeoutTime (int mSecs) |
Sets the time without a response until connection assumed lost. | |
void | setDeviceConnection (ArDeviceConnection *conn) |
Sets the device connection. | |
void | setFilterCleanCumulativeInterval (int milliSeconds) |
Cumulative readings are cleaned every this number of milliseconds. | |
void | setFilterCumulativeCleanDist (double dist) |
Cumulative readings that are this close to current beams are discarded. | |
void | setFilterCumulativeInsertMaxDist (double dist) |
Cumulative readings must be taken within this distance to the robot to be added. | |
void | setFilterCumulativeMaxAge (int seconds) |
void | setFilterCumulativeMaxDist (double dist) |
You should see setMaxDistToKeepCumulative (it replaces this). | |
void | setFilterCumulativeNearDist (double dist) |
Cumulative readings closer than this are discarded as too close. | |
void | setFilterNearDist (double dist) |
Current readings closer than this are discarded as too close. | |
void | setIsControllingPower (bool controlPower) |
Sets whether the computer is controling laser power or not. | |
void | setIsLaserFlipped (bool laserFlipped) |
Sets whether the laser is flipped over or not. | |
void | setIsUsingSim (bool usingSim) |
Sets whether the laser is simulated or not. | |
void | setMinRange (unsigned int minRange) |
Sets the maximum range for this device (defaults to 100 mm). | |
void | setRangeInformation (Bits bits=BITS_1REFLECTOR, Units units=UNITS_1MM) |
Sets the ranging/reflector information. | |
virtual void | setRobot (ArRobot *robot) |
void | setSensorPosition (ArPose pose) |
Sets the position of the laser on the robot. | |
void | setSensorPosition (double x, double y, double th) |
Sets the position of the laser on the robot. | |
bool | simPacketHandler (ArRobotPacket *packet) |
bool | tryingToConnect (void) |
Sees if this is trying to connect to the laser at the moment. | |
virtual | ~ArSick () |
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 | filterAddAndCleanCumulative (double x, double y, bool clean) |
Internal function for managing the cumulative. | |
void | filterFarAndOldCumulative (void) |
Internal function for managing the cumulative. | |
void | filterReadings () |
Internal function for filtering the raw readings and updating buffers. | |
void | switchState (State state) |
Internal function for switching states. | |
Protected Attributes | |
ArRetFunctor1C< bool, ArSick, bool > | myAriaExitCB |
std::list< ArSensorReading * > * | myAssembleReadings |
BaudRate | myBaud |
Bits | myBits |
ArDeviceConnection * | myConn |
std::list< ArFunctor * > | myConnectCBList |
ArMutex | myConnLock |
std::list< ArSensorReading * > * | myCurrentReadings |
std::list< ArFunctor * > | myDataCBList |
Degrees | myDegrees |
std::list< ArFunctor * > | myDisconnectNormallyCBList |
std::list< ArFunctor * > | myDisconnectOnErrorCBList |
std::list< ArFunctor * > | myFailedConnectCBList |
int | myFilterCleanCumulativeInterval |
double | myFilterCumulativeCleanDist |
double | myFilterCumulativeInsertMaxDist |
double | myFilterCumulativeNearDist |
double | myFilterNearDist |
double | myFilterSquaredCumulativeCleanDist |
double | myFilterSquaredCumulativeInsertMaxDist |
double | myFilterSquaredCumulativeNearDist |
std::list< double > | myIgnoreReadings |
Readings we ignore. | |
Increment | myIncrement |
double | myIncrementAmount |
bool | myInterpolation |
std::list< ArSensorReading * >::iterator | myIter |
bool | myLaserFlipped |
ArTime | myLastCleanedCumulative |
ArTime | myLastReading |
unsigned int | myMinRange |
double | myOffsetAmount |
ArSickPacket | myPacket |
std::list< ArSickPacket * > | myPackets |
bool | myPowerControl |
bool | myProcessImmediately |
bool | myRealConfigured |
ArFunctorC< ArSick > | myRobotConnectCB |
bool | myRunInOwnThread |
bool | myRunningOnRobot |
ArFunctorC< ArSick > | mySensorInterpCB |
ArPose | mySensorPose |
int | mySickPacCount |
int | mySickPacCurrentCount |
ArSickPacketReceiver | mySickPacketReceiver |
unsigned int | mySimPacketCounter |
ArTransform | mySimPacketEncoderTrans |
ArRetFunctor1C< bool, ArSick, ArRobotPacket * > | mySimPacketHandler |
ArPose | mySimPacketStart |
ArTransform | mySimPacketTrans |
bool | myStartConnect |
State | myState |
ArMutex | myStateMutex |
ArTime | myStateStart |
time_t | myTimeLastSickPacket |
int | myTimeoutTime |
unsigned int | myTotalNumReadings |
Units | myUnits |
bool | myUseSim |
unsigned int | myWhichReading |
|
|
|
|
|
|
|
|
|
|
|
|
Adds a connect callback. Adds a connect callback, any ArFunctor, (e.g. created as an ArFunctorC subclass). Each connect callback is called when a connection is made with the laser. (Note, if you have some sort of module that adds a callback, that module must remove the callback when the module is removed or destroyed.)
Definition at line 1354 of file ArSick.cpp. |
|
Adds a callback that is called whenever a laser packet is processed. Adds a data callback, which is an ArFunctor, created as an ArFunctorC. Whenever a new reading is processed this callback is called. You can then get the raw readings with getRawReadings.
Definition at line 1490 of file ArSick.cpp. |
|
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.
Definition at line 1422 of file ArSick.cpp. |
|
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.
Definition at line 1459 of file ArSick.cpp. |
|
Adds a callback for when a connection to the robot is failed. Adds a failed connect callback ArFunctor. Each failed connect callbacks is invoked 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. Note, if you have some sort of module that adds a callback, that module must remove the callback when the module is removed or destroyed.
Definition at line 1388 of file ArSick.cpp. |
|
Applies a transform to the buffers. Applies a transform to the buffers. this is mostly useful for translating to/from local/global coordinates, but may have other uses. This is different from the class because it also transforms the raw readings.
Reimplemented from ArRangeDevice. Definition at line 2290 of file ArSick.cpp. |
|
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.
Definition at line 1714 of file ArSick.cpp. |
|
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.
Definition at line 1666 of file ArSick.cpp. |
|
Use this to manually configure the laser before connecting to it. Manually set laser configuration options for connection. This must be called only before connecting to the laser (not while the laser is connected). This configuration is automatically performed if you are using ArSimpleConnector to connect to the laser based on command line parameters, so calling this function is only neccesary if you are not using ArSimpleConnector, or you wish to always override ArSimpleConnector's configuration. (Don't forget, you must lock ArSick with lockDevice() if multiple threads are accessing the ArSick, e.g. if you used runAsync().) Definition at line 305 of file ArSick.cpp. |
|
Shorter configure for the laser (settings are overridden by the .p file). Manually set laser configuration options for connection. This must be called only before connecting to the laser (not while the laser is connected). This configuration is automatically performed if you are using ArSimpleConnector to connect to the laser based on command line parameters, so calling this function is only neccesary if you are not using ArSimpleConnector, or you wish to always override ArSimpleConnector's configuration. (Don't forget, you must lock ArSick with lockDevice() if multiple threads are accessing the ArSick, e.g. if you used runAsync().) Definition at line 349 of file ArSick.cpp. |
|
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.
Definition at line 1569 of file ArSick.cpp. |
|
Internal function, shouldn't be used, drops the conn because of error Definition at line 1512 of file ArSick.cpp. |
|
Internal function, shouldn't be used, denotes the conn failed Definition at line 1533 of file ArSick.cpp. |
|
Gets the time without a response until connection assumed lost. Gets the time (miliseconds) to go without 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. If 0, then the timeout is disabled. Definition at line 269 of file ArSick.cpp. |
|
Cumulative readings are cleaned every this number of milliseconds. The cumulative readings are check against the current buffer every this number of milliseconds... if 0 its cleaned every time there are readings. Definition at line 2147 of file ArSick.cpp. |
|
Cumulative readings that are this close to current beams are discarded. When the readings are cleaned the current readings are compared against the cumulative readings... if a beam of a current reading comes within this distance of a cumulative reading that cumulative reading is removed. If this value is 0 then there is no filtering of this kind. Definition at line 2122 of file ArSick.cpp. |
|
Cumulative readings must be taken within this distance to the robot to be added. When readings are put into the cumulative buffer they must be within this distance of the robot. If this value is 0 then there is no filtering of this kind. Definition at line 2066 of file ArSick.cpp. |
|
you should use getMaxSecondsToKeepCumulative instead, (replaces this)
|
|
Cumulative readings closer than this are discarded as too close. When readings are put into the cumulative buffer they must be this far from all the other cumulative readings or they aren't put in. If this value is 0 then there is no filtering of this kind. Definition at line 2092 of file ArSick.cpp. |
|
Current readings closer than this are discarded as too close. When readings are put into the current buffer they are compared against the last reading and must be at least this distance away from the last reading. If this value is 0 then there is no filtering of this kind. Definition at line 2039 of file ArSick.cpp. |
|
An internal function Definition at line 1312 of file ArSick.cpp. |
|
Internal function, shouldn't be used, does the after conn stuff Definition at line 1547 of file ArSick.cpp. |
|
The internal function which processes the sickPackets Definition at line 1755 of file ArSick.cpp. |
|
Adds a disconnect callback.
Definition at line 1370 of file ArSick.cpp. |
|
Removes a callback that is called whenever a laser packet is processed.
Definition at line 1506 of file ArSick.cpp. |
|
Removes a callback for when disconnect is called while connected.
Definition at line 1438 of file ArSick.cpp. |
|
Removes a callback for when disconnection happens because of an error.
Definition at line 1475 of file ArSick.cpp. |
|
Removes a callback for when a connection to the robot is failed.
Definition at line 1404 of file ArSick.cpp. |
|
Internal function, shouldn't be used, gets params from the robot Definition at line 107 of file ArSick.cpp. |
|
The internal function that gets does the work Definition at line 1932 of file ArSick.cpp. |
|
Runs the laser off of the robot. 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. Definition at line 1741 of file ArSick.cpp. |
|
The internal function used by the ArRangeDeviceThreaded Implements ArRangeDeviceThreaded. Definition at line 2235 of file ArSick.cpp. |
|
The function called if the laser isn't running in its own thread and isn't simulated Definition at line 2155 of file ArSick.cpp. |
|
Sets the time without a response until connection assumed lost. Sets the time 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.
Definition at line 255 of file ArSick.cpp. |
|
Cumulative readings are cleaned every this number of milliseconds. The cumulative readings are check against the current buffer every this number of milliseconds... if 0 its cleaned every time there are readings. Definition at line 2132 of file ArSick.cpp. |
|
Cumulative readings that are this close to current beams are discarded. When the readings are cleaned the current readings are compared against the cumulative readings... if a beam of a current reading comes within this distance of a cumulative reading that cumulative reading is removed. If this value is 0 then there is no filtering of this kind. Definition at line 2104 of file ArSick.cpp. |
|
Cumulative readings must be taken within this distance to the robot to be added. When readings are put into the cumulative buffer they must be within this distance of the robot. If this value is 0 then there is no filtering of this kind. Definition at line 2050 of file ArSick.cpp. |
|
you should use setMaxSecondsToKeepCumulative instead, (replaces this)
|
|
Cumulative readings closer than this are discarded as too close. When readings are put into the cumulative buffer they must be this far from all the other cumulative readings or they aren't put in. If this value is 0 then there is no filtering of this kind. Definition at line 2076 of file ArSick.cpp. |
|
Current readings closer than this are discarded as too close. When readings are put into the current buffer they are compared against the last reading and must be at least this distance away from the last reading. If this value is 0 then there is no filtering of this kind. Definition at line 2024 of file ArSick.cpp. |
|
Sets the ranging/reflector information. Sets the range/bit information. The old immutable combination is (in effect) the same as the new default. If you look at the enums for these units you can see the effect this has on range. Definition at line 396 of file ArSick.cpp. |
|
The packet handler for when connected to the simulator Definition at line 404 of file ArSick.cpp. |