Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of IEEE_14_Freescale by
main.cpp@48:519deb1d4dff, 2014-04-03 (annotated)
- Committer:
- sswatek
- Date:
- Thu Apr 03 06:17:32 2014 +0000
- Revision:
- 48:519deb1d4dff
- Parent:
- 45:9c520ebc38e0
- Child:
- 49:7d172c133dbf
Moved servos to be in robot class and added convenience functions for them
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
soonerbot | 0:3a3dd78038a6 | 1 | #include "mbed.h" |
soonerbot | 1:c28fac16a109 | 2 | #include "dbgprint.h" |
soonerbot | 1:c28fac16a109 | 3 | #include "robot.h" |
soonerbot | 14:a30aa3b29a2e | 4 | #include "hcsr04.h" |
sswatek | 33:03b0b66038e1 | 5 | #include "game.h" |
soonerbot | 0:3a3dd78038a6 | 6 | |
soonerbot | 1:c28fac16a109 | 7 | BusOut leds(LED_RED,LED_GREEN,LED_BLUE); |
soonerbot | 1:c28fac16a109 | 8 | Serial pc(USBTX, USBRX); |
soonerbot | 0:3a3dd78038a6 | 9 | |
sswatek | 35:6ef5fbc45672 | 10 | |
soonerbot | 14:a30aa3b29a2e | 11 | |
soonerbot | 14:a30aa3b29a2e | 12 | /* |
soonerbot | 14:a30aa3b29a2e | 13 | //actual competition code, kinda |
soonerbot | 14:a30aa3b29a2e | 14 | int firstSection(){ // drive forward and measure distance |
soonerbot | 14:a30aa3b29a2e | 15 | tmpOut = bot.absDriveForward(targetAngle,3000); |
soonerbot | 14:a30aa3b29a2e | 16 | // ping sensor |
soonerbot | 14:a30aa3b29a2e | 17 | tmpOut = bot.absDriveForward(targetAngle,3000); |
soonerbot | 14:a30aa3b29a2e | 18 | // ping sensor |
soonerbot | 14:a30aa3b29a2e | 19 | } |
soonerbot | 14:a30aa3b29a2e | 20 | int secondsection(){ |
soonerbot | 14:a30aa3b29a2e | 21 | // second step |
soonerbot | 14:a30aa3b29a2e | 22 | // etc |
soonerbot | 14:a30aa3b29a2e | 23 | } |
soonerbot | 14:a30aa3b29a2e | 24 | */ |
soonerbot | 14:a30aa3b29a2e | 25 | |
soonerbot | 0:3a3dd78038a6 | 26 | int main() { |
sswatek | 35:6ef5fbc45672 | 27 | wait(0.1); |
sswatek | 35:6ef5fbc45672 | 28 | robot bot; |
sswatek | 35:6ef5fbc45672 | 29 | gamePlayer game(bot); |
sswatek | 48:519deb1d4dff | 30 | /*servo s(PTC9); |
sswatek | 37:38a4ad49343e | 31 | servo s2(PTC8); |
sswatek | 37:38a4ad49343e | 32 | servo s3(PTA5); |
sswatek | 48:519deb1d4dff | 33 | servo s4(PTA4);*/ |
soonerbot | 14:a30aa3b29a2e | 34 | // Initialize variables |
soonerbot | 14:a30aa3b29a2e | 35 | leds = 0x2; |
soonerbot | 1:c28fac16a109 | 36 | char tmpchar = 0; |
soonerbot | 14:a30aa3b29a2e | 37 | const int* constbuf; // displays values |
soonerbot | 10:926f142f16a3 | 38 | int tmpOut; |
soonerbot | 4:adc885f4ab75 | 39 | double targetAngle=0.0; |
soonerbot | 14:a30aa3b29a2e | 40 | DBGPRINT("AA\n\r",1); // to see if robot powers up at least |
soonerbot | 14:a30aa3b29a2e | 41 | |
soonerbot | 15:b10859606504 | 42 | //test servo |
sswatek | 48:519deb1d4dff | 43 | /*s.toPosition(-45); |
sswatek | 44:4b933e7409e7 | 44 | s2.toPosition(60); |
sswatek | 48:519deb1d4dff | 45 | s3.toPosition(250); |
sswatek | 48:519deb1d4dff | 46 | s4.toPosition(90);*/ |
soonerbot | 15:b10859606504 | 47 | |
sswatek | 42:28d73a7c624e | 48 | int s1pos = 45; |
sswatek | 42:28d73a7c624e | 49 | int s2pos = 45; |
soonerbot | 15:b10859606504 | 50 | |
soonerbot | 15:b10859606504 | 51 | //timer issue navigation test |
soonerbot | 15:b10859606504 | 52 | bot.absDriveForward(0,50);//assuming the bot stops in this function |
sswatek | 44:4b933e7409e7 | 53 | |
sswatek | 44:4b933e7409e7 | 54 | bot.gyro.stop();//stopping the gyro timer |
soonerbot | 15:b10859606504 | 55 | /* |
soonerbot | 15:b10859606504 | 56 | DBGPRINT("%f",bot.gyro.getZDegrees()); |
soonerbot | 15:b10859606504 | 57 | bot.gyro.stop();//stopping the gyro timer |
soonerbot | 15:b10859606504 | 58 | //bot.gyro.gyroUpkeepTicker.detach();//stopping the gyro timer |
soonerbot | 15:b10859606504 | 59 | //use sensor to find distance |
soonerbot | 15:b10859606504 | 60 | bot.pingLeft.trigger(); |
soonerbot | 15:b10859606504 | 61 | wait(0.1); |
soonerbot | 15:b10859606504 | 62 | float pingresult = bot.pingLeft.inches(); |
soonerbot | 15:b10859606504 | 63 | DBGPRINT("Distance = %f\r\n",pingresult); |
soonerbot | 15:b10859606504 | 64 | bot.gyro.start();//stopping the gyro timer |
soonerbot | 15:b10859606504 | 65 | DBGPRINT("%f",bot.gyro.getZDegrees()); |
soonerbot | 15:b10859606504 | 66 | */ |
sswatek | 23:53cafcd67828 | 67 | Timer dataTimer; |
sswatek | 23:53cafcd67828 | 68 | int testdata[]={'H','e','l','l','o'}; |
sswatek | 30:4158120cf801 | 69 | //int responseData[17]; |
sswatek | 23:53cafcd67828 | 70 | int response; |
sswatek | 23:53cafcd67828 | 71 | int gotAck=0; |
soonerbot | 14:a30aa3b29a2e | 72 | // Loop |
soonerbot | 0:3a3dd78038a6 | 73 | while(1) { |
soonerbot | 1:c28fac16a109 | 74 | DBGPRINT("BB\n\r",1); |
soonerbot | 7:3b2cf7efe5d1 | 75 | leds = leds^0x7; // toggle the LEDs for each loop |
soonerbot | 1:c28fac16a109 | 76 | tmpchar = pc.getc(); |
sswatek | 23:53cafcd67828 | 77 | bot.BTLink.procBuf(0x02); |
soonerbot | 7:3b2cf7efe5d1 | 78 | // all of these movement commands are blocking, so they can't be easily stopped short of resetting the microcontroller |
soonerbot | 1:c28fac16a109 | 79 | switch(tmpchar){ |
soonerbot | 15:b10859606504 | 80 | /*case 'e': //drive in a smallish square |
soonerbot | 7:3b2cf7efe5d1 | 81 | bot.driveForward(0,3000); |
soonerbot | 7:3b2cf7efe5d1 | 82 | bot.driveForward(-90,0); |
soonerbot | 7:3b2cf7efe5d1 | 83 | bot.driveForward(-90,3000); |
soonerbot | 7:3b2cf7efe5d1 | 84 | bot.driveForward(-180,0); |
soonerbot | 7:3b2cf7efe5d1 | 85 | bot.driveForward(-180,3000); |
soonerbot | 7:3b2cf7efe5d1 | 86 | bot.driveForward(-270,0); |
soonerbot | 7:3b2cf7efe5d1 | 87 | bot.driveForward(-270,3000); |
soonerbot | 7:3b2cf7efe5d1 | 88 | bot.driveForward(0,0); |
soonerbot | 7:3b2cf7efe5d1 | 89 | DBGPRINT("={%f,\t%f,\t%f}\n\r",bot.x,bot.y,bot.rot*180.0/3.14159); |
soonerbot | 15:b10859606504 | 90 | break;*/ |
soonerbot | 7:3b2cf7efe5d1 | 91 | case 'q': //poll the encoders |
soonerbot | 1:c28fac16a109 | 92 | constbuf = bot.bigenc.getVals(); |
soonerbot | 1:c28fac16a109 | 93 | DBGPRINT("\n\r%d\t%d\t%d\t%d\n\r",constbuf[0],constbuf[1],constbuf[2],constbuf[3]); |
soonerbot | 1:c28fac16a109 | 94 | break; |
soonerbot | 7:3b2cf7efe5d1 | 95 | case 'z': //set the current direction to "forward" for the following "go forward/reverse" commands |
soonerbot | 4:adc885f4ab75 | 96 | targetAngle = bot.gyro.getZDegrees(); |
soonerbot | 4:adc885f4ab75 | 97 | break; |
soonerbot | 7:3b2cf7efe5d1 | 98 | case 'w': // turn 90 degrees counter clockwise from the starting rotation |
soonerbot | 15:b10859606504 | 99 | |
sswatek | 48:519deb1d4dff | 100 | //s.toPosition(-40); |
soonerbot | 15:b10859606504 | 101 | //bot.driveForward(90,0); |
soonerbot | 7:3b2cf7efe5d1 | 102 | DBGPRINT("={%f,\t%f,\t%f}\n\r",bot.x,bot.y,bot.rot*180.0/3.14159); |
soonerbot | 7:3b2cf7efe5d1 | 103 | break; |
soonerbot | 7:3b2cf7efe5d1 | 104 | case 'x': // turn 90 degrees clockwise from the starting rotation |
sswatek | 48:519deb1d4dff | 105 | //s.toPosition(220); |
soonerbot | 15:b10859606504 | 106 | //bot.driveForward(-90,0); |
soonerbot | 6:62d498ee97cf | 107 | DBGPRINT("={%f,\t%f,\t%f}\n\r",bot.x,bot.y,bot.rot*180.0/3.14159); |
soonerbot | 6:62d498ee97cf | 108 | break; |
soonerbot | 7:3b2cf7efe5d1 | 109 | case 'a': // turn the opposite direction from the starting one |
sswatek | 48:519deb1d4dff | 110 | //s.toPosition(90); |
soonerbot | 15:b10859606504 | 111 | //bot.driveForward(180,0); |
soonerbot | 6:62d498ee97cf | 112 | DBGPRINT("={%f,\t%f,\t%f}\n\r",bot.x,bot.y,bot.rot*180.0/3.14159); |
soonerbot | 1:c28fac16a109 | 113 | break; |
soonerbot | 7:3b2cf7efe5d1 | 114 | case 'd': // turn back to starting rotation |
soonerbot | 15:b10859606504 | 115 | //bot.driveForward(0,0); |
sswatek | 18:c834bd26869e | 116 | response=bot.BTLink.sendCmd(0x02,testdata,5); |
sswatek | 17:e247d58d9f42 | 117 | DBGPRINT("=%d\n\r",response); |
soonerbot | 7:3b2cf7efe5d1 | 118 | break; |
soonerbot | 7:3b2cf7efe5d1 | 119 | case 'W': // drive forward a small bit |
soonerbot | 9:aff48e331147 | 120 | //bot.driveForward(targetAngle,1000); |
soonerbot | 10:926f142f16a3 | 121 | //bot.motors.moveForward(100); |
soonerbot | 11:967469d7e01c | 122 | tmpOut = bot.absDriveForward(targetAngle,3000); |
soonerbot | 10:926f142f16a3 | 123 | DBGPRINT("W -> %d\n\r",tmpOut); |
soonerbot | 12:925f52da3ba9 | 124 | DBGPRINT("={%f,\t%f,\t%f}\n\r",bot.x,bot.y,bot.rot*180.0/3.14159); |
soonerbot | 4:adc885f4ab75 | 125 | break; |
soonerbot | 7:3b2cf7efe5d1 | 126 | case 'E': //drive forward five times as much |
soonerbot | 15:b10859606504 | 127 | //bot.driveForward(targetAngle,5000); |
sswatek | 31:4ef53fbd6759 | 128 | bot.absDriveForward(0,290*16); |
soonerbot | 4:adc885f4ab75 | 129 | DBGPRINT("={%f,\t%f,\t%f}\n\r",bot.x,bot.y,bot.rot*180.0/3.14159); |
soonerbot | 4:adc885f4ab75 | 130 | break; |
soonerbot | 7:3b2cf7efe5d1 | 131 | case 'X': // small reverse |
soonerbot | 10:926f142f16a3 | 132 | //bot.driveForward(targetAngle,-1000); |
soonerbot | 10:926f142f16a3 | 133 | |
soonerbot | 11:967469d7e01c | 134 | tmpOut = bot.absDriveForward(targetAngle,-3000); |
soonerbot | 10:926f142f16a3 | 135 | DBGPRINT("X -> %d\n\r",tmpOut); |
soonerbot | 12:925f52da3ba9 | 136 | DBGPRINT("={%f,\t%f,\t%f}\n\r",bot.x,bot.y,bot.rot*180.0/3.14159); |
soonerbot | 4:adc885f4ab75 | 137 | break; |
soonerbot | 7:3b2cf7efe5d1 | 138 | case 'C': // big reverse |
soonerbot | 15:b10859606504 | 139 | //bot.driveForward(targetAngle,-5000); |
sswatek | 31:4ef53fbd6759 | 140 | bot.absDriveForward(0,-290*16); |
soonerbot | 4:adc885f4ab75 | 141 | DBGPRINT("={%f,\t%f,\t%f}\n\r",bot.x,bot.y,bot.rot*180.0/3.14159); |
soonerbot | 4:adc885f4ab75 | 142 | break; |
soonerbot | 7:3b2cf7efe5d1 | 143 | case 'p': // poll the gyro |
soonerbot | 3:a223b0bf8256 | 144 | DBGPRINT("%d\r\n",bot.gyro.getZ()); |
soonerbot | 3:a223b0bf8256 | 145 | break; |
soonerbot | 7:3b2cf7efe5d1 | 146 | case 'l': //calibrate the gyro ( caution, only use after resetting and before moving, otherwise will break any calibration) |
soonerbot | 3:a223b0bf8256 | 147 | bot.gyro.calibrate(); |
soonerbot | 3:a223b0bf8256 | 148 | break; |
soonerbot | 7:3b2cf7efe5d1 | 149 | |
soonerbot | 7:3b2cf7efe5d1 | 150 | // these are all control system modifications which should be fairly well locked down at this point |
soonerbot | 4:adc885f4ab75 | 151 | case 't': |
sswatek | 18:c834bd26869e | 152 | response=bot.BTLink.sendCmd(0x00,testdata,5); |
sswatek | 23:53cafcd67828 | 153 | //bot.gyro.stop(); |
sswatek | 23:53cafcd67828 | 154 | dataTimer.start(); |
sswatek | 23:53cafcd67828 | 155 | dataTimer.reset(); |
sswatek | 30:4158120cf801 | 156 | while(1){ |
sswatek | 30:4158120cf801 | 157 | gotAck=bot.BTLink.getAck(response); |
sswatek | 30:4158120cf801 | 158 | if(gotAck || dataTimer.read_ms()>=500) |
sswatek | 30:4158120cf801 | 159 | break; |
sswatek | 30:4158120cf801 | 160 | } |
sswatek | 23:53cafcd67828 | 161 | dataTimer.stop(); |
sswatek | 23:53cafcd67828 | 162 | //bot.gyro.start(); |
sswatek | 18:c834bd26869e | 163 | //bot.pfac*=2; |
sswatek | 18:c834bd26869e | 164 | //DBGPRINT("pfac = %f\r\n",bot.pfac); |
sswatek | 23:53cafcd67828 | 165 | DBGPRINT("Mode0=%d, %d, %d [%d]\n\r",response,bot.BTLink.bufSize(), gotAck, dataTimer.read_ms()); |
soonerbot | 4:adc885f4ab75 | 166 | break; |
soonerbot | 4:adc885f4ab75 | 167 | case 'g': |
sswatek | 29:1132155bc7da | 168 | DBGPRINT("full rotation %d,%f -> ",bot.gyro.getZ(),bot.gyro.getZDegrees()); |
sswatek | 33:03b0b66038e1 | 169 | for(int i=0;i<36;i++){ |
sswatek | 33:03b0b66038e1 | 170 | bot.smoothMove((8000.0/360.0)*(10.0), 1, 40); |
sswatek | 33:03b0b66038e1 | 171 | } |
sswatek | 29:1132155bc7da | 172 | DBGPRINT(" %d,%f\r\n",bot.gyro.getZ(),bot.gyro.getZDegrees()); |
soonerbot | 4:adc885f4ab75 | 173 | break; |
soonerbot | 4:adc885f4ab75 | 174 | case 'y': |
sswatek | 26:ade7c813538f | 175 | bot.pollForShapes(); |
soonerbot | 4:adc885f4ab75 | 176 | break; |
soonerbot | 4:adc885f4ab75 | 177 | case 'h': |
sswatek | 29:1132155bc7da | 178 | DBGPRINT("full rotation %d,%f -> ",bot.gyro.getZ(),bot.gyro.getZDegrees()); |
sswatek | 29:1132155bc7da | 179 | bot.smoothMove(-8000, 1, 40); |
sswatek | 29:1132155bc7da | 180 | DBGPRINT(" %d,%f\r\n",bot.gyro.getZ(),bot.gyro.getZDegrees()); |
soonerbot | 4:adc885f4ab75 | 181 | break; |
soonerbot | 4:adc885f4ab75 | 182 | case 'u': |
sswatek | 27:688409727452 | 183 | bot.pollForRigs(); |
soonerbot | 4:adc885f4ab75 | 184 | break; |
soonerbot | 4:adc885f4ab75 | 185 | case 'j': |
sswatek | 31:4ef53fbd6759 | 186 | DBGPRINT("LeftStable (15,8) = %f\r\n",bot.pingLeft.getStablePoll()); |
soonerbot | 4:adc885f4ab75 | 187 | break; |
soonerbot | 4:adc885f4ab75 | 188 | case 'i': |
soonerbot | 14:a30aa3b29a2e | 189 | //put distance ping here |
soonerbot | 14:a30aa3b29a2e | 190 | bot.pingLeft.trigger(); |
sswatek | 30:4158120cf801 | 191 | dataTimer.start(); |
sswatek | 30:4158120cf801 | 192 | dataTimer.reset(); |
sswatek | 30:4158120cf801 | 193 | while(bot.pingLeft.measuring && dataTimer.read_ms()<300); |
sswatek | 30:4158120cf801 | 194 | dataTimer.stop(); |
sswatek | 30:4158120cf801 | 195 | DBGPRINT("Distance = %f\r\n",bot.pingLeft.inches()); |
soonerbot | 4:adc885f4ab75 | 196 | break; |
soonerbot | 4:adc885f4ab75 | 197 | case 'k': |
sswatek | 30:4158120cf801 | 198 | dataTimer.start(); |
sswatek | 30:4158120cf801 | 199 | for(int i=0;i<100;i++){ |
sswatek | 30:4158120cf801 | 200 | bot.pingLeft.trigger(); |
sswatek | 30:4158120cf801 | 201 | dataTimer.reset(); |
sswatek | 30:4158120cf801 | 202 | while(bot.pingLeft.measuring && dataTimer.read_ms()<300); |
sswatek | 30:4158120cf801 | 203 | DBGPRINT("Distance %d = %f\r\n",i,bot.pingLeft.inches()); |
sswatek | 30:4158120cf801 | 204 | } |
sswatek | 30:4158120cf801 | 205 | dataTimer.stop(); |
sswatek | 26:ade7c813538f | 206 | //bot.angfac/=2; |
sswatek | 26:ade7c813538f | 207 | //DBGPRINT("angfac = %f\r\n",bot.angfac); |
soonerbot | 4:adc885f4ab75 | 208 | break; |
soonerbot | 4:adc885f4ab75 | 209 | case 'T': |
sswatek | 48:519deb1d4dff | 210 | DBGPRINT("Grabbing Tool\r\n",1); |
sswatek | 48:519deb1d4dff | 211 | //s.toPosition(-45); |
sswatek | 48:519deb1d4dff | 212 | //s2.toPosition(60); |
sswatek | 48:519deb1d4dff | 213 | bot.grabPosition(); |
sswatek | 44:4b933e7409e7 | 214 | wait(0.5); |
sswatek | 48:519deb1d4dff | 215 | bot.grab(); |
sswatek | 48:519deb1d4dff | 216 | /*s2.toPosition(-10); |
sswatek | 44:4b933e7409e7 | 217 | wait(0.5); |
sswatek | 44:4b933e7409e7 | 218 | //bot.cont.start(); |
sswatek | 44:4b933e7409e7 | 219 | bot.cont.resetTicks(); |
sswatek | 44:4b933e7409e7 | 220 | bot.cont.rampSpeed(-20,-20); |
sswatek | 44:4b933e7409e7 | 221 | //s.toPosition(0); |
sswatek | 44:4b933e7409e7 | 222 | //wait(.5); |
sswatek | 44:4b933e7409e7 | 223 | while(bot.cont.avgTicks()>-900){ |
sswatek | 44:4b933e7409e7 | 224 | s.toPosition((-45)+((35+45)*(-bot.cont.avgTicks()))/900); |
sswatek | 44:4b933e7409e7 | 225 | wait_ms(20); |
sswatek | 44:4b933e7409e7 | 226 | } |
sswatek | 44:4b933e7409e7 | 227 | bot.cont.rampSpeed(0,0); |
sswatek | 44:4b933e7409e7 | 228 | s.toPosition(130); |
sswatek | 48:519deb1d4dff | 229 | while(!bot.cont.stopped());*/ |
sswatek | 44:4b933e7409e7 | 230 | //bot.cont.stop(); |
sswatek | 44:4b933e7409e7 | 231 | //game.checkWaves(); |
soonerbot | 4:adc885f4ab75 | 232 | break; |
soonerbot | 4:adc885f4ab75 | 233 | case 'G': |
soonerbot | 38:3062838df0ce | 234 | DBGPRINT("Running First and Second Row\r\n",1); |
sswatek | 34:4ad11cda1eca | 235 | game.runFirstRow(); |
soonerbot | 38:3062838df0ce | 236 | game.runSecondRow(); |
soonerbot | 45:9c520ebc38e0 | 237 | game.runSecondRow(); |
soonerbot | 45:9c520ebc38e0 | 238 | game.approachRig(); |
sswatek | 26:ade7c813538f | 239 | //bot.pfac/=1.05; |
sswatek | 26:ade7c813538f | 240 | //DBGPRINT("pfac = %f\r\n",bot.pfac); |
soonerbot | 4:adc885f4ab75 | 241 | break; |
soonerbot | 45:9c520ebc38e0 | 242 | case 's': |
soonerbot | 45:9c520ebc38e0 | 243 | game.runSecondRow(); //testing second and third row |
soonerbot | 45:9c520ebc38e0 | 244 | game.runSecondRow(); |
soonerbot | 45:9c520ebc38e0 | 245 | break; |
soonerbot | 4:adc885f4ab75 | 246 | case 'Y': |
sswatek | 44:4b933e7409e7 | 247 | /*bot.cont.start(); |
sswatek | 43:f7ef0f5f980c | 248 | bot.cont.rampSpeed(40,40); |
sswatek | 44:4b933e7409e7 | 249 | while(!bot.cont.steady()); |
sswatek | 43:f7ef0f5f980c | 250 | bot.cont.rampSpeed(0,0); |
sswatek | 44:4b933e7409e7 | 251 | while(!bot.cont.stopped()); |
sswatek | 44:4b933e7409e7 | 252 | bot.cont.stop();*/ |
sswatek | 48:519deb1d4dff | 253 | //s3.toPosition(s1pos+=5); |
sswatek | 48:519deb1d4dff | 254 | //bot.alignWithRig(); |
sswatek | 42:28d73a7c624e | 255 | DBGPRINT("1 pos = %d\r\n",s1pos); |
soonerbot | 4:adc885f4ab75 | 256 | break; |
soonerbot | 4:adc885f4ab75 | 257 | case 'H': |
sswatek | 48:519deb1d4dff | 258 | //s3.toPosition(s1pos-=5); |
sswatek | 42:28d73a7c624e | 259 | DBGPRINT("1 pos = %d\r\n",s1pos); |
soonerbot | 4:adc885f4ab75 | 260 | break; |
soonerbot | 4:adc885f4ab75 | 261 | case 'U': |
sswatek | 48:519deb1d4dff | 262 | //s4.toPosition(s2pos+=5); |
sswatek | 42:28d73a7c624e | 263 | DBGPRINT("2 pos = %d\r\n",s2pos); |
soonerbot | 4:adc885f4ab75 | 264 | break; |
soonerbot | 4:adc885f4ab75 | 265 | case 'J': |
sswatek | 48:519deb1d4dff | 266 | //s4.toPosition(s2pos-=5); |
sswatek | 42:28d73a7c624e | 267 | DBGPRINT("2 pos = %d\r\n",s2pos); |
soonerbot | 4:adc885f4ab75 | 268 | break; |
soonerbot | 7:3b2cf7efe5d1 | 269 | |
soonerbot | 7:3b2cf7efe5d1 | 270 | // poll the compass ( currently gives bad values ) |
soonerbot | 4:adc885f4ab75 | 271 | case 'Q': |
sswatek | 28:c7e8d2db03f5 | 272 | //bot.gyro.checkCompass(); |
sswatek | 28:c7e8d2db03f5 | 273 | DBGPRINT("Compass vector = %d\t%d\t%d\t%f\r\n",bot.gyro.xmag,bot.gyro.ymag,bot.gyro.zmag,bot.gyro.compDir*180.0/3.14159); |
soonerbot | 4:adc885f4ab75 | 274 | break; |
soonerbot | 7:3b2cf7efe5d1 | 275 | |
soonerbot | 7:3b2cf7efe5d1 | 276 | // brake if we get an unknown command |
soonerbot | 1:c28fac16a109 | 277 | default: |
soonerbot | 15:b10859606504 | 278 | //bot.left.brake(); |
soonerbot | 15:b10859606504 | 279 | //bot.right.brake(); |
soonerbot | 1:c28fac16a109 | 280 | break; |
soonerbot | 1:c28fac16a109 | 281 | |
soonerbot | 1:c28fac16a109 | 282 | } |
soonerbot | 0:3a3dd78038a6 | 283 | } |
soonerbot | 0:3a3dd78038a6 | 284 | } |