Example using actions and range devices to implement a random wander avoiding obstacles. This program will just have the robot wander around. It uses some avoidance actions if obstacles are detected with the sonar or laser (if robot has a laser), otherwise it just has a constant forward velocity.
Press Control-C or Escape keys to exit.
This program will work either with the MobileSim simulator or on a real robot's onboard computer. (Or use -remoteHost to connect to a wireless ethernet-serial bridge.)
#include "Aria.h"
int main(int argc, char **argv)
{
{
{
return 1;
}
}
{
return 1;
}
puts("This program will make the robot wander around. It uses some avoidance\n"
"actions if obstacles are detected, otherwise it just has a\n"
"constant forward velocity.\n\nPress CTRL-C or Escape to exit.");
{
}
return 0;
}
bool connectRobot(void)
Sets up the robot then connects it.
Definition: ArRobotConnector.cpp:405
Action to recover from a stall.
Definition: ArActionStallRecover.h:40
void loadDefaultArguments(int positon=1)
Adds args from default files and environmental variables.
Definition: ArArgumentParser.cpp:736
Perform actions when keyboard keys are pressed.
Definition: ArKeyHandler.h:65
@ Terse
Use terse logging.
Definition: ArLog.h:61
bool comInt(unsigned char command, short int argument)
Sends a command to the robot with an int for argument.
Definition: ArRobot.cpp:5634
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
This action does obstacle avoidance, controlling both trans and rot.
Definition: ArActionAvoidFront.h:51
static void setKeyHandler(ArKeyHandler *keyHandler)
Sets the key handler, so that other classes can find it using getKeyHandler()
Definition: Aria.cpp:624
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
Action for going straight at a constant velocity.
Definition: ArActionConstantVelocity.h:37
Create laser interface objects (for any kind of laser supported by ARIA) and connect to lasers based ...
Definition: ArLaserConnector.h:80
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
Action to deal with if the bumpers trigger.
Definition: ArActionBumpers.h:45
Keep track of recent sonar readings from a robot as an ArRangeDevice.
Definition: ArSonarDevice.h:51
void runAsync(bool stopRunIfNotConnected, bool runNonThreadedPacketReader=false)
Starts the instance to do processing in its own new thread.
Definition: ArRobot.cpp:301
bool addAction(ArAction *action, int priority)
Adds an action to the list with the given priority.
Definition: ArRobot.cpp:3278
@ SOUNDTOG
int, AmigoBot (old H8 model) specific, enable(1) or diable(0) sound
Definition: ArCommands.h:125
static bool parseArgs(void)
Parses the arguments for the program (calls all the callbacks added with addParseArgsCB())
Definition: Aria.cpp:759
bool connectLasers(bool continueOnFailedConnect=false, bool addConnectedLasersToRobot=true, bool addAllLasersToRobot=false, bool turnOnLasers=true, bool powerCycleLaserOnFailedConnect=true, int *failedOnLaser=NULL)
Connects all the lasers the robot has that should be auto connected.
Definition: ArLaserConnector.cpp:1213
@ Normal
Use normal logging.
Definition: ArLog.h:62
void attachKeyHandler(ArKeyHandler *keyHandler, bool exitOnEscape=true, bool useExitNotShutdown=true)
Attachs a key handler.
Definition: ArRobot.cpp:6641
void addDefaultArgument(const char *argument, int position=-1)
Adds a string as a default argument.
Definition: ArArgumentParser.cpp:699
WaitState waitForRunExit(unsigned int msecs=0)
Suspend calling thread until the ArRobot run loop has exited.
Definition: ArRobot.cpp:2923