Example using actions for safe teleoperation with keyboard or joystick.This example program creates several "limiting" actions (stop the robot from hitting detected obstacles), as well as Joydrive and Keydrive actions which request movement based on keys pressed or a joystick attached to the computer. The limiting actions are added at a higher priority than the teleoperation actions, so they prevent those actions from driving the robot if nearby obstacles are detected; otherwise, you can drive the robot using they joystick or keyboard.
#include "Aria.h"
int main(int argc, char **argv)
{
{
{
}
}
{
}
printf("This program will allow you to use a joystick or keyboard to control the robot.\nYou can use the arrow keys to drive, and the spacebar to stop.\nFor joystick control press the trigger button and then drive.\nPress escape to exit.\n");
printf("Do not have a joystick, only the arrow keys on the keyboard will work.\n");
}
bool connectRobot(void)
Sets up the robot then connects it.
Definition: ArRobotConnector.cpp:405
bool setAbsoluteMaxTransVel(double maxVel)
Sets the robot's absolute maximum translational velocity.
Definition: ArRobot.cpp:2144
void loadDefaultArguments(int positon=1)
Adds args from default files and environmental variables.
Definition: ArArgumentParser.cpp:736
Action to limit speed (and stop) based on whether the "table"-sensors see anything.
Definition: ArActionLimiterTableSensor.h:40
@ Terse
Use terse logging.
Definition: ArLog.h:61
Connect to robot or simulator based on program command line parameters.
Definition: ArRobotConnector.h:80
void enableMotors()
Enables the motors on the robot.
Definition: ArRobot.cpp:6521
void addRangeDevice(ArRangeDevice *device)
Adds a rangeDevice to the robot's list of them, and set the ArRangeDevice object's robot pointer to t...
Definition: ArRobot.cpp:5757
static void exit(int exitCode=0)
Shutdown all Aria processes/threads, call exit callbacks, and exit the program.
Definition: Aria.cpp:367
static void log(LogLevel level, const char *str,...)
Log a message, with formatting and variable number of arguments.
Definition: ArLog.cpp:93
bool joystickInited(void)
Whether the joystick is initalized or not.
Definition: ArActionJoydrive.cpp:108
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 sign...
Definition: Aria.cpp:128
bool checkHelpAndWarnUnparsed(unsigned int numArgsOkay=0)
Checks for the help strings and warns about unparsed arguments.
Definition: ArArgumentParser.cpp:843
Central class for communicating with and operating the robot.
Definition: ArRobot.h:82
Parse and store program command-line arguments for use by other ARIA classes.
Definition: ArArgumentParser.h:64
static void logOptions(void)
Logs all the options for the program (Calls all the callbacks added with addLogOptionsCB())
Definition: Aria.cpp:794
Keep track of recent sonar readings from a robot as an ArRangeDevice.
Definition: ArSonarDevice.h:51
This action will use the joystick for input to drive the robot.
Definition: ArActionJoydrive.h:51
bool addAction(ArAction *action, int priority)
Adds an action to the list with the given priority.
Definition: ArRobot.cpp:3278
static bool parseArgs(void)
Parses the arguments for the program (calls all the callbacks added with addParseArgsCB())
Definition: Aria.cpp:759
This action will use the keyboard arrow keys for input to drive the robot.
Definition: ArActionKeydrive.h:37
@ Normal
Use normal logging.
Definition: ArLog.h:62
Action to limit the backwards motion of the robot based on range sensor readings.
Definition: ArActionLimiterBackwards.h:40
void setStopIfNoButtonPressed(bool stopIfNoButtonPressed)
Set if we'll stop if no button is pressed, otherwise just do nothing.
Definition: ArActionJoydrive.cpp:97
void run(bool stopRunIfNotConnected, bool runNonThreaded=false)
Starts the instance to do processing in this thread.
Definition: ArRobot.cpp:255
Action to limit the forwards motion of the robot based on range sensor readings.
Definition: ArActionLimiterForwards.h:39