Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages | Examples

Aria Class Reference

#include <ariaInternal.h>

List of all members.


Detailed Description

This class performs global initialization and deinitialization.


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().
static void addInitCallBack (ArFunctor *cb, ArListPos::Pos position)
 Adds a callback to call when Aria is initialized using init().
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().
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.
static ArDeviceConnectiondeviceConnectionCreate (const char *deviceConnectionType, const char *port, const char *defaultInfo, const char *prefix="Aria::deviceConnectionCreate")
 Creates a deviceConnection of the given type.
static const char * deviceConnectionGetTypes (void)
 Gets a list of the possible deviceConnection types.
static void exit (int exitCode=0)
 Shutdown all Aria processes/threads, call exit callbacks, and exit the program.
static void exitOld (int exitCode=0)
 Force an exit of all Aria processes/threads (the old way).
static ArRobotfindRobot (char *name)
 Finds a robot in the global list of robots, by name.
static ArConfiggetConfig (void)
 Gets the ArConfig for this program.
static const char * getDirectory (void)
 Gets the directory that ARIA resides in.
static ArStringInfoGroupgetInfoGroup (void)
 Gets the ArStringInfoGroup for this program.
static ArJoyHandlergetJoyHandler (void)
 Get a pointer to the joystick handler if one has been set with setJoyHandler().
static ArKeyHandlergetKeyHandler (void)
 Gets a pointer to the global key handler, if one has been set with setKeyHandler().
static int getMaxNumLasers (void)
 Gets the maximum number of lasers to use.
static ArRobotJoyHandlergetRobotJoyHandler (void)
 Gets the robot joystick handler if one has been set.
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).
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.
static bool laserAddCreator (const char *laserType, ArRetFunctor2< ArLaser *, int, const char * > *creator)
 Adds a type of laser for Aria to be able to create.
static ArLaserlaserCreate (const char *laserType, int laserNumber, const char *prefix="Aria::laserCreate")
 Creates a laser of the given type.
static const char * laserGetTypes (void)
 Gets a list of the possible laser types.
static void logOptions (void)
 Logs all the options for the program (Calls all the callbacks added with addLogOptionsCB()).
static bool parseArgs (void)
 Parses the arguments for the program (calls all the callbacks added with addParseArgsCB()).
static void remExitCallback (ArFunctor *functor)
 Removes a functor to by called before program exit by Aria::exit().
static void setDirectory (const char *directory)
 Sets the directory that ARIA resides in, to override default.
static void setExitCallbacksLogLevel (ArLog::LogLevel level)
 Sets the log level for the exit callbacks.
static void setJoyHandler (ArJoyHandler *joyHandler)
 Sets the joystick handler, so that other classes can find it using getJoyHandler().
static void setKeyHandler (ArKeyHandler *keyHandler)
 Sets the key handler, so that other classes can find it using getKeyHandler().
static void setMaxNumLasers (int maxNumLasers)
 Sets the maximum number of lasers to use.
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.
static void shutdown ()
 Shutdown all Aria processes/threads.
static void signalHandlerCB (int sig)
 Internal, the callback for the signal handling.
static void uninit ()
 Performs OS-specific deinitialization, used by shutdown() and exit().

Static Protected Attributes

static ArConfig ourConfig
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 ArStringInfoGroup ourInfoGroup
static std::list< ArFunctor * > ourInitCBs
static bool ourInited = false
static ArJoyHandlerourJoyHandler = NULL
static ArKeyHandlerourKeyHandler = NULL
static std::map< std::string,
ArRetFunctor2< ArLaser *,
int, const char * > *, ArStrCaseCmpOp
ourLaserCreatorMap
static std::string ourLaserTypes
static std::multimap< int,
ArFunctor * > 
ourLogOptionsCBs
static int ourMaxNumLasers = 9
static std::multimap< int,
ArRetFunctor< bool > * > 
ourParseArgCBs
static ArLog::LogLevel ourParseArgsLogLevel = ArLog::Verbose
static ArRobotJoyHandlerourRobotJoyHandler = 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::list< ArFunctor * > ourUninitCBs


Member Enumeration Documentation

enum Aria::SigHandleMethod
 

Enumeration values:
SIGHANDLE_SINGLE  Setup signal handlers in a global, non-thread way.
SIGHANDLE_THREAD  Setup a dedicated signal handling thread.
SIGHANDLE_NONE  Do no signal handling.


Member Function Documentation

void Aria::addExitCallback ArFunctor functor,
int  position = 50
[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.

Examples:
gpsRobotTaskExample.cpp.

void Aria::addInitCallBack ArFunctor cb,
ArListPos::Pos  position
[static]
 

Adds a callback to call when Aria is initialized using init().

This will add a callback to the list of callbacks to call when Aria has been initialized. It can be called before anything else.

void Aria::addUninitCallBack ArFunctor cb,
ArListPos::Pos  position
[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.

bool Aria::deviceConnectionAddCreator const char *  deviceConnectionType,
ArRetFunctor3< ArDeviceConnection *, const char *, const char *, const char * > *  creator
[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.

Parameters:
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.

ArDeviceConnection * Aria::deviceConnectionCreate const char *  deviceConnectionType,
const char *  port,
const char *  defaultInfo,
const char *  logPrefix = "Aria::deviceConnectionCreate"
[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

Parameters:
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

const char * Aria::deviceConnectionGetTypes void   )  [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.

void Aria::exit int  exitCode = 0  )  [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 with the given exit code. Note that this could be called from anywhere, mutexes may be locked when called-- the exit callbacks MUST exit and cannot wait for a lock.

See also:
addExitCallback()
Examples:
actsColorFollowingExample.cpp, demo.cpp, dpptuExample.cpp, gotoActionExample.cpp, moduleExample.cpp, simpleConnect.cpp, simpleMotionCommands.cpp, and wander.cpp.

void Aria::exitOld int  exitCode = 0  )  [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.

Deprecated:

ArRobot * Aria::findRobot char *  name  )  [static]
 

Finds a robot in the global list of robots, by name.

Parameters:
name the name of the robot you want to find
Returns:
NULL if there is no robot of that name, otherwise the robot with that name

ArConfig * Aria::getConfig void   )  [static]
 

Gets the ArConfig for this program.

This gets the global config aria uses.

Examples:
configExample.cpp.

const char * Aria::getDirectory void   )  [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.

Returns:
the directory ARIA is located in
See also:
setDirectory

ArStringInfoGroup * Aria::getInfoGroup void   )  [static]
 

Gets the ArStringInfoGroup for this program.

This gets the global string group aria uses.

int Aria::getMaxNumLasers void   )  [static]
 

Gets the maximum number of lasers to use.

Gets the maximum number of lasers to check for and use

bool Aria::getRunning void   )  [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)

Examples:
gotoActionExample.cpp, netServerExample.cpp, socketServerExample.cpp, and soundsQueueExample.cpp.

void Aria::init SigHandleMethod  method = SIGHANDLE_THREAD,
bool  initSockets = true,
bool  sigHandleExitNotShutdown = true
[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.

Parameters:
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.
See also:
ArSignalHandler

ArSocket

Examples:
actionExample.cpp, actionGroupExample.cpp, actsColorFollowingExample.cpp, armExample.cpp, auxSerialExample.cpp, configExample.cpp, demo.cpp, directMotionExample.cpp, dpptuExample.cpp, gotoActionExample.cpp, gpsExample.cpp, gpsRobotTaskExample.cpp, gripperExample.cpp, gyroExample.cpp, joydriveActionExample.cpp, lineFinderExample.cpp, moduleExample.cpp, netServerExample.cpp, robotConnectionCallbacks.cpp, robotSyncTaskExample.cpp, simpleConnect.cpp, simpleMotionCommands.cpp, socketClientExample.cpp, socketServerExample.cpp, sonyPTZDemo.cpp, soundsQueueExample.cpp, teleopActionsExample.cpp, threadExample.cpp, triangleDriveToActionExample.cpp, vcc4CameraExample.cpp, and wander.cpp.

bool Aria::laserAddCreator const char *  laserType,
ArRetFunctor2< ArLaser *, int, const char * > *  creator
[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.

Parameters:
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

ArLaser * Aria::laserCreate const char *  laserType,
int  laserNumber,
const char *  logPrefix = "Aria::laserCreate"
[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.

Parameters:
laserType The type of laser to create
laserNumber The laser number to use for the created laser
logPrefix The prefix to use when logging

const char * Aria::laserGetTypes void   )  [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.

void Aria::logOptions void   )  [static]
 

Logs all the options for the program (Calls all the callbacks added with addLogOptionsCB()).

See also:
addLogOptionsCB()
Examples:
actionExample.cpp, actionGroupExample.cpp, actsColorFollowingExample.cpp, armExample.cpp, auxSerialExample.cpp, configExample.cpp, demo.cpp, directMotionExample.cpp, dpptuExample.cpp, gotoActionExample.cpp, gpsExample.cpp, gpsRobotTaskExample.cpp, gripperExample.cpp, lineFinderExample.cpp, robotConnectionCallbacks.cpp, simpleConnect.cpp, simpleMotionCommands.cpp, teleopActionsExample.cpp, and wander.cpp.

bool Aria::parseArgs void   )  [static]
 

Parses the arguments for the program (calls all the callbacks added with addParseArgsCB()).

See also:
addParseArgsCB()
Examples:
actionExample.cpp, actionGroupExample.cpp, actsColorFollowingExample.cpp, armExample.cpp, auxSerialExample.cpp, configExample.cpp, demo.cpp, directMotionExample.cpp, dpptuExample.cpp, gotoActionExample.cpp, gpsExample.cpp, gpsRobotTaskExample.cpp, gripperExample.cpp, lineFinderExample.cpp, robotConnectionCallbacks.cpp, simpleConnect.cpp, simpleMotionCommands.cpp, teleopActionsExample.cpp, and wander.cpp.

void Aria::remExitCallback ArFunctor functor  )  [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).

void Aria::setDirectory const char *  directory  )  [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.

Parameters:
directory the directory Aria is located in
See also:
getDirectory

void Aria::setMaxNumLasers int  maxNumLasers  )  [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.

void Aria::shutdown  )  [static]
 

Shutdown all Aria processes/threads.

Use this function to clean up or uninitialize Aria, in particular, to stop background threads. 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. Use exit() to do some cleanup and exit the program.)

See also:
Aria::exit()
Examples:
actionExample.cpp, actionGroupExample.cpp, actsColorFollowingExample.cpp, armExample.cpp, auxSerialExample.cpp, configExample.cpp, directMotionExample.cpp, dpptuExample.cpp, gotoActionExample.cpp, gripperExample.cpp, gyroExample.cpp, joydriveActionExample.cpp, lineFinderExample.cpp, moduleExample.cpp, robotConnectionCallbacks.cpp, simpleConnect.cpp, simpleMotionCommands.cpp, sonyPTZDemo.cpp, soundsQueueExample.cpp, teleopActionsExample.cpp, triangleDriveToActionExample.cpp, and vcc4CameraExample.cpp.

void Aria::uninit  )  [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.

Examples:
socketClientExample.cpp, and socketServerExample.cpp.


The documentation for this class was generated from the following files:
Generated on Thu Jan 7 10:34:41 2010 for Aria by  doxygen 1.4.2