beobot-calibrate.C
Go to the documentation of this file.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
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include "Component/ModelManager.H"
00039 #include "Devices/BeoChip.H"
00040 #include "Devices/DeviceOpts.H"
00041 #include "Util/MathFunctions.H"
00042
00043 #include <cstdlib>
00044
00045
00046
00047
00048 int main(const int argc, const char* argv[])
00049 {
00050 MYLOGVERB = LOG_INFO;
00051
00052
00053 ModelManager manager("Beobot Calibrator");
00054
00055
00056 nub::soft_ref<BeoChip> b(new BeoChip(manager));
00057 manager.addSubComponent(b);
00058
00059
00060 if (manager.parseCommandLine(argc, argv, "<serdev> <sernum>", 2, 2) == false)
00061 return(1);
00062
00063
00064 b->setModelParamVal("BeoChipDeviceName", manager.getExtraArg(0));
00065 int servo = manager.getExtraArgAs<int>(1);
00066
00067
00068 manager.start();
00069
00070
00071 b->lcdClear();
00072 b->lcdPrintf(0, 0, " Beobot Servo Calib");
00073 const byte neutral = byte(127);
00074 LINFO("Setting all servos to neutral (%d)", neutral);
00075 b->setServoRaw(servo, neutral);
00076
00077 LINFO("Press and hold ESC 'SET' button until LED turns solid red.");
00078 LINFO("Then release button and press [RETURN]");
00079 getchar();
00080
00081 LINFO("Setting servo %d to full forward (255)", servo);
00082 b->setServoRaw(servo, 255);
00083 LINFO("Press [RETURN] when LED turns solid green.");
00084 getchar();
00085
00086 LINFO("Setting servo %d to full reverse (0)", servo);
00087 b->setServoRaw(servo, 0);
00088 LINFO("Press [RETURN] when LED blinks green.");
00089 getchar();
00090
00091 LINFO("Setting servo %d to neutral (%d)", servo, neutral);
00092 b->setServoRaw(servo, neutral);
00093 LINFO("Press [RETURN] when LED gets solid red.");
00094 getchar();
00095
00096 LINFO("Calibration complete!");
00097
00098 while(1) {
00099 b->setServoRaw(servo, neutral);
00100 LINFO("Neutral... press [RETURN] to continue");
00101 getchar();
00102
00103 b->setServoRaw(servo, 192);
00104 LINFO("Weak forward... press [RETURN] to continue");
00105 getchar();
00106
00107 b->setServoRaw(servo, 255);
00108 LINFO("Full forward... press [RETURN] to continue");
00109 getchar();
00110
00111 b->setServoRaw(servo, neutral);
00112 LINFO("Neutral... press [RETURN] to continue");
00113 getchar();
00114
00115 b->setServoRaw(servo, 64);
00116 LINFO("Weak reverse... press [RETURN] to continue");
00117 getchar();
00118
00119 b->setServoRaw(servo, 0);
00120 LINFO("Full Reverse... press [RETURN] to continue");
00121 getchar();
00122 }
00123
00124 manager.stop();
00125 return 0;
00126 }
00127
00128
00129
00130
00131
00132