Aria  2.8.0
ArLaserConnector Class Reference

Create laser interface objects (for any kind of laser supported by ARIA) and connect to lasers based on parameters from robot parameter file and command-line arguments. More...

#include <ArLaserConnector.h>

Classes

class  LaserData
 Class that holds information about the laser data. More...
 

Public Member Functions

bool addLaser (ArLaser *laser, int laserNumber=1)
 Adds a laser so parsing will get it. More...
 
bool addPlaceholderLaser (ArLaser *placeholderLaser, int laserNumber=1, bool takeOwnershipOfPlaceholder=false)
 Adds a laser for parsing but where connectLaser will be called later. More...
 
 ArLaserConnector (ArArgumentParser *parser, ArRobot *robot, ArRobotConnector *robotConnector, bool autoParseArgs=true, ArLog::LogLevel infoLogLevel=ArLog::Verbose, ArRetFunctor1< bool, const char *> *turnOnPowerOutputCB=NULL, ArRetFunctor1< bool, const char *> *turnOffPowerOutputCB=NULL)
 Constructor that takes argument parser. More...
 
bool connectLaser (ArLaser *laser, int laserNumber=1, bool forceConnection=true)
 Connects the laser synchronously (will take up to a minute) More...
 
bool connectLasers (bool continueOnFailedConnect=false, bool addConnectedLasersToRobot=true, bool addAllLasersToRobot=false, bool turnOnLasers=true, bool powerCycleLaserOnFailedConnect=true, int *failedOnLaser=NULL)
 Connects all the lasers the robot has that should be auto connected. More...
 
ArLasergetLaser (int laserNumber)
 Internal function to get the laser (only useful between parseArgs and connectLasers)
 
void logOptions (void) const
 Log the options the simple connector has.
 
bool parseArgs (void)
 Function to parse the arguments given in the constructor. More...
 
bool parseArgs (ArArgumentParser *parser)
 Function to parse the arguments given in an arbitrary parser. More...
 
bool replaceLaser (ArLaser *laser, int laserNumber)
 Internal function to replace the laser (only useful between parseArgs and connectLasers) but not the laser data.
 
bool setupLaser (ArLaser *laser, int laserNumber=1)
 Sets up a laser to be connected. More...
 
 ~ArLaserConnector (void)
 Destructor.
 

Protected Member Functions

bool internalConfigureLaser (LaserData *laserData)
 
void logLaserOptions (LaserData *laserdata, bool header=true, bool metaOpts=true) const
 Logs the laser command line option help text.
 
bool parseLaserArgs (ArArgumentParser *parser, LaserData *laserData)
 Parses the laser arguments.
 

Protected Attributes

bool myAutoParseArgs
 
ArLog::LogLevel myInfoLogLevel
 
std::map< int, LaserData * > myLasers
 
std::string myLaserTypes
 
ArConstFunctorC< ArLaserConnectormyLogOptionsCB
 
bool myOwnParser
 
ArRetFunctorC< bool, ArLaserConnectormyParseArgsCB
 
bool myParsedArgs
 
ArArgumentParsermyParser
 
ArRobotmyRobot
 
ArRobotConnectormyRobotConnector
 
ArRetFunctor1< bool, const char * > * myTurnOffPowerOutputCB
 
ArRetFunctor1< bool, const char * > * myTurnOnPowerOutputCB
 

Detailed Description

Create laser interface objects (for any kind of laser supported by ARIA) and connect to lasers based on parameters from robot parameter file and command-line arguments.

ArLaserConnector makes a laser connection (e.g. through serial port, TCP network connection, or to simulator connection as a special case if the robot connection is to a simulator.) Parameters are configurable through command-line arguments or in the robot parameter file.

When you create your ArLaserConnector, pass it command line parameters via either the argc and argv variables from main(), or pass it an ArArgumentBuilder or ArArgumentParser object. (ArArgumentBuilder is able to obtain command line parameters from a Windows program that uses WinMain() instead of main()). ArLaserConnector registers a callback with the global Aria class. Use Aria::parseArgs() to parse all command line parameters to the program, and Aria::logOptions() to print out information about all registered command-line parameters. ArLaserConnector will be included in these.

Then, to connect to any lasers that were set up in the robot parameter file or via command line arguments, call connectLasers(). If successful, connectLasers() will return true and add an entry for each laser connected in the ArRobot object's list of lasers. These ArLaser objects can be accessed from your ArRobot object via ArRobot::findLaser() or ArRobot::getLaserMap().

