Aria  2.8.0
ArSimpleConnector Class Reference

Legacy connector for robot and laser. More...

#include <ArSimpleConnector.h>

Public Member Functions

 ArSimpleConnector (int *argc, char **argv)
 Constructor that takes args from the main.
 
 ArSimpleConnector (ArArgumentBuilder *arguments)
 Constructor that takes argument builder. More...
 
 ArSimpleConnector (ArArgumentParser *parser)
 Constructor that takes argument parser. More...
 
bool connectLaser (ArSick *laser)
 Connects the laser synchronously (will take up to a minute) More...
 
bool connectLaserArbitrary (ArSick *laser, int laserNumber)
 Connects the laser synchronously (make sure you setMaxNumLasers)
 
bool connectRobot (ArRobot *robot)
 Sets up the robot then connects it. More...
 
bool connectSecondLaser (ArSick *laser)
 Connects the laser synchronously (will take up to a minute) More...
 
void logOptions (void) const
 Log the options the simple connector has.
 
bool parseArgs (void)
 Function to parse the arguments given in the constructor.
 
bool parseArgs (ArArgumentParser *parser)
 Function to parse the arguments given in an arbitrary parser. More...
 
void setMaxNumLasers (int maxNumLasers=1)
 Sets the number of possible lasers.
 
bool setupLaser (ArSick *laser)
 Sets up the laser to be connected. More...
 
bool setupLaserArbitrary (ArSick *laser, int laserNumber)
 Sets up a laser t obe connected (make sure you setMaxNumLasers)
 
bool setupRobot (ArRobot *robot)
 Sets up the robot to be connected. More...
 
bool setupSecondLaser (ArSick *laser)
 Sets up a second laser to be connected. More...
 
 ~ArSimpleConnector (void)
 Destructor.
 

Protected Member Functions

void finishConstructor (void)
 Finishes the stuff the constructor needs to do.
 

Protected Attributes

ArLaserConnectormyLaserConnector
 
bool myOwnParser
 
ArArgumentParsermyParser
 
ArRobotConnectormyRobotConnector
 

Detailed Description

Constructor & Destructor Documentation

◆ ArSimpleConnector() [1/2]

ArSimpleConnector::ArSimpleConnector ( ArArgumentBuilder builder)

Constructor that takes argument builder.

Warning
do not delete builder during the lifetime of this ArSimpleConnector, which may need to access its contents later.

◆ ArSimpleConnector() [2/2]

ArSimpleConnector::ArSimpleConnector ( ArArgumentParser parser)

Constructor that takes argument parser.

Warning
do not delete parser during the lifetime of this ArSimpleConnector, which may need to access its contents later.

Member Function Documentation

◆ connectLaser()

bool ArSimpleConnector::connectLaser ( ArSick laser)

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

This will setup and connect the laser if the command line switch was given to do so or simply return true if no connection was wanted.

◆ connectRobot()

bool ArSimpleConnector::connectRobot ( ArRobot robot)

Sets up the robot then connects it.

Prepares the given ArRobot object for connection, then begins a blocking connection attempt.

If you wish to simply prepare the ArRobot object, but not begin the connection, then use setupRobot().

Examples:
actionExample.cpp, actionGroupExample.cpp, actsColorFollowingExample.cpp, armExample.cpp, auxSerialExample.cpp, gotoActionExample.cpp, gpsExample.cpp, gpsRobotTaskExample.cpp, gripperExample.cpp, imuExample.cpp, joydriveActionExample.cpp, lineFinderExample.cpp, moduleExample.cpp, robotConnectionCallbacks.cpp, robotSyncTaskExample.cpp, and triangleDriveToActionExample.cpp.

◆ connectSecondLaser()

bool ArSimpleConnector::connectSecondLaser ( ArSick laser)

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

This will setup and connect the laser if the command line switch was given to do so or simply return true if no connection was requested.

◆ parseArgs()

bool ArSimpleConnector::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.

-remoteHost hostname
-rh hostname

Use a TCP connection to a remote computer with the given network host name instead of a serial port connection

-remoteRobotTcpPort port
-rrtp port

Use the given TCP port number if connecting to a remote robot using TCP due to -remoteHost having been given.

-remoteIsSim
-ris

The remote TCP robot given by -remoteHost or -rh is actually a simulator. Use any alternative behavior intended for the simulator (e.g. tell the laser device object to request laser data from the simulator rather than trying to connect to a real laser device on the local computer)

-robotBaud baudrate
-rb baudrate
Use the given baud rate when connecting over a serial port, instead of trying to use the normal rate.

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

◆ setupLaser()

bool ArSimpleConnector::setupLaser ( ArSick laser)

Sets up the laser to be connected.

Description of the logic for connection to the laser: If –remoteHost then the laser will a tcp connection will be opened to that remoteHost at port 8102 or –remoteLaserTcpPort if that argument is given, if this connection fails then the setup fails.

If –remoteHost wasn't provided and the robot connected to a simulator as described elsewhere then the laser is just configured to be simulated, if the robot isn't connected to a simulator it tries to open a serial connection to ArUtil::COM3 or –laserPort if that argument is given.

Examples:
gpsRobotTaskExample.cpp, lineFinderExample.cpp, and triangleDriveToActionExample.cpp.

◆ setupRobot()

bool ArSimpleConnector::setupRobot ( ArRobot robot)

Sets up the robot to be connected.

This method is normally used internally by connectRobot(), but you may use it if you wish.

If -remoteHost was given, then open that TCP port. If it was not given, then try to open a TCP port to the simulator on localhost. If that fails, then use a local serial port connection. Sets the given ArRobot's device connection pointer to this object. Sets up internal settings determined by command line arguments such as serial port and baud rate, etc.

After calling this function (and it returns true), then you may connect ArRobot to the robot using ArRobot::blockingConnect() (or similar).

Returns
false if -remoteHost was given and there was an error connecting to the remote host, true otherwise.

◆ setupSecondLaser()

bool ArSimpleConnector::setupSecondLaser ( ArSick laser)

Sets up a second laser to be connected.

Description of the logic for connecting to a second laser: Given the fact that there are no parameters for the location of a second laser, the laser's port must be passed in to ArSimpleConnector from the main or from ArArgumentBuilder.

Similarly, a tcp connection must be explicitly defined with the –remoteLaserTcpPort2 argument.


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