Aria  2.8.0
ArMode Class Referenceabstract

A class for different modes, mostly as related to keyboard input. More...

#include <ArMode.h>

Inherited by ArModeActs, ArModeBumps, ArModeCamera, ArModeCommand, ArModeConfig, ArModeGripper, ArModeIO, ArModeLaser, ArModePosition, ArModeSonar, ArModeTCM2, ArModeTeleop, ArModeUnguardedTeleop, and ArModeWander.

Public Member Functions

virtual void activate (void)=0
 The function called when the mode is activated, subclass must provide.
 
 ArMode (ArRobot *robot, const char *name, char key, char key2)
 Constructor. More...
 
bool baseActivate (void)
 The base activation, it MUST be called by inheriting classes, and inheriting classes MUST return if this returns false. More...
 
bool baseDeactivate (void)
 The base deactivation, it MUST be called by inheriting classes, and inheriting classes MUST return if this returns false. More...
 
virtual void deactivate (void)=0
 The function called when the mode is deactivated, subclass must provide.
 
char getKey (void)
 An internal function to get the first key this is bound to.
 
char getKey2 (void)
 An internal function to get the second key this is bound to.
 
const char * getName (void)
 Gets the name of the mode.
 
virtual void help (void)
 The mode's help print out... subclass must provide if needed. More...
 
virtual void userTask (void)
 The ArMode's user task, don't need one, subclass must provide if needed.
 
virtual ~ArMode ()
 Destructor.
 

Static Public Member Functions

static void baseHelp (void)
 This is the base help function, its internal, bound to ? and h and H.
 

Protected Member Functions

void addKeyHandler (int keyToHandle, ArFunctor *functor)
 
void remKeyHandler (ArFunctor *functor)
 

Protected Attributes

ArFunctorC< ArModemyActivateCB
 
ArFunctorC< ArModemyDeactivateCB
 
char myKey
 
char myKey2
 
std::string myName
 
ArRobotmyRobot
 
ArFunctorC< ArModemyUserTaskCB
 

Static Protected Attributes

static ArModeourActiveMode = NULL
 
static ArGlobalFunctorourHelpCB = NULL
 
static std::list< ArMode * > ourModes
 

Detailed Description

A class for different modes, mostly as related to keyboard input.

Each mode is going to need to add its keys to the keyHandler... each mode should only use the keys 1-0, the arrow keys (movement), the space bar (stop), z (zoom in), x (zoom out), and e (exercise)... then when its activate is called by that key handler it needs to first deactivate the ourActiveMode (if its not itself, in which case its done) then add its key handling stuff... activate and deactivate will need to add and remove their user tasks (or call the base class activate/deactivate to do it) as well as the key handling things for their other part of modes. This mode will ALWAYS bind help to /, ?, h, and H when the first instance of an ArMode is made.

Constructor & Destructor Documentation

◆ ArMode()

ArMode::ArMode ( ArRobot robot,
const char *  name,
char  key,
char  key2 
)

Constructor.

Parameters
robotthe robot we're attaching to
namethe name of this mode
keythe primary key to switch to this mode on... it can be '\0' if you don't want to use this
key2an alternative key to switch to this mode on... it can be '\0' if you don't want a second alternative key

Member Function Documentation

◆ baseActivate()

bool ArMode::baseActivate ( void  )

The base activation, it MUST be called by inheriting classes, and inheriting classes MUST return if this returns false.

Inheriting modes must first call this to get their user task called and to deactivate the active mode....

if it returns false then the inheriting class must return, as it means that his mode is already active

◆ baseDeactivate()

bool ArMode::baseDeactivate ( void  )

The base deactivation, it MUST be called by inheriting classes, and inheriting classes MUST return if this returns false.

This gets called when the mode is deactivated, it removes the user task from the robot.

◆ help()

virtual void ArMode::help ( void  )
inlinevirtual

The mode's help print out... subclass must provide if needed.

This is called as soon as a mode is activated, and should give directions on to what keys do what and what this mode will do


The documentation for this class was generated from the following files: