#include <ArSimpleConnector.h>
ArSimpleConnector makes a robot 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 ArSimpleConnector, 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()). ArSimpleConnector 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.
See the documentation for parseArgs() for a list of recognized command line parameters.
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 ArSimpleConnector 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 ArSick::runAsync() or ArSick()::run()) and then use ArSimpleConnector::connectLaser() to connect with the laser if specifically requested on the command line using the -connectLaser option (or simply call ArSick::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).
actionExample.cpp, actionGroupExample.cpp, actsColorFollowingExample.cpp, armExample.cpp, auxSerialExample.cpp, demo.cpp, dpptuExample.cpp, gotoActionExample.cpp, gripperExample.cpp, gyroExample.cpp, joydriveActionExample.cpp, lineFinderExample.cpp, robotConnectionCallbacks.cpp, robotSyncTaskExample.cpp, simpleConnect.cpp, teleopActionsExample.cpp, triangleDriveToActionExample.cpp, and wander.cpp.
Definition at line 82 of file ArSimpleConnector.h.
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 |
ArConstFunctorC< ArSimpleConnector > | myLogOptionsCB |
int | myMaxNumLasers |
bool | myOwnParser |
ArRetFunctorC< bool, ArSimpleConnector > | myParseArgsCB |
ArArgumentParser * | myParser |
const char * | myRemoteHost |
bool | myRemoteIsSim |
int | myRemoteRobotTcpPort |
ArRobot * | myRobot |
int | myRobotBaud |
const char * | myRobotPort |
ArSerialConnection | myRobotSerConn |
ArTcpConnection | myRobotTcpConn |
bool | myUsingSim |
Classes | |
class | LaserData |
Class that holds information about the laser data. More... |
|
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 658 of file ArSimpleConnector.cpp. |
|
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(). Definition at line 514 of file ArSimpleConnector.cpp. |
|
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. Definition at line 669 of file ArSimpleConnector.cpp. |
|
Function to parse the arguments given in an arbitrary parser. Parse command line arguments held by the given ArArgumentParser.
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".
Definition at line 201 of file ArSimpleConnector.cpp. |
|
Function to parse the arguments given in the constructor. Parse command line arguments using the ArArgumentParser given in the ArSimpleConnector constructor. See parseArgs(ArArgumentParser*) for details about argument parsing.
Definition at line 114 of file ArSimpleConnector.cpp. |
|
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 94 of file ArSimpleConnector.cpp. |
|
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 534 of file ArSimpleConnector.cpp. |
|
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).
Definition at line 452 of file ArSimpleConnector.cpp. |
|
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 546 of file ArSimpleConnector.cpp. |