Aria
2.8.0
|
Connect to sonar based on robot parameters and command-line arguments. More...
#include <ArSonarConnector.h>
Classes | |
class | SonarData |
Class that holds information about the sonar data. More... | |
Public Member Functions | |
bool | addSonar (ArSonarMTX *sonar, int sonarNumber=1) |
Adds a sonar so parsing will get it. More... | |
ArSonarConnector (ArArgumentParser *parser, ArRobot *robot, ArRobotConnector *robotConnector, bool autoParseArgs=true, ArLog::LogLevel infoLogLevel=ArLog::Verbose, ArRetFunctor1< bool, const char *> *turnOnPowerOutputCB=NULL, ArRetFunctor1< bool, const char *> *turnOffPowerOutputCB=NULL) | |
Constructor that takes argument parser. More... | |
bool | connectReplaySonars (bool continueOnFailedConnect=false, bool addConnectedSonarsToRobot=true, bool addAllSonarsToRobot=false, bool turnOnSonars=true, bool powerCycleSonarOnFailedConnect=true) |
bool | connectSonar (ArSonarMTX *sonar, int sonarNumber=1, bool forceConnection=true) |
Connects the sonar synchronously (will take up to a minute) More... | |
bool | connectSonars (bool continueOnFailedConnect=false, bool addConnectedSonarsToRobot=true, bool addAllSonarsToRobot=false, bool turnOnSonars=true, bool powerCycleSonarOnFailedConnect=true) |
Connects all the sonars the robot has that should be auto connected. | |
ArSonarMTX * | getSonar (int sonarNumber) |
Internal function to get the sonar (only useful between parseArgs and connectSonars) | |
void | logOptions (void) const |
Log the options the simple connector has. | |
bool | parseArgs (void) |
Function to parse the arguments given in the constructor. More... | |
bool | parseArgs (ArArgumentParser *parser) |
Function to parse the arguments given in an arbitrary parser. More... | |
bool | replaceSonar (ArSonarMTX *sonar, int sonarNumber) |
Internal function to replace the sonar (only useful between parseArgs and connectSonars) but not the sonar data. | |
bool | setupSonar (ArSonarMTX *sonar, int sonarNumber=1) |
Sets up a sonar to be connected. More... | |
~ArSonarConnector (void) | |
Destructor. | |
Protected Member Functions | |
bool | internalConfigureSonar (SonarData *sonarData) |
void | logSonarOptions (SonarData *sonardata, bool header=true, bool metaOpts=true) const |
Logs the sonar command line option help text. | |
bool | parseSonarArgs (ArArgumentParser *parser, SonarData *sonarData) |
Parses the sonar arguments. | |
bool | turnOnPower (SonarData *sonarData) |
Turns on the power for the specific board in the firmware. More... | |
Protected Attributes | |
bool | myAutoParseArgs |
ArLog::LogLevel | myInfoLogLevel |
ArConstFunctorC< ArSonarConnector > | myLogOptionsCB |
bool | myOwnParser |
ArRetFunctorC< bool, ArSonarConnector > | myParseArgsCB |
bool | myParsedArgs |
ArArgumentParser * | myParser |
ArRobot * | myRobot |
ArRobotConnector * | myRobotConnector |
bool | mySonarLogPacketsReceived |
bool | mySonarLogPacketsSent |
std::map< int, SonarData * > | mySonars |
std::string | mySonarTypes |
ArRetFunctor1< bool, const char * > * | myTurnOffPowerOutputCB |
ArRetFunctor1< bool, const char * > * | myTurnOnPowerOutputCB |
Connect to sonar based on robot parameters and command-line arguments.
ArSonarConnector makes a sonar connection either through a serial port connection. When you create your ArSonarConnector, 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()). ArSonarConnector 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 ArSonarConnector: -sonarLogPacketsReceived -slpr -sonarLogPacketsSent -slps Options shown are for currently set up sonars. Activate sonars with -sonarType<N> option to see options for that sonar (e.g. "-help -sonarType1 sonarMTX"). Valid sonar types are: mtx See docs for details.
To connect to any sonars that were set up in the robot parameter file or via command line arguments, call connectSonars(). If successful, connectSonars() will return true and add an entry for each sonar connected in the ArRobot object's list of sonars. These ArSonarMTX objects can be accessed from your ArRobot object via ArRobot::findSonar() or ArRobot::getSonarMap().
ArSonarConnector::ArSonarConnector | ( | ArArgumentParser * | parser, |
ArRobot * | robot, | ||
ArRobotConnector * | robotConnector, | ||
bool | autoParseArgs = true , |
||
ArLog::LogLevel | infoLogLevel = ArLog::Verbose , |
||
ArRetFunctor1< bool, const char *> * | turnOnPowerOutputCB = NULL , |
||
ArRetFunctor1< bool, const char *> * | turnOffPowerOutputCB = NULL |
||
) |
Constructor that takes argument parser.
parser | the parser with the arguments to parse |
robot | the robot these sonars 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 sonars and such, this is also passed to all the sonars created as their infoLogLevel too |
bool ArSonarConnector::addSonar | ( | ArSonarMTX * | sonar, |
int | sonarNumber = 1 |
||
) |
Adds a sonar so parsing will get it.
Normally adding sonars 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 ArSonarConnector::connectSonars.()
bool ArSonarConnector::connectSonar | ( | ArSonarMTX * | sonar, |
int | sonarNumber = 1 , |
||
bool | forceConnection = true |
||
) |
Connects the sonar 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 ArSonarConnector::connectSonars().
bool ArSonarConnector::parseArgs | ( | void | ) |
Function to parse the arguments given in the constructor.
Parse command line arguments using the ArArgumentParser given in the ArSonarConnector constructor.
See parseArgs(ArArgumentParser*) for details about argument parsing.
bool ArSonarConnector::parseArgs | ( | ArArgumentParser * | parser | ) |
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 sonar connections. A program may request support for more than one sonar using setMaxNumSonarBoards(); if multi-sonar support is enabled in this way, then these arguments must have the sonar index number appended. For example, "-sonarPort" for sonar 1 would instead by "-sonarPort1", and for sonar 2 it would be "-sonarPort2".
COM2
or on Linux, /dev/ttyS1
. The default sonar port is COM2, which is the typical Pioneer sonar port setup. bool ArSonarConnector::setupSonar | ( | ArSonarMTX * | sonar, |
int | sonarNumber = 1 |
||
) |
Sets up a sonar 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 ArSonarConnector::connectSonars().
|
protected |
Turns on the power for the specific board in the firmware.
MPL the new way