(The internal interface used by ARIA to connect to configured lasers and add them to ArRobot is also available if you need to use it: See addLaser(); but this is normally not neccesary for almost all cases.)

The following command-line arguments are checked:

Laser types and options may also be set in the robot parameter file.  See the
ARIA reference documentation for details.

If a program supports multiple lasers, then options for additional lasers
after the first are given by appending the laser number (e.g. -laserType2)
To enable use of a laser, choose its type with the -laserType<N> options
(e.g.: -laserType lms2xx -laserType2 urg2.0)

The default laser type for the primary laser (laser 1) is specified in the
robot type parameter file in the ARIA "params" directory. For many robots
it is "lms2xx", the SICK LMS200. For some it is "lms1xx", for the SICK
LMS100 or LMS111.

Instruct a program to connect to a laser using the -connectLaser<N> option
or by setting LaserAutoConnect to true in the robot's parameter file.
If a program requires use of a laser it usually always attempts to connect to
the primary laser, however.

The index number is optional in any options for the primary laser; i.e. 1 is
assumed if the index number is omitted.



For laser type "lms2xx" (SICK LMS-200):

-laserPort <laserPort>
-lp <laserPort>
-laserPortType <serial|serial422|tcp>
-lpt <serial|serial422|tcp>
-remoteLaserTcpPort <remoteLaserTcpPort>
-rltp <remoteLaserTcpPort>
-laserFlipped <true|false>
-lf <true|false>
-laserMaxRange <maxRange>
-lmr <maxRange>
	<maxRange> is an unsigned int less than 32000
-laserDegrees <100|180>
-ld <100|180>
-laserIncrement <half|one>
-li <half|one>
-laserUnits <1mm|1cm|10cm>
-lu <1mm|1cm|10cm>
-laserReflectorBits <1ref|2ref|3ref>
-lrb <1ref|2ref|3ref>
-laserPowerControlled <true|false>
-lpc <true|false>
-laserStartingBaud <9600|19200|38400>
-lsb <9600|19200|38400>
-laserAutoBaud <9600|19200|38400>
-lab <9600|19200|38400>
-laserAdditionalIgnoreReadings <readings>
-lair <readings>
	<readings> is a string that contains readings to ignore separated by commas, where ranges are acceptable with a -, example '75,76,90-100,-75,-76,-90--100'

For laser type "lms1xx" (SICK LMS-100, LMS-111, etc.):

-laserPort <laserPort>
-lp <laserPort>
-laserPortType <serial|serial422|tcp>
-lpt <serial|serial422|tcp>
-remoteLaserTcpPort <remoteLaserTcpPort>
-rltp <remoteLaserTcpPort>
-laserFlipped <true|false>
-lf <true|false>
-laserMaxRange <maxRange>
-lmr <maxRange>
	<maxRange> is an unsigned int less than 20000
-laserDegreesStart <startAngle>
-lds <startAngle>
	<startAngle> is a double between -135 and 135
-laserDegreesEnd <endAngle>
-lde <endAngle>
	<endAngle> is a double between -135 and 135
-laserIncrement <half|quarter>
-li <half|quarter>
-laserReflectorBits <none|8bits>
-lrb <none|8bits>
-laserPowerControlled <true|false>
-lpc <true|false>
-laserAdditionalIgnoreReadings <readings>
-lair <readings>
	<readings> is a string that contains readings to ignore separated by commas, where ranges are acceptable with a -, example '75,76,90-100,-75,-76,-90--100'

For laser type "urg2.0" (URG with SCIP 2.0):

-laserPort <laserPort>
-lp <laserPort>
-laserPortType <serial|serial422|tcp>
-lpt <serial|serial422|tcp>
-remoteLaserTcpPort <remoteLaserTcpPort>
-rltp <remoteLaserTcpPort>
-laserFlipped <true|false>
-lf <true|false>
-laserMaxRange <maxRange>
-lmr <maxRange>
	<maxRange> is an unsigned int less than 262144
-laserDegreesStart <startAngle>
-lds <startAngle>
	<startAngle> is a double between -180 and 180
-laserDegreesEnd <endAngle>
-lde <endAngle>
	<endAngle> is a double between -180 and 180
-laserIncrementByDegrees <incrementByDegrees>
-libd <incrementByDegrees>
	<incrementByDegrees> is a double between 0 and 180
-laserStartingBaud <0|019200|057600|115200|250000|500000|750000>
-lsb <0|019200|057600|115200|250000|500000|750000>
-laserAutoBaud <0|019200|057600|115200|250000|500000|750000>
-lab <0|019200|057600|115200|250000|500000|750000>
-laserAdditionalIgnoreReadings <readings>
-lair <readings>
	<readings> is a string that contains readings to ignore separated by commas, where ranges are acceptable with a -, example '75,76,90-100,-75,-76,-90--100'

For laser type "urg" (URG with old SCIP 1.0):

-laserPort <laserPort>
-lp <laserPort>
-laserPortType <serial|serial422|tcp>
-lpt <serial|serial422|tcp>
-remoteLaserTcpPort <remoteLaserTcpPort>
-rltp <remoteLaserTcpPort>
-laserFlipped <true|false>
-lf <true|false>
-laserMaxRange <maxRange>
-lmr <maxRange>
	<maxRange> is an unsigned int less than 4095
-laserDegreesStart <startAngle>
-lds <startAngle>
	<startAngle> is a double between -135 and 135
-laserDegreesEnd <endAngle>
-lde <endAngle>
	<endAngle> is a double between -135 and 135
-laserIncrementByDegrees <incrementByDegrees>
-libd <incrementByDegrees>
	<incrementByDegrees> is a double between 0 and 135
-laserStartingBaud <019200|057600|115200|250000|500000|750000>
-lsb <019200|057600|115200|250000|500000|750000>
-laserAutoBaud <019200|057600|115200|250000|500000|750000>
-lab <019200|057600|115200|250000|500000|750000>
-laserAdditionalIgnoreReadings <readings>
-lair <readings>
	<readings> is a string that contains readings to ignore separated by commas, where ranges are acceptable with a -, example '75,76,90-100,-75,-76,-90--100'

For laser type "lms5XX" (SICK LMS-500):

-laserPort <laserPort>
-lp <laserPort>
-laserPortType <serial|serial422|tcp>
-lpt <serial|serial422|tcp>
-remoteLaserTcpPort <remoteLaserTcpPort>
-rltp <remoteLaserTcpPort>
-laserFlipped <true|false>
-lf <true|false>
-laserMaxRange <maxRange>
-lmr <maxRange>
	<maxRange> is an unsigned int less than 20000
-laserIncrement <half|one|quarter>
-li <half|one|quarter>
-laserReflectorBits <none|8bits>
-lrb <none|8bits>
-laserPowerControlled <true|false>
-lpc <true|false>
-laserAdditionalIgnoreReadings <readings>
-lair <readings>
	<readings> is a string that contains readings to ignore separated by commas, where ranges are acceptable with a -, example '75,76,90-100,-75,-76,-90--100'

For laser type "sZseries" (Keyence SZ):

-laserPort <laserPort>
-lp <laserPort>
-laserPortType <serial|serial422|tcp>
-lpt <serial|serial422|tcp>
-remoteLaserTcpPort <remoteLaserTcpPort>
-rltp <remoteLaserTcpPort>
-laserFlipped <true|false>
-lf <true|false>
-laserMaxRange <maxRange>
-lmr <maxRange>
	<maxRange> is an unsigned int less than 16382
-laserDegreesStart <startAngle>
-lds <startAngle>
	<startAngle> is a double between -135 and -135
-laserDegreesEnd <endAngle>
-lde <endAngle>
	<endAngle> is a double between 135 and 135
-laserIncrementByDegrees <incrementByDegrees>
-libd <incrementByDegrees>
	<incrementByDegrees> is a double between 0.5 and 0.5
-laserPowerControlled <true|false>
-lpc <true|false>
-laserStartingBaud <9600|19200|38400|57600|115200|230400|460800>
-lsb <9600|19200|38400|57600|115200|230400|460800>
-laserAdditionalIgnoreReadings <readings>
-lair <readings>
	<readings> is a string that contains readings to ignore separated by commas, where ranges are acceptable with a -, example '75,76,90-100,-75,-76,-90--100'

For laser type "s3series" (SICK S-300, S-3000, etc.):

-laserPort <laserPort>
-lp <laserPort>
-laserPortType <serial|serial422|tcp>
-lpt <serial|serial422|tcp>
-remoteLaserTcpPort <remoteLaserTcpPort>
-rltp <remoteLaserTcpPort>
-laserFlipped <true|false>
-lf <true|false>
-laserMaxRange <maxRange>
-lmr <maxRange>
	<maxRange> is an unsigned int less than 20000
-laserDegreesStart <startAngle>
-lds <startAngle>
	<startAngle> is a double between -135 and -135
-laserDegreesEnd <endAngle>
-lde <endAngle>
	<endAngle> is a double between 135 and 135
-laserIncrement <half>
-li <half>
-laserPowerControlled <true|false>
-lpc <true|false>
-laserStartingBaud <9600|19200|38400|57600|115200|230400|460800>
-lsb <9600|19200|38400|57600|115200|230400|460800>
-laserAdditionalIgnoreReadings <readings>
-lair <readings>
	<readings> is a string that contains readings to ignore separated by commas, where ranges are acceptable with a -, example '75,76,90-100,-75,-76,-90--100'

For laser type "tim3XX" (SICK TiM300):

-laserPort <laserPort>
-lp <laserPort>
-laserPortType <serial|serial422|tcp>
-lpt <serial|serial422|tcp>
-remoteLaserTcpPort <remoteLaserTcpPort>
-rltp <remoteLaserTcpPort>
-laserFlipped <true|false>
-lf <true|false>
-laserMaxRange <maxRange>
-lmr <maxRange>
	<maxRange> is an unsigned int less than 20000
-laserDegreesStart <startAngle>
-lds <startAngle>
	<startAngle> is a double between -135 and 135
-laserDegreesEnd <endAngle>
-lde <endAngle>
	<endAngle> is a double between -135 and 135
-laserIncrement <half|quarter|three>
-li <half|quarter|three>
-laserReflectorBits <none|8bits>
-lrb <none|8bits>
-laserPowerControlled <true|false>
-lpc <true|false>
-laserStartingBaud <115200>
-lsb <115200>
-laserAdditionalIgnoreReadings <readings>
-lair <readings>
	<readings> is a string that contains readings to ignore separated by commas, where ranges are acceptable with a -, example '75,76,90-100,-75,-76,-90--100'
Since
2.7.0
Examples:
demo.cpp, laserConnect.cpp, lasers.cpp, and wander.cpp.

Constructor & Destructor Documentation

◆ ArLaserConnector()

ArLaserConnector::ArLaserConnector ( ArArgumentParser parser,
ArRobot robot,
ArRobotConnector robotConnector,
bool  autoParseArgs = true,
ArLog::LogLevel  infoLogLevel = ArLog::Verbose,
ArRetFunctor1< bool, const char *> *  turnOnPowerOutputCB = NULL,
ArRetFunctor1< bool, const char *> *  turnOffPowerOutputCB = NULL 
)

Constructor that takes argument parser.

Warning
do not delete parser during the lifetime of this ArLaserConnector, which may need to access its contents later.
Parameters
parserthe parser with the arguments to parse
robotthe robot these lasers are attached to (or NULL for none)
robotConnectorthe connector used for connecting to the robot (so we can see if it was a sim or not)
autoParseArgsif this class should autoparse the args if they aren't parsed explicitly
infoLogLevelThe log level for information about creating lasers and such, this is also passed to all the lasers created as their infoLogLevel too

Member Function Documentation

◆ addLaser()

bool ArLaserConnector::addLaser ( ArLaser laser,
int  laserNumber = 1 
)

Adds a laser so parsing will get it.

Normally adding lasers is done from the .p file, you can use this if you want to add them explicitly in a program (which will override the .p file, and may cause some problems).

This is mainly for backwards compatibility (ie used for ArSimpleConnector). If you're using this class you should probably use the new functionality which is just ArLaserConnector::connectLasers.()

◆ addPlaceholderLaser()

bool ArLaserConnector::addPlaceholderLaser ( ArLaser placeholderLaser,
int  laserNumber = 1,
bool  takeOwnershipOfPlaceholder = false 
)

Adds a laser for parsing but where connectLaser will be called later.

Normally adding lasers is done from the .p file, you can use this if you want to add them explicitly in a program (which will override the .p file, and may cause some problems).

This is only for backwards compatibility (ie used for ArSimpleConnector). If you're using this class you should probably use the new functionality which is just ArLaserConnector::connectLasers().

◆ connectLaser()

bool ArLaserConnector::connectLaser ( ArLaser laser,
int  laserNumber = 1,
bool  forceConnection = true 
)

Connects the laser synchronously (will take up to a minute)

This is mainly for backwards compatibility (ie used for ArSimpleConnector).

If you're using this class you should probably use the new functionality which is just ArLaserConnector::connectLasers().

◆ connectLasers()

bool ArLaserConnector::connectLasers ( bool  continueOnFailedConnect = false,
bool  addConnectedLasersToRobot = true,
bool  addAllLasersToRobot = false,
bool  turnOnLasers = true,
bool  powerCycleLaserOnFailedConnect = true,
int *  failedOnLaser = NULL 
)

Connects all the lasers the robot has that should be auto connected.

Parameters
continueOnFailedConnectwhether to continue on a failed connection or not
addConnectedLasersToRobotwhether to add connected lasers to the list stored in ArRobot. Normally this should be left as true.
addAllLasersToRobotwhether to add all the lasers to the ArRobot list or not (even if connection was not made to that laser).
turnOnLaserswhether to attempt to turn on power to the laser (by sending commands to the robot microcontroller).
powerCycleLaserOnFailedConnectwhether to turn on the laser (with the microcontroller commands)
failedOnLaserIf this pointer is valid then the function will set the index of the first laser where connection failed, or -1 if there was an internal failure before attempting to connect to any lasers (for example, parsing program arguments). The function will also return false. If NULL, ignored.
Returns
true if successful connecting to lasers, false on any errors.

TODO see if this firmware can actually do the power cycling

Examples:
demo.cpp, laserConnect.cpp, lasers.cpp, and wander.cpp.

◆ parseArgs() [1/2]

bool ArLaserConnector::parseArgs ( void  )

Function to parse the arguments given in the constructor.

Parse command line arguments using the ArArgumentParser given in the ArLaserConnector constructor.

See parseArgs(ArArgumentParser*) for details about argument parsing.

Returns
true if the arguments were parsed successfully false if not

◆ parseArgs() [2/2]

bool ArLaserConnector::parseArgs ( ArArgumentParser parser)

Function to parse the arguments given in an arbitrary parser.

This function parses command line arguments held by the given ArArgumentParser.

Normally, it is automatically called by ArArgumentParser::parseArgs().

Returns
true if the arguments were parsed successfully false if not

The following arguments are accepted for laser connections. A program may request support for up to a specific number of lasers using setMaxNumLasers(); if multi-laser support is enabled in this way, then these arguments must have the laser index number appended. For example, "-laserPort" for laser 1 would instead by "-laserPort1", and for laser 2 it would be "-laserPort2".

-laserPort port
-lp port

Use the given serial port device name when connecting to a laser. For example, COM2 or on Linux, /dev/ttyS1. The default laser port is COM2, which is the typical Pioneer laser port.

-laserFlipped true|false
-lf true|false

If true, then the laser is mounted upside-down on the robot and the ordering of readings should be reversed.

-connectLaser
-cl

Explicitly request that the client program connect to a laser, if it does not always do so

-laserPowerControlled true|false
-lpc true|false

If true, then the laser is powered on when the serial port is initially opened, so enable certain features when connecting such as a waiting period as the laser initializes.

-laserDegrees degrees
-ld degrees

Indicate the size of the laser field of view, either 180 (default) or 100.

-laserIncrement increment
-li increment

Configures the laser's angular resolution. If one, then configure the laser to take a reading every degree. If half, then configure it for a reading every 1/2 degrees.

-laserUnits units
-lu units

Configures the laser's range resolution. May be 1mm for one milimiter, 1cm for ten milimeters, or 10cm for one hundred milimeters.

-laserReflectorBits bits
-lrb bits
Enables special reflectance detection, and configures the granularity of reflector detection information. Using more bits allows the laser to provide values for several different reflectance levels, but also may force a reduction in range. (Note, the SICK LMS-200 only detects high reflectance on special reflector material manufactured by SICK.)

◆ setupLaser()

bool ArLaserConnector::setupLaser ( ArLaser laser,
int  laserNumber = 1 
)

Sets up a laser to be connected.

This is mainly for backwards compatibility (ie used for ArSimpleConnector).

If you're using this class you should probably use the new functionality which is just ArLaserConnector::connectLasers().


The documentation for this class was generated from the following files: