00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "Aria.h"
00027
00040 int main(int argc, char **argv)
00041 {
00042 Aria::init();
00043
00044 ArRobot robot;
00045
00046
00047 ArActionLimiterForwards limiter("speed limiter near", 300, 600, 250);
00048
00049 ArActionLimiterForwards limiterFar("speed limiter far", 300, 1100, 400);
00050
00051 ArActionLimiterTableSensor tableLimiter;
00052
00053 ArActionLimiterBackwards backwardsLimiter;
00054
00055 ArActionJoydrive joydriveAct;
00056
00057 ArActionKeydrive keydriveAct;
00058
00059
00060 ArSonarDevice sonar;
00061
00062 ArArgumentParser parser(&argc, argv);
00063 parser.loadDefaultArguments();
00064 ArSimpleConnector connector(&parser);
00065
00066 if (!Aria::parseArgs())
00067 {
00068 Aria::logOptions();
00069 Aria::shutdown();
00070 return 1;
00071 }
00072
00073
00074 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");
00075
00076
00077 if (!joydriveAct.joystickInited())
00078 printf("Do not have a joystick, only the arrow keys on the keyboard will work.\n");
00079
00080
00081 joydriveAct.setStopIfNoButtonPressed(false);
00082
00083
00084 robot.addRangeDevice(&sonar);
00085
00086
00087 if (!connector.connectRobot(&robot))
00088 {
00089 printf("Could not connect to robot... exiting\n");
00090 Aria::shutdown();
00091 return 1;
00092 }
00093
00094
00095
00096 robot.setAbsoluteMaxTransVel(400);
00097
00098
00099 robot.enableMotors();
00100
00101
00102
00103
00104 robot.addAction(&tableLimiter, 100);
00105 robot.addAction(&limiter, 95);
00106 robot.addAction(&limiterFar, 90);
00107 robot.addAction(&backwardsLimiter, 85);
00108 robot.addAction(&joydriveAct, 50);
00109 robot.addAction(&keydriveAct, 45);
00110
00111
00112
00113
00114 joydriveAct.setStopIfNoButtonPressed(false);
00115
00116
00117
00118 robot.run(true);
00119
00120 Aria::shutdown();
00121 return 0;
00122 }