example showing how to connect and send basic motion commands to the robotARIA provides two levels of robot motion control, direct motion commands, and actions. This example shows direct motion commands. See actionExample.cpp, actionGroupExample.cpp, and others for examples on how to use actions. Actions provide a more modular way of performing more complex motion behaviors than the simple imperitive style used here.
See the ArRobot class documentation, as well as the overview of robot motion, for more information.
WARNING: this program does no sensing or avoiding of obstacles, the robot WILL collide with any objects in the way! Make sure the robot has about 2-3 meters of free space around it before starting the program.
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)
{
ArLog::log(
ArLog::Terse,
"WARNING: this program does no sensing or avoiding of obstacles, the robot WILL collide with any objects in the way! Make sure the robot has approximately 3 meters of free space on all sides.");
{
{
return 1;
}
}
{
return 1;
}
ArLog::log(
ArLog::Normal,
"simpleMotionCommands: Pose=(%.2f,%.2f,%.2f), Trans. Vel=%.2f, Rot. Vel=%.2f, Battery=%.2fV",
ArLog::log(
ArLog::Normal,
"simpleMotionCommands: Pose=(%.2f,%.2f,%.2f), Trans. Vel=%.2f, Rot. Vel=%.2f, Battery=%.2fV",
return 0;
}
double getVel(void) const
Gets the current translational velocity of the robot.
Definition: ArRobot.h:330
bool connectRobot(void)
Sets up the robot then connects it.
Definition: ArRobotConnector.cpp:405
void stop(void)
Stops the robot.
Definition: ArRobot.cpp:1935
void stopRunning(bool doDisconnect=true)
Stops the robot from doing any more processing.
Definition: ArRobot.cpp:340
void loadDefaultArguments(int positon=1)
Adds args from default files and environmental variables.
Definition: ArArgumentParser.cpp:736
void setRotVel(double velocity)
Sets the rotational velocity.
Definition: ArRobot.cpp:2099
Use terse logging.
Definition: ArLog.h:61
double getBatteryVoltage(void) const
Gets the battery voltage of the robot (normalized to 12 volt system)
Definition: ArRobot.h:374
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
double getTh(void) const
Gets the global angular position ("theta") of the robot.
Definition: ArRobot.h:316
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
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
double getRotVel(void) const
Gets the current rotational velocity of the robot.
Definition: ArRobot.h:338
void setVel(double velocity)
Sets the velocity.
Definition: ArRobot.cpp:1956
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
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
double getX(void) const
Gets the global X position of the robot.
Definition: ArRobot.h:310
Use normal logging.
Definition: ArLog.h:62
double getY(void) const
Gets the global Y position of the robot.
Definition: ArRobot.h:313
int lock()
Lock the robot instance.
Definition: ArRobot.h:1268
WaitState waitForRunExit(unsigned int msecs=0)
Suspend calling thread until the ArRobot run loop has exited.
Definition: ArRobot.cpp:2923