Note that if you want to stop direct motion commands and let ArActions take over, you must call ArRobot::clearDirectMotion() (otherwise ArRobot may continue sending motion commands that conflict with the requests of the action resolver). See the section on motion commands and actions for details.
#include "Aria.h"
class ConnHandler
{
public:
~ConnHandler(void) {}
void connected(void);
void connFail(void);
void disconnected(void);
protected:
};
ConnHandler::ConnHandler(
ArRobot *robot) :
myConnectedCB(this, &ConnHandler::connected),
myConnFailCB(this, &ConnHandler::connFail),
myDisconnectedCB(this, &ConnHandler::disconnected)
{
myRobot = robot;
}
void ConnHandler::connFail(void)
{
printf("directMotionDemo connection handler: Failed to connect.\n");
myRobot->stopRunning();
return;
}
void ConnHandler::connected(void)
{
printf("directMotionDemo connection handler: Connected\n");
}
void ConnHandler::disconnected(void)
{
printf("directMotionDemo connection handler: Lost connection, exiting program.\n");
}
int main(int argc, char **argv)
{
ConnHandler ch(&robot);
{
return 1;
}
{
{
}
return 1;
}
{
}
printf("directMotionExample: Setting rot velocity to 100 deg/sec then sleeping 3 seconds\n");
printf("Stopping\n");
printf("directMotionExample: Telling the robot to go 300 mm on left wheel and 100 mm on right wheel for 5 seconds\n");
while (1)
{
{
break;
}
}
printf("directMotionExample: Telling the robot to move forwards one meter, then sleeping 5 seconds\n");
while (1)
{
{
printf("directMotionExample: Finished distance\n");
break;
}
{
printf("directMotionExample: Distance timed out\n");
break;
}
}
printf("directMotionExample: Telling the robot to move backwards one meter, then sleeping 5 seconds\n");
while (1)
{
{
printf("directMotionExample: Finished distance\n");
break;
}
{
printf("directMotionExample: Distance timed out\n");
break;
}
}
printf("directMotionExample: Telling the robot to turn to 180, then sleeping 4 seconds\n");
while (1)
{
{
printf("directMotionExample: Finished turn\n");
break;
}
{
printf("directMotionExample: Turn timed out\n");
break;
}
}
printf("directMotionExample: Telling the robot to turn to 90, then sleeping 2 seconds\n");
while (1)
{
{
printf("directMotionExample: Finished turn\n");
break;
}
{
printf("directMotionExample: turn timed out\n");
break;
}
}
printf("directMotionExample: Setting vel2 to 200 mm/sec on both wheels, then sleeping 3 seconds\n");
printf("directMotionExample: Stopping the robot, then sleeping for 2 seconds\n");
printf("directMotionExample: Setting velocity to 200 mm/sec then sleeping 3 seconds\n");
printf("directMotionExample: Stopping the robot, then sleeping for 2 seconds\n");
printf("directMotionExample: Setting vel2 with 0 on left wheel, 200 mm/sec on right, then sleeping 5 seconds\n");
printf("directMotionExample: Telling the robot to rotate at 50 deg/sec then sleeping 5 seconds\n");
printf("directMotionExample: Telling the robot to rotate at -50 deg/sec then sleeping 5 seconds\n");
printf("directMotionExample: Setting vel2 with 0 on both wheels, then sleeping 3 seconds\n");
printf("directMotionExample: Now having the robot change heading by -125 degrees, then sleeping for 6 seconds\n");
printf("directMotionExample: Now having the robot change heading by 45 degrees, then sleeping for 6 seconds\n");
printf("directMotionExample: Setting vel2 with 200 on left wheel, 0 on right wheel, then sleeping 5 seconds\n");
printf("directMotionExample: Done, exiting.\n");
return 0;
}