Example of using ArActionGroup objects to switch between two different kinds of behavior.
This program creates two action groups, a teleoperation group and a wander group. Each group contains actions that together effect the desired behavior: in teleoperation mode, input actions allow the robot to be driven by keyboard or joystick, and higher-priority limiter actions help avoid obstacles. In wander mode, a constant-velocity action drives the robot forward, but higher-priority avoidance actions make the robot turn away from obstacles, or back up if an obstacle is hit or the motors stall. Keyboard commands (the T and W keys) are used to switch between the two modes, by activating the action group for the chosen mode.
- See Also
- ArActionGroup
-
Actions overview
-
actionExample.cpp
#include "Aria.h"
void teleopMode(void)
{
printf("\n== Teleoperation Mode ==\n");
printf(" Use the arrow keys to drive, and the spacebar to stop.\n For joystick control hold the trigger button.\n Press 'w' to switch to wander mode.\n Press escape to exit.\n");
}
void wanderMode(void)
{
printf("\n== Wander Mode ==\n");
printf(" The robot will now just wander around avoiding things.\n Press 't' to switch to teleop mode.\n Press escape to exit.\n");
}
int main(int argc, char** argv)
{
argParser.loadDefaultArguments();
{
return 1;
}
300, 600, 250), 95);
300, 1100, 400), 90);
if (keyHandler == NULL)
{
}
if (!joydriveAct.joystickInited())
printf("Note: Do not have a joystick, only the arrow keys on the keyboard will work.\n");
joydriveAct.setStopIfNoButtonPressed(false);
if(!con.connectRobot(&robot))
{
}
teleopMode();
}