cansat program1
Dependencies: ADXL345 BME280 HMC5883L ITG3200 MBed_Adafruit-GPS-Library XBee agzIDLIST cansat mbed
Fork of Cansat_program4_1 by
Diff: main.cpp
- Revision:
- 20:f92bdcda5a60
- Parent:
- 19:cb3a4b4c3526
- Child:
- 21:18a196d3021c
--- a/main.cpp Thu Aug 13 07:11:57 2015 +0000 +++ b/main.cpp Fri Aug 14 04:56:21 2015 +0000 @@ -69,9 +69,9 @@ int running_flag = 0; Timer compass_Timer; -const int compass_Time = 500; +const int compass_Time = 50; Timer running_Timer; -const int running_Time = 500; +const int running_Time = 50; Timer parachute_Timer; const int parachute_Time = 30000; ///////////////////////////////////////// @@ -90,8 +90,8 @@ double preHeading = 0.0; int maxX, minX, maxY, minY; -const int ofsX = 36; //calibration x -const int ofsY = -425; //calibration y +const int ofsX = -102; //calibration x +const int ofsY = -381; //calibration y int16_t raw[3]; @@ -216,29 +216,21 @@ if(t==r) { //前進 return 'f'; - } else if(n < 4) { + } else if(n == 4) { + return 'r'; + } else if(n > 0 && n < 4) { if(t > r) - t -= 8; + return 'r'; else - r -= 8; - - if(r-t > 0) + return 'l'; + } else if(n > 4 && n < 8){ + if(t > r) return 'l'; else return 'r'; - } else if(n >= 4) { - if(t > r) - t -= 8; - else - r -= 8; - - if(r-t > 0) - return 'r'; - else - return 'l'; - } + } else + return 'b'; - return 'b'; } //対象とロボットの角度