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

ArLaserConnector Class Reference

#include <ArLaserConnector.h>

List of all members.


Detailed Description

Connect to robot and laser based on run-time availablitily and command-line arguments.

ArLaserConnector makes a laser connection either through a TCP port (for the simulator or for robots with Ethernet-serial bridge devices instead of onboard computers), or through a direct serial port connection. Normally, it first attempts a TCP connection on localhost port 8101, to use a simulator if running. If the simulator is not running, then it normally then connects using the serial port (the first serial port, COM1, by default). Various other connection parameters are configurable through command-line arguments.

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.

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 urg)

The default laser type for the primary laser (laser 1) is "lms2xx".

Instruct a program to connect to a laser using the -connectLaser<N> option;
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 options for the primary laser (laser 1).



For laser type "lms2xx":

-laserPort <laserPort>
-lp <laserPort>
-laserPortType <serial|tcp>
-lpt <serial|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 "urg":

-laserPort <laserPort>
-lp <laserPort>
-laserPortType <serial|tcp>
-lpt <serial|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'

You can prepare an ArRobot object for connection (with various connection options configured via the command line parameters) and initiate the connection attempt by that object by calling connectRobot().

After it's connected, you must then begin the robot processing cycle by calling ArRobot::runAsync() or ArRobot::run().

You can then configure ArLaserConnector for the SICK laser based on the robot connection, and command line parameters with setupLaser(). After calling setupLaser(), you must then run the laser processing thread (with ArLaser::runAsync() or ArLaser()::run()) and then use ArLaserConnector::connectLaser() to connect with the laser if specifically requested on the command line using the -connectLaser option (or simply call ArLaser::blockingConnect() (or similar) to attempt a laser connection regardless of whether or not the -connectLaser option was given; use this latter technique if your program always prefers or requires use of the laser).

Examples:

demo.cpp, and wander.cpp.


Public Member Functions

bool addLaser (ArLaser *laser, int laserNumber=1)
 Adds a laser so parsing will get it.
bool addPlaceholderLaser (ArLaser *placeholderLaser, int laserNumber=1, bool takeOwnershipOfPlaceholder=false)
 Adds a laser for parsing but where connectLaser will be called later.
 ArLaserConnector (ArArgumentParser *parser, ArRobot *robot, ArRobotConnector *robotConnector, bool autoParseArgs=true, ArLog::LogLevel infoLogLevel=ArLog::Verbose)
 Constructor that takes argument parser.
bool connectLaser (ArLaser *laser, int laserNumber=1, bool forceConnection=true)
 Connects the laser synchronously (will take up to a minute).
bool connectLasers (bool continueOnFailedConnect=false, bool addConnectedLasersToRobot=true, bool addAllLasersToRobot=false, bool turnOnLasers=true, bool powerCycleLaserOnFailedConnect=true)
 Connects all the lasers the robot has that should be auto connected.
void logOptions (void) const
 Log the options the simple connector has.
bool parseArgs (ArArgumentParser *parser)
 Function to parse the arguments given in an arbitrary parser.
bool parseArgs (void)
 Function to parse the arguments given in the constructor.
bool setupLaser (ArLaser *laser, int laserNumber=1)
 Sets up a laser to be connected.
 ~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

Classes

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


Constructor & Destructor Documentation

ArLaserConnector::ArLaserConnector ArArgumentParser parser,
ArRobot robot,
ArRobotConnector robotConnector,
bool  autoParseArgs = true,
ArLog::LogLevel  infoLogLevel = ArLog::Verbose
 

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:
parser the parser with the arguments to parse
robot the robot these lasers are attached to (or NULL for none)
robotConnector the connector used for connecting to the robot (so we can see if it was a sim or not)
autoParseArgs if this class should autoparse the args if they aren't parsed explicitly
infoLogLevel The 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

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.

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.

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.

bool ArLaserConnector::connectLasers bool  continueOnFailedConnect = false,
bool  addConnectedLasersToRobot = true,
bool  addAllLasersToRobot = false,
bool  turnOnLasers = true,
bool  powerCycleLaserOnFailedConnect = true
 

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

TODO see if this firmware can actually do the power cycling

bool ArLaserConnector::parseArgs ArArgumentParser parser  ) 
 

Function to parse the arguments given in an arbitrary parser.

Parse command line arguments held by the given ArArgumentParser.

Returns:
true if the arguments were parsed successfully false if not
The following arguments are used for the robot connection:

-robotPort port
-rp port
Use the given serial port device name for a serial port connection (e.g. COM1, or /dev/ttyS0 if on Linux.) The default is the first serial port, or COM1, which is the typical Pioneer setup.

The following arguments are accepted for laser connections. A program may request support for more than one laser 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 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 setup.

-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.)

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

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:
Generated on Thu Jan 7 10:34:42 2010 for Aria by  doxygen 1.4.2