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

ArSimpleConnector Class Reference

This class simplifies connecting to the robot and/or laser. More...

#include <ArSimpleConnector.h>

List of all members.

Public Member Functions

 ArSimpleConnector (ArArgumentParser *parser)
 Constructor that takes argument parser.
 ArSimpleConnector (ArArgumentBuilder *arguments)
 Constructor that takes argument builder.
 ArSimpleConnector (int *argc, char **argv)
 Constructor that takes args from the main.
bool connectLaser (ArSick *sick)
 Connects the laser synchronously (will take up to a minute).
bool connectLaserArbitrary (ArSick *sick, int laserNumber)
 Connects the laser synchronously (make sure you setMaxNumLasers).
bool connectRobot (ArRobot *robot)
 Sets up the robot then connects it.
bool connectSecondLaser (ArSick *sick)
 Connects the laser synchronously (will take up to a minute).
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.
void setMaxNumLasers (int maxNumLasers=1)
 Sets the number of possible lasers.
bool setupLaser (ArSick *sick)
 Sets up the laser to be connected.
bool setupLaserArbitrary (ArSick *sick, int laserNumber)
 Sets up a laser t obe connected (make sure you setMaxNumLasers).
bool setupRobot (ArRobot *robot)
 Sets up the robot to be connected.
bool setupSecondLaser (ArSick *sick)
 Sets up a second laser to be connected.
 ~ArSimpleConnector (void)
 Destructor.

Protected Member Functions

void logLaserOptions (unsigned int laserNumber) const
 Logs the laser parameters.
bool parseLaserArgs (ArArgumentParser *parser, int laserNumber)
 Parses the laser arguments.
void reset (void)

Protected Attributes

std::list< LaserData * > myLasers
ArSerialConnection myLaserSerConn
ArSerialConnection myLaserSerConn2
ArTcpConnection myLaserTcpConn
ArTcpConnection myLaserTcpConn2
int myMaxNumLasers
bool myOwnParser
ArArgumentParsermyParser
const char * myRemoteHost
bool myRemoteIsSim
int myRemoteRobotTcpPort
ArRobotmyRobot
int myRobotBaud
const char * myRobotPort
ArSerialConnection myRobotSerConn
ArTcpConnection myRobotTcpConn
bool myUsingSim

Classes

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


Detailed Description

This class simplifies connecting to the robot and/or laser.

First of all, when you create your ArSimpleConnector you pass it either the argc and argv from main or you can pass it an ArArgumentBuilder, which you might do if you were making a windows executable that had a WinMain instead of a main.

Then you need to tell it to parseArgs, which parses those arguments in order to know where to connect the robot and/or laser.

Then you can either set up the robot to be connected with setupRobot or just connect it with connectRobot. You'll still need to run or runAsync the robot.

You can then set up the laser with setupLaser, but you'll have to run or runAsync the laser and connect it yourself.

Definition at line 60 of file ArSimpleConnector.h.


Member Function Documentation

bool ArSimpleConnector::connectLaser ArSick sick  ) 
 

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.

Definition at line 503 of file ArSimpleConnector.cpp.

References connectLaserArbitrary().

bool ArSimpleConnector::connectSecondLaser ArSick sick  ) 
 

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.

Definition at line 514 of file ArSimpleConnector.cpp.

References connectLaserArbitrary().

bool ArSimpleConnector::parseArgs ArArgumentParser parser  ) 
 

Function to parse the arguments given in an arbitrary parser.

Returns:
true if the arguments were parsed successfully false if not

Definition at line 100 of file ArSimpleConnector.cpp.

References parseLaserArgs().

bool ArSimpleConnector::parseArgs void   ) 
 

Function to parse the arguments given in the constructor.

Returns:
true if the arguments were parsed successfully false if not

Definition at line 92 of file ArSimpleConnector.cpp.

void ArSimpleConnector::setMaxNumLasers int  maxNumLasers = 1  ) 
 

Sets the number of possible lasers.

This gets rid of all of the data that was set for the lasers, so call this before you parse.

Definition at line 76 of file ArSimpleConnector.cpp.

References ArUtil::deleteSet().

bool ArSimpleConnector::setupLaser ArSick sick  ) 
 

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.

Definition at line 380 of file ArSimpleConnector.cpp.

References setupLaserArbitrary().

bool ArSimpleConnector::setupRobot ArRobot robot  ) 
 

Sets up the robot to be connected.

Description of the logic for connection to the robot. If --remoteHost is given then the connector tries to open a tcp connection to port 8101 by default, or --remoteRobotTcpPort if that was an option provided and if this tcp connection fails then the whole connection fails. If no remoteHost was given it first tries to open a tcp connection to localhost on port 8101 (or --remoteRoboTcpPort) which is the where the simulator runs, if this tcp connection succeeds then the connector assumes its connecting to the simulator, if this connection fails then it assumes a serial connection to the real robot is desired and connects to ArUtil::COM1 or --robotPort if that argument was supplied.

Definition at line 303 of file ArSimpleConnector.cpp.

References ArSerialConnection::getPort(), ArLog::log(), ArTcpConnection::openSimple(), ArSerialConnection::setBaud(), ArSerialConnection::setPort(), and ArTcpConnection::setPort().

Referenced by connectRobot().

bool ArSimpleConnector::setupSecondLaser ArSick sick  ) 
 

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.

Definition at line 392 of file ArSimpleConnector.cpp.

References setupLaserArbitrary().


The documentation for this class was generated from the following files:
Generated on Wed Oct 19 12:56:55 2005 for Aria by  doxygen 1.4.0