Uses ArActionGoto to drive the robot in a squareThis program will make the robot drive in a 2.5x2.5 meter square by setting each corner in turn as the goal for an ArActionGoto action. It also uses speed limiting actions to avoid collisions. After some time, it cancels the goal (and the robot stops due to a stopping action) and exits.
Press escape to shut down Aria and exit.
#include "Aria.h"
int main(int argc, char **argv)
{
printf("You may press escape to exit\n");
{
return 1;
}
{
printf("Could not connect to robot... exiting\n");
return 1;
}
const int duration = 30000;
ArLog::log(
ArLog::Normal,
"Going to four goals in turn for %d seconds, then cancelling goal and exiting.", duration/1000);
bool first = true;
int goalNum = 0;
{
{
first = false;
goalNum++;
if (goalNum > 4)
goalNum = 1;
if (goalNum == 1)
else if (goalNum == 2)
else if (goalNum == 3)
else if (goalNum == 4)
}
ArLog::log(
ArLog::Normal,
"%d seconds have elapsed. Cancelling current goal, waiting 3 seconds, and exiting.", duration/1000);
break;
}
}
return 0;
}
void setGoal(ArPose goal)
Sets a new goal and sets the action to go there.
Definition: ArActionGoto.cpp:79
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
Action to limit speed (and stop) based on whether the "table"-sensors see anything.
Definition: ArActionLimiterTableSensor.h:40
Use onboard gyro to improve the heading in an ArRobot object's pose value.
Definition: ArAnalogGyro.h:95
void cancelGoal(void)
Cancels the goal; this action will stop requesting movement.
Definition: ArActionGoto.cpp:74
Legacy connector for robot and laser.
Definition: ArSimpleConnector.h:51
bool haveAchievedGoal(void)
Sees if the goal has been achieved.
Definition: ArActionGoto.cpp:66
bool comInt(unsigned char command, short int argument)
Sends a command to the robot with an int for argument.
Definition: ArRobot.cpp:5634
void enableMotors()
Enables the motors on the robot.
Definition: ArRobot.cpp:6521
static void setKeyHandler(ArKeyHandler *keyHandler)
Sets the key handler, so that other classes can find it using getKeyHandler()
Definition: Aria.cpp:624
bool connectRobot(ArRobot *robot)
Sets up the robot then connects it.
Definition: ArSimpleConnector.cpp:209
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
double getY(void) const
Gets the y position.
Definition: ariaUtil.h:814
double getX(void) const
Gets the x position.
Definition: ariaUtil.h:812
void setToNow(void)
Resets the time.
Definition: ariaUtil.cpp:1086
long mSecSince(ArTime since) const
Gets the number of milliseconds since the given timestamp to this one.
Definition: ariaUtil.h:1029
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
ArPose getGoal(void)
Gets the goal the action has.
Definition: ArActionGoto.h:77
This action goes to a given ArPose very naively.
Definition: ArActionGoto.h:52
void runAsync(bool stopRunIfNotConnected, bool runNonThreadedPacketReader=false)
Starts the instance to do processing in its own new thread.
Definition: ArRobot.cpp:301
int unlock()
Unlock the robot instance.
Definition: ArRobot.h:1272
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
static void sleep(unsigned int ms)
Sleep for the given number of milliseconds.
Definition: ariaUtil.cpp:151
@ Normal
Use normal logging.
Definition: ArLog.h:62
A class for time readings and measuring durations.
Definition: ariaUtil.h:1001
Action for stopping the robot.
Definition: ArActionStop.h:37
Represents an x, y position with an orientation.
Definition: ariaUtil.h:758
static bool getRunning(void)
Sees if Aria is still running (mostly for the thread in main)
Definition: Aria.cpp:753
int lock()
Lock the robot instance.
Definition: ArRobot.h:1268
void attachKeyHandler(ArKeyHandler *keyHandler, bool exitOnEscape=true, bool useExitNotShutdown=true)
Attachs a key handler.
Definition: ArRobot.cpp:6641
Action to limit the forwards motion of the robot based on range sensor readings.
Definition: ArActionLimiterForwards.h:39