Aria
2.8.0
|
Contains global initialization, deinitialization and other global functions. More...
#include <ariaInternal.h>
Public Types | |
enum | SigHandleMethod { SIGHANDLE_SINGLE, SIGHANDLE_THREAD, SIGHANDLE_NONE } |
Static Public Member Functions | |
static void | addExitCallback (ArFunctor *functor, int position=50) |
Adds a functor to by called before program exit by Aria::exit() More... | |
static void | addInitCallBack (ArFunctor *cb, ArListPos::Pos position) |
Adds a callback to call when Aria is initialized using init() More... | |
static void | addLogOptionsCB (ArFunctor *functor, int position=50) |
Adds a callback for when we log options. | |
static void | addParseArgsCB (ArRetFunctor< bool > *functor, int position=50) |
Adds a callback for when we parse arguments. | |
static void | addRobot (ArRobot *robot) |
Add a robot to the global list of robots. | |
static void | addUninitCallBack (ArFunctor *cb, ArListPos::Pos position) |
Adds a callback to call when Aria is uninititialized using uninit() More... | |
static bool | batteryAddCreator (const char *batteryType, ArRetFunctor2< ArBatteryMTX *, int, const char *> *creator) |
Adds a type of battery for Aria to be able to create. More... | |
static ArBatteryMTX * | batteryCreate (const char *batteryType, int batteryNumber, const char *prefix="Aria::batteryCreate") |
Creates a battery of the given type. More... | |
static const char * | batteryGetChoices (void) |
Gets a list of the possible battery types (for use in the config) More... | |
static const char * | batteryGetTypes (void) |
Gets a list of the possible battery types. More... | |
static void | callExitCallbacks (void) |
Internal, calls the exit callbacks. | |
static void | delRobot (ArRobot *robot) |
Remove a robot from the global list of robots. | |
static bool | deviceConnectionAddCreator (const char *deviceConnectionType, ArRetFunctor3< ArDeviceConnection *, const char *, const char *, const char *> *creator) |
Adds a type of deviceConnection for Aria to be able to create. More... | |
static ArDeviceConnection * | deviceConnectionCreate (const char *deviceConnectionType, const char *port, const char *defaultInfo, const char *prefix="Aria::deviceConnectionCreate") |
Creates a deviceConnection of the given type. More... | |
static const char * | deviceConnectionGetChoices (void) |
Gets a list of the possible deviceConnection types (for use in the config) More... | |
static const char * | deviceConnectionGetTypes (void) |
Gets a list of the possible deviceConnection types. More... | |
static void | exit (int exitCode=0) |
Shutdown all Aria processes/threads, call exit callbacks, and exit the program. More... | |
static void | exitOld (int exitCode=0) |
Force an exit of all Aria processes/threads (the old way) More... | |
static ArRobot * | findRobot (char *name) |
Finds a robot in the global list of robots, by name. More... | |
static ArConfig * | getConfig (void) |
Gets the ArConfig for this program. More... | |
static const char * | getDirectory (void) |
Gets the directory that ARIA resides in. More... | |
static const char * | getIdentifier (void) |
Gets the identifier (for humans) used for this instance of Aria. | |
static ArStringInfoGroup * | getInfoGroup (void) |
Gets the ArStringInfoGroup for this program. More... | |
static ArJoyHandler * | getJoyHandler (void) |
Get a pointer to the joystick handler if one has been set with setJoyHandler() More... | |
static ArKeyHandler * | getKeyHandler (void) |
Gets a pointer to the global key handler, if one has been set with setKeyHandler() More... | |
static int | getMaxNumBatteries (void) |
Gets the maximum number of batteris to use. More... | |
static int | getMaxNumLasers (void) |
Gets the maximum number of lasers to use. More... | |
static int | getMaxNumLCDs (void) |
Gets the maximum number of lcds to use. More... | |
static size_t | getMaxNumPTZs () |
Set maximum limit on PTZ or PTU devices, used by ArPTZConnector. | |
static int | getMaxNumSonarBoards (void) |
Gets the maximum number of sonars to use. More... | |
static size_t | getMaxNumVideoDevices () |
Get maximum limit on video devices (used by ArVideo library) | |
static ArRobotJoyHandler * | getRobotJoyHandler (void) |
Gets the robot joystick handler if one has been set. More... | |
static std::list< ArRobot * > * | getRobotList () |
Get a copy of the global robot list. | |
static bool | getRunning (void) |
Sees if Aria is still running (mostly for the thread in main) More... | |
static void | init (SigHandleMethod method=SIGHANDLE_THREAD, bool initSockets=true, bool sigHandleExitNotShutdown=true) |
Initialize Aria global data struture and perform OS-specific initialization, including adding OS signal handlers on Linux, initializing sockets library on Windows, etc. More... | |
static bool | laserAddCreator (const char *laserType, ArRetFunctor2< ArLaser *, int, const char *> *creator) |
Adds a type of laser for Aria to be able to create. More... | |
static ArLaser * | laserCreate (const char *laserType, int laserNumber, const char *prefix="Aria::laserCreate") |
Creates a laser of the given type. More... | |
static const char * | laserGetChoices (void) |
Gets a list of the possible laser types (for use in the config) More... | |
static const char * | laserGetTypes (void) |
Gets a list of the possible laser types. More... | |
static bool | lcdAddCreator (const char *lcdType, ArRetFunctor2< ArLCDMTX *, int, const char *> *creator) |
Adds a type of lcd for Aria to be able to create. More... | |
static ArLCDMTX * | lcdCreate (const char *lcdType, int lcdNumber, const char *prefix="Aria::lcdCreate") |
Creates a lcd of the given type. More... | |
static const char * | lcdGetChoices (void) |
Gets a list of the possible lcd types (for use in the config) More... | |
static const char * | lcdGetTypes (void) |
Gets a list of the possible lcd types. More... | |
static void | logOptions (void) |
Logs all the options for the program (Calls all the callbacks added with addLogOptionsCB()) More... | |
static bool | parseArgs (void) |
Parses the arguments for the program (calls all the callbacks added with addParseArgsCB()) More... | |
static void | remExitCallback (ArFunctor *functor) |
Removes a functor to by called before program exit by Aria::exit() More... | |
static void | setDirectory (const char *directory) |
Sets the directory that ARIA resides in, to override default. More... | |
static void | setExitCallbacksLogLevel (ArLog::LogLevel level) |
Sets the log level for the exit callbacks. | |
static void | setIdentifier (const char *identifier) |
Sets the identifier (for humans) used for this instance of Aria. | |
static void | setJoyHandler (ArJoyHandler *joyHandler) |
Sets the joystick handler, so that other classes can find it using getJoyHandler() More... | |
static void | setKeyHandler (ArKeyHandler *keyHandler) |
Sets the key handler, so that other classes can find it using getKeyHandler() More... | |
static void | setMaxNumBatteries (int maxNumBatteries) |
Sets the maximum number of batteries to use. More... | |
static void | setMaxNumLasers (int maxNumLasers) |
Sets the maximum number of lasers to use. More... | |
static void | setMaxNumLCDs (int maxNumLCDs) |
Sets the maximum number of batteries to use. More... | |
static void | setMaxNumPTZs (size_t n) |
Set maximum limit on PTZ or PTU devices, used by ArPTZConnector. Call before connecting to PTZ devices with ArPTZConnector. | |
static void | setMaxNumSonarBoards (int maxNumSonarBoards) |
Sets the maximum number of sonars to use. More... | |
static void | setMaxNumVideoDevices (size_t n) |
Set maximum limit on video devices (used by ArVideo library) | |
static void | setParseArgLogLevel (ArLog::LogLevel level) |
Sets the log level for the parsing function. | |
static void | setRobotJoyHandler (ArRobotJoyHandler *robotJoyHandler) |
Sets the robot joystick handler, so that other classes can find it. More... | |
static void | shutdown () |
Shutdown all Aria processes/threads. More... | |
static void | signalHandlerCB (int sig) |
Internal, the callback for the signal handling. | |
static bool | sonarAddCreator (const char *sonarType, ArRetFunctor2< ArSonarMTX *, int, const char *> *creator) |
Adds a type of sonar for Aria to be able to create. More... | |
static ArSonarMTX * | sonarCreate (const char *sonarType, int sonarNumber, const char *prefix="Aria::sonarCreate") |
Creates a sonar of the given type. More... | |
static const char * | sonarGetChoices (void) |
Gets a list of the possible sonar types (for use in the config) More... | |
static const char * | sonarGetTypes (void) |
Gets a list of the possible sonar types. More... | |
static void | uninit () |
Performs OS-specific deinitialization, used by shutdown() and exit(). More... | |
Static Protected Attributes | |
static std::string | ourBatteryChoices = "Choices:" |
static std::map< std::string, ArRetFunctor2< ArBatteryMTX *, int, const char * > *, ArStrCaseCmpOp > | ourBatteryCreatorMap |
static std::string | ourBatteryTypes |
static ArConfig | ourConfig |
static std::string | ourDeviceConnectionChoices = "Choices:" |
static std::map< std::string, ArRetFunctor3< ArDeviceConnection *, const char *, const char *, const char * > *, ArStrCaseCmpOp > | ourDeviceConnectionCreatorMap |
static std::string | ourDeviceConnectionTypes |
static std::string | ourDirectory ="" |
static std::multimap< int, ArFunctor * > | ourExitCallbacks |
static ArLog::LogLevel | ourExitCallbacksLogLevel = ArLog::Verbose |
static ArMutex | ourExitCallbacksMutex |
static bool | ourExiting =false |
static std::string | ourIdentifier = "generic" |
static ArStringInfoGroup | ourInfoGroup |
static std::list< ArFunctor * > | ourInitCBs |
static bool | ourInited = false |
static ArJoyHandler * | ourJoyHandler = NULL |
static ArKeyHandler * | ourKeyHandler = NULL |
static std::string | ourLaserChoices = "Choices:" |
static std::map< std::string, ArRetFunctor2< ArLaser *, int, const char * > *, ArStrCaseCmpOp > | ourLaserCreatorMap |
static std::string | ourLaserTypes |
static std::string | ourLCDChoices = "Choices:" |
static std::map< std::string, ArRetFunctor2< ArLCDMTX *, int, const char * > *, ArStrCaseCmpOp > | ourLCDCreatorMap |
static std::string | ourLCDTypes |
static std::multimap< int, ArFunctor * > | ourLogOptionsCBs |
static int | ourMaxNumBatteries = 1 |
static int | ourMaxNumLasers = 2 |
static int | ourMaxNumLCDs = 1 |
static size_t | ourMaxNumPTZs = 8 |
static int | ourMaxNumSonarBoards = 1 |
static size_t | ourMaxNumVideoDevices = 8 |
static std::multimap< int, ArRetFunctor< bool > * > | ourParseArgCBs |
static ArLog::LogLevel | ourParseArgsLogLevel = ArLog::Verbose |
static ArRobotJoyHandler * | ourRobotJoyHandler = NULL |
static std::list< ArRobot * > | ourRobots |
static bool | ourRunning = false |
static bool | ourShuttingDown =false |
static ArMutex | ourShuttingDownMutex |
static bool | ourSigHandleExitNotShutdown = true |
static ArGlobalFunctor1< int > | ourSignalHandlerCB |
static std::string | ourSonarChoices = "Choices:" |
static std::map< std::string, ArRetFunctor2< ArSonarMTX *, int, const char * > *, ArStrCaseCmpOp > | ourSonarCreatorMap |
static std::string | ourSonarTypes |
static std::list< ArFunctor * > | ourUninitCBs |
Contains global initialization, deinitialization and other global functions.
|
static |
Adds a functor to by called before program exit by Aria::exit()
Note, an exit callback may be called at any time; it should not block or wait on any locked mutexes or similar.
|
static |
|
static |
Adds a callback to call when Aria is uninititialized using uninit()
This will add a callback to the list of callbacks to call right before Aria is un-initialized.
It can be called before anything else. This facilitates code that in operating system signal handlers simply calls Aria::uninit() and packages that are based on Aria are unitited as well. It simplifies the entire uninit process.
|
static |
Adds a type of battery for Aria to be able to create.
This adds a functor which can create a battery of a given type.
batteryType | The battery type that the creator will make (these are always checked case insensitively). If there is already a creator for this type, then the old one is replaced and the new one is used. |
creator | A functor which takes an int (battery number) and a const char * (logPrefix) and returns a new battery of the batteryType |
|
static |
Creates a battery of the given type.
Creates a battery of a given type, with the given batteryNumber, and uses the logPrefix for logging what happens.
This is mostly for internal use by ArBatteryConnector.
batteryType | The type of battery to create |
batteryNumber | The battery number to use for the created battery |
logPrefix | The prefix to use when logging |
|
static |
Gets a list of the possible battery types (for use in the config)
Gets a string that is the types of batteries that can be created separated by ;; characters.
Mostly for internal use by the config.
|
static |
Gets a list of the possible battery types.
Gets a string that is the types of batteries that can be created separated by | characters.
Mostly for internal use by ArBatteryConnector.
|
static |
Adds a type of deviceConnection for Aria to be able to create.
This adds a functor which can create a deviceConnection of a given type.
deviceConnectionType | The deviceConnection type that the creator will make (these are always checked case insensitively). If there is already a creator for this type, then the old one is replaced and the new one is used. |
creator | A functor which takes a const char * (port name), a const char * (defaultInfo, for example default tcp port), a const char * (logPrefix) and returns a new deviceConnection of the deviceConnectionType if it can create the desired connection. If the connection failes then it should return NULL. |
|
static |
Creates a deviceConnection of the given type.
Creates a device connection of a given type, connecting to a given port, with the given defaultInfo, logging messages with the given prefix.
This is mostly for internal use by ArLaserConnector
deviceConnectionType | The type of device connection to create |
port | The port to connect to (for serial, an example is COM1 or /dev/ttyS0, for tcp an example is p3dx:8101) |
defaultInfo | Default info to use, the only use for this right now is for a default port for a tcp connection (so that if it doesn't have hostname:port format but only hostname then it will use this port) |
logPrefix | The prefix to use when logging |
|
static |
Gets a list of the possible deviceConnection types (for use in the config)
Gets a string that is the types of device connections that can be created separated by ;; characters.
Mostly for internal use by the config.
|
static |
Gets a list of the possible deviceConnection types.
Gets a string that is the types of device connections that can be created separated by | characters.
Mostly for internal use by ArLaserConnector.
|
static |
Shutdown all Aria processes/threads, call exit callbacks, and exit the program.
This will call the list of Aria exit callbacks (added by addExitCallback()) and then exit the program with the given exit code.
This method may be used as a replacement for the standard system ::exit() call (which is used by this method to finally exit the program with the given exitCode after finishing Aria shutdown steps.)
Note that this could be called from anywhere, mutexes may be locked when called– all exit callbacks MUST return and cannot wait for a lock, since this could result in the program hanging due to double-lock (deadlock).
|
static |
Force an exit of all Aria processes/threads (the old way)
This method is roughly obsolete, it simply forces all the threads to die immediately and then exits...
The new method exit() is preferred.
This calls cancel() on all AtThread's and ArASyncTask's. It forces each thread to exit and should only be used in the case of a thread hanging or getting stuck in an infinite loop. This works fine in Linux. In Windows it is not recommended at all that this function be called. Windows can not handle cleanly killing off a thread. See the help in the VC++ compiler on the WIN32 function TerminateThread. The biggest problem is that the state of DLL's can be destroyed.
|
static |
Finds a robot in the global list of robots, by name.
name | the name of the robot you want to find |
|
static |
Gets the ArConfig for this program.
This gets the global config aria uses.
|
static |
Gets the directory that ARIA resides in.
This gets the directory that ARIA is located in, this is so ARIA can find param files and the like.
|
static |
Gets the ArStringInfoGroup for this program.
This gets the global string group aria uses.
|
static |
Get a pointer to the joystick handler if one has been set with setJoyHandler()
Gets the joy handler if one has been set.
|
static |
Gets a pointer to the global key handler, if one has been set with setKeyHandler()
Gets the key handler if one has been set.
|
static |
Gets the maximum number of batteris to use.
Gets the maximum number of batteries to check for and use.
|
static |
Gets the maximum number of lasers to use.
Gets the maximum number of lasers to check for and use.
|
static |
Gets the maximum number of lcds to use.
Gets the maximum number of lcds to check for and use.
|
static |
Gets the maximum number of sonars to use.
Gets the maximum number of sonar boards to check for and use.
|
static |
Gets the robot joystick handler if one has been set.
Gets the robot joy handler if one has been set.
|
static |
Sees if Aria is still running (mostly for the thread in main)
returns true if ARIA is initialized (Aria::init() has been called) and has not been shut down by a call to Aria::shutdown() or Aria::exit() and an operating system signal has not occured (e.g.
external KILL signal)
|
static |
Initialize Aria global data struture and perform OS-specific initialization, including adding OS signal handlers on Linux, initializing sockets library on Windows, etc.
This must be called first before any other Aria functions.
It initializes the thread layer and the signal handling method. For Windows it iniatializes the socket layer as well. This also sets the directory Aria is located in using ARIA environmental variable (or Aria registry key on Windows). For more about Aria's directory see getDirectory() and setDirectory().
For Linux the default signal handling method is to intercept OS signals in a dedicated "signal handling thread", which cleanly closes down the program, causes all the instances of ArRobot to stop their run loop and disconnect from their robot. The program will exit on the following signals: SIGHUP, SIGINT, SIGQUIT, and SIGTERM.
For Windows, there is no signal handling.
This method also adds the file /etc/Aria.args and the environment variable ARIAARGS as locations for ArArgumentParser to obtain default argument values from.
method | the method in which to handle signals. Defaulted to SIGHANDLE_SINGLE, or the method indicated by the ARIA_SIGHANDLE_METHOD environment variable (NONE, SINGLE or THREAD), if it exists. |
initSockets | specify whether or not to initialize the socket layer. This is only meaningfull for Windows. Defaulted to true. |
sigHandleExitNotShutdown | if this is true and a signal happens Aria will use exit() to quit instead of shutdown(), false will still use shutdown which is the old behavior. |
|
static |
Adds a type of laser for Aria to be able to create.
This adds a functor which can create a laser of a given type.
laserType | The laser type that the creator will make (these are always checked case insensitively). If there is already a creator for this type, then the old one is replaced and the new one is used. |
creator | A functor which takes an int (laser number) and a const char * (logPrefix) and returns a new laser of the laserType |
|
static |
Creates a laser of the given type.
Creates a laser of a given type, with the given laserNumber, and uses the logPrefix for logging what happens.
This is mostly for internal use by ArLaserConnector.
laserType | The type of laser to create |
laserNumber | The laser number to use for the created laser |
logPrefix | The prefix to use when logging |
|
static |
Gets a list of the possible laser types (for use in the config)
Gets a string that is the types of lasers that can be created separated by ;; characters.
Mostly for internal use by the config
|
static |
Gets a list of the possible laser types.
Gets a string that is the types of lasers that can be created separated by | characters.
Mostly for internal use by ArLaserConnector.
|
static |
Adds a type of lcd for Aria to be able to create.
This adds a functor which can create a lcd of a given type.
lcdType | The lcd type that the creator will make (these are always checked case insensitively). If there is already a creator for this type, then the old one is replaced and the new one is used. |
creator | A functor which takes an int (lcd number) and a const char * (logPrefix) and returns a new lcd of the lcdType |
|
static |
Creates a lcd of the given type.
Creates a lcd of a given type, with the given lcdNumber, and uses the logPrefix for logging what happens.
This is mostly for internal use by ArLCDConnector.
lcdType | The type of lcd to create |
lcdNumber | The lcd number to use for the created lcd |
logPrefix | The prefix to use when logging |
|
static |
Gets a list of the possible lcd types (for use in the config)
Gets a string that is the types of batteries that can be created separated by ;; characters.
Mostly for internal use by ArLCDConnector.
|
static |
Gets a list of the possible lcd types.
Gets a string that is the types of batteries that can be created separated by | characters.
Mostly for internal use by ArLCDConnector.
|
static |
Logs all the options for the program (Calls all the callbacks added with addLogOptionsCB())
|
static |
Parses the arguments for the program (calls all the callbacks added with addParseArgsCB())
|
static |
Removes a functor to by called before program exit by Aria::exit()
Note, an exit callback may be called at any time; it should not * block or wait on any locked mutexes or similar.
Also note that this will not actually happen if it is called while aria is exiting (ie it is walking through the list).
|
static |
Sets the directory that ARIA resides in, to override default.
This sets the directory that ARIA is located in, so ARIA can find param files and the like.
This can also be controlled by the environment variable ARIA, which this is set to (if it exists) when Aria::init is done. So for setDirectory to be effective, it must be done after the Aria::init.
directory | the directory Aria is located in |
|
static |
Sets the joystick handler, so that other classes can find it using getJoyHandler()
Sets the joy handler, so that other classes can find it.
|
static |
Sets the key handler, so that other classes can find it using getKeyHandler()
Sets the key handler, so that other classes can find it.
|
static |
Sets the maximum number of batteries to use.
Sets the maximum number of sonars to check for and use, if you are going to set this you should do it after the Aria::init.
|
static |
Sets the maximum number of lasers to use.
Sets the maximum number of lasers to check for and use, if you are going to set this you should do it after the Aria::init before you start making laser connectors or robots or robot params.
|
static |
Sets the maximum number of batteries to use.
Sets the maximum number of sonars to check for and use, if you are going to set this you should do it after the Aria::init.
|
static |
Sets the maximum number of sonars to use.
Sets the maximum number of sonars to check for and use, if you are going to set this you should do it after the Aria::init.
|
static |
Sets the robot joystick handler, so that other classes can find it.
Sets the robot joy handler, so that other classes can find it.
|
static |
Shutdown all Aria processes/threads.
Use this function to clean up or uninitialize Aria, in particular, to stop background threads.
(Note: If you want to shutdown ARIA cleanly at the end of your program or when exiting the program due to error, use Aria::exit() instead.) This calls stop() on all ArThread's and ArASyncTask's. It will block until all ArThread's and ArASyncTask's exit. It is expected that all the tasks will obey the ArThread::myRunning variable and exit when it is false. Note, this only stop Aria's background threads, it does not exit the program. If you want to shutdown ARIA cleanly at the end of your program or when exiting the program due to error, use Aria::exit() instead.
|
static |
Adds a type of sonar for Aria to be able to create.
This adds a functor which can create a sonar of a given type.
sonarType | The sonar type that the creator will make (these are always checked case insensitively). If there is already a creator for this type, then the old one is replaced and the new one is used. |
creator | A functor which takes an int (sonar number) and a const char * (logPrefix) and returns a new sonar of the sonarType |
|
static |
Creates a sonar of the given type.
Creates a sonar of a given type, with the given sonarNumber, and uses the logPrefix for logging what happens.
This is mostly for internal use by ArSonarConnector.
sonarType | The type of sonar to create |
sonarNumber | The sonar number to use for the created sonar |
logPrefix | The prefix to use when logging |
|
static |
Gets a list of the possible sonar types (for use in the config)
Gets a string that is the types of sonars that can be created separated by ;; characters.
Mostly for internal use by the config.
|
static |
Gets a list of the possible sonar types.
Gets a string that is the types of sonars that can be created separated by | characters.
Mostly for internal use by ArSonarConnector.
|
static |
Performs OS-specific deinitialization, used by shutdown() and exit().
This must be called last, after all other Aria functions.
For both Linux and Windows, it closes all the open ArModules. For Windows it deinitializes the socket layer as well.