#include <ArRobotConnector.h>
When you create your ArRobotConnector, 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()). ArRobotConnector 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:
Options for ArRobotConnector (see docs for more details): Robot options: -remoteHost <remoteHostNameOrIP> -rh <remoteHostNameOrIP> -robotPort <robotSerialPort> -rp <robotSerialPort> -robotBaud <baud> -rb <baud> -remoteRobotTcpPort <remoteRobotTcpPort> -rrtp <remoteRobotTcpPort> -remoteIsSim -ris -robotLogPacketsReceived -rlpr -robotLogPacketsSent -rlps -robotLogMovementReceived -rlmr -robotLogMovementSent -rlms -robotLogVelocitiesReceived -rlvr -robotLogActions -rla
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 ArRobotConnector 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 ArRangeDeviceLaser::runAsync() or ArRangeDeviceLaser()::run()) and then use ArRobotConnector::connectLaser() to connect with the laser if specifically requested on the command line using the -connectLaser option (or simply call ArRangeDeviceLaser::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).
demo.cpp, simpleConnect.cpp, simpleMotionCommands.cpp, and wander.cpp.
Public Member Functions | |
ArRobotConnector (ArArgumentParser *parser, ArRobot *robot, bool autoParseArgs=true) | |
Constructor that takes argument parser. | |
bool | connectRobot (ArRobot *robot) |
Sets up the robot then connects it. | |
bool | connectRobot (void) |
Sets up the robot then connects it. | |
const char * | getRemoteHost (void) const |
Gets the remote host, if one was used, or NULL if it wasn't. | |
bool | getRemoteIsSim (void) const |
Gets if the remote connection is a sim. | |
ArRobot * | getRobot (void) |
Gets the robot this connector is using (mostly for backwards compatibility stuff). | |
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 | setupRobot (ArRobot *robot) |
Sets up an arbitrary robot to be connected. | |
bool | setupRobot (void) |
Sets up the given robot to be connected. | |
~ArRobotConnector (void) | |
Destructor. | |
Protected Attributes | |
bool | myAutoParseArgs |
bool | myHaveParsedArgs |
If we've parsed the args already or not. | |
ArConstFunctorC< ArRobotConnector > | myLogOptionsCB |
bool | myOwnParser |
ArRetFunctorC< bool, ArRobotConnector > | myParseArgsCB |
ArArgumentParser * | myParser |
const char * | myRemoteHost |
bool | myRemoteIsSim |
int | myRemoteRobotTcpPort |
ArRobot * | myRobot |
int | myRobotBaud |
bool | myRobotLogActions |
bool | myRobotLogMovementReceived |
bool | myRobotLogMovementSent |
bool | myRobotLogPacketsReceived |
bool | myRobotLogPacketsSent |
bool | myRobotLogVelocitiesReceived |
const char * | myRobotPort |
ArSerialConnection | myRobotSerConn |
ArTcpConnection | myRobotTcpConn |
bool | myUsingSim |
|
Constructor that takes argument parser.
|
|
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(). |
|
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(). |
|
Function to parse the arguments given in an arbitrary parser. Parse command line arguments held by the given ArArgumentParser.
|
|
Function to parse the arguments given in the constructor. Parse command line arguments using the ArArgumentParser given in the ArRobotConnector constructor. See parseArgs(ArArgumentParser*) for details about argument parsing.
|
|
Sets up an arbitrary 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).
|
|
Sets up the given 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).
|