Aria
2.8.0
|
Connect to robot and lcd based on run-time availablitily and command-line arguments. More...
#include <ArLCDConnector.h>
Classes | |
class | LCDData |
Class that holds information about the lcd data. More... | |
Public Member Functions | |
bool | addLCD (ArLCDMTX *lcd, int lcdNumber=1) |
Adds a lcd so parsing will get it. More... | |
ArLCDConnector (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 | connectLCD (ArLCDMTX *lcd, int lcdNumber=1, bool forceConnection=true) |
Connects the lcd synchronously (will take up to a minute) More... | |
bool | connectLCDs (bool continueOnFailedConnect=false, bool addConnectedLCDsToRobot=true, bool addAllLCDsToRobot=false, bool turnOnLCDs=true, bool powerCycleLCDOnFailedConnect=true) |
Connects all the lcds the robot has that should be auto connected. | |
ArLCDMTX * | getLCD (int lcdNumber) |
Internal function to get the lcd (only useful between parseArgs and connectLCDs) | |
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 | replaceLCD (ArLCDMTX *lcd, int lcdNumber) |
Internal function to replace the lcd (only useful between parseArgs and connectLCDs) but not the lcd data. | |
void | setIdentifier (const char *identifier) |
bool | setupLCD (ArLCDMTX *lcd, int lcdNumber=1) |
Sets up a lcd to be connected. More... | |
void | turnOffPowerCB (int) |
void | turnOnPowerCB (int) |
~ArLCDConnector (void) | |
Destructor. | |
Protected Member Functions | |
bool | internalConfigureLCD (LCDData *lcdData) |
void | logLCDOptions (LCDData *lcddata, bool header=true, bool metaOpts=true) const |
Logs the lcd command line option help text. | |
bool | parseLCDArgs (ArArgumentParser *parser, LCDData *lcdData) |
Parses the lcd arguments. | |
std::string | searchForFile (const char *dirToLookIn, const char *prefix, const char *suffix) |
bool | turnOffPower (LCDData *LCDData) |
Turns off the power for the specific board in the firmware. More... | |
bool | turnOnPower (LCDData *LCDData) |
Turns on the power for the specific board in the firmware. More... | |
bool | verifyFirmware (LCDData *LCDData) |
Verifies the firmware version on the LCD and loads new firmware if there is no match. | |
Protected Attributes | |
bool | myAutoParseArgs |
ArLog::LogLevel | myInfoLogLevel |
bool | myLCDLogPacketsReceived |
bool | myLCDLogPacketsSent |
std::map< int, LCDData * > | myLCDs |
std::string | myLCDTypes |
ArConstFunctorC< ArLCDConnector > | myLogOptionsCB |
bool | myOwnParser |
ArRetFunctorC< bool, ArLCDConnector > | myParseArgsCB |
bool | myParsedArgs |
ArArgumentParser * | myParser |
ArRobot * | myRobot |
ArRobotConnector * | myRobotConnector |
ArFunctor1C< ArLCDConnector, int > | myTurnOffPowerCB |
ArRetFunctor1< bool, const char * > * | myTurnOffPowerOutputCB |
ArFunctor1C< ArLCDConnector, int > | myTurnOnPowerCB |
ArRetFunctor1< bool, const char * > * | myTurnOnPowerOutputCB |
Connect to robot and lcd based on run-time availablitily and command-line arguments.
ArLCDConnector makes a lcd connection either through a serial port connection, or through a TCP port (for the simulator or for robots with Ethernet-serial bridge devices instead of onboard computers). 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 Various connection parameters are configurable through command-line arguments or in the robot parameter file. (Though the internal interface used by ARIA to do this is also available if you need to use it: See addLCD(); otherwise don't use addLCD(), setupLCD(), etc.).
When you create your ArLCDConnector, 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()). ArLCDConnector 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:
To connect to any lcds that were set up in the robot parameter file or via command line arguments, call connectLCDs(). If successful, connectLCDs() will return true and add an entry for each lcd connected in the ArRobot object's list of lcds. These ArLCDMTX objects can be accessed from your ArRobot object via ArRobot::findLCD() or ArRobot::getLCDMap().
ArLCDConnector::ArLCDConnector | ( | 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 lcds 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 lcds and such, this is also passed to all the lcds created as their infoLogLevel too |
bool ArLCDConnector::addLCD | ( | ArLCDMTX * | lcd, |
int | lcdNumber = 1 |
||
) |
Adds a lcd so parsing will get it.
Normally adding lcds 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 ArLCDConnector::connectLCDs.()
bool ArLCDConnector::connectLCD | ( | ArLCDMTX * | lcd, |
int | lcdNumber = 1 , |
||
bool | forceConnection = true |
||
) |
Connects the lcd 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 ArLCDConnector::connectLCDs().
bool ArLCDConnector::parseArgs | ( | void | ) |
Function to parse the arguments given in the constructor.
Parse command line arguments using the ArArgumentParser given in the ArLCDConnector constructor.
See parseArgs(ArArgumentParser*) for details about argument parsing.
bool ArLCDConnector::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 lcd connections. A program may request support for more than one lcd using setMaxNumLCDs(); if multi-lcd support is enabled in this way, then these arguments must have the lcd index number appended. For example, "-lcdPort" for lcd 1 would instead by "-lcdPort1", and for lcd 2 it would be "-lcdPort2".
COM2
or on Linux, /dev/ttyS1
. The default lcd port is COM2, which is the typical Pioneer lcd port setup. bool ArLCDConnector::setupLCD | ( | ArLCDMTX * | lcd, |
int | lcdNumber = 1 |
||
) |
Sets up a lcd 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 ArLCDConnector::connectLCDs().
|
protected |
Turns off the power for the specific board in the firmware.
MPL the new way
|
protected |
Turns on the power for the specific board in the firmware.
MPL the new way