12/16用テスト
Dependencies: ATP3012 mbed a HMC US015_2 getGPS
Diff: Function.h
- Revision:
- 6:326208aabe68
- Parent:
- 5:cc7917e8c442
- Child:
- 10:e25e06011fd2
diff -r cc7917e8c442 -r 326208aabe68 Function.h --- a/Function.h Wed Nov 10 12:17:25 2021 +0000 +++ b/Function.h Mon Dec 06 08:30:50 2021 +0000 @@ -12,7 +12,6 @@ ATP3011 talk(D4,D5); // I2C sda scl TB6612 motor_a(D10,D6,D7); //モータA制御用(pwma,ain1,ain2) TB6612 motor_b(D11,D8,D9); //モータB制御用(pwmb,bin1,bin2) -Serial pc(USBTX, USBRX); Serial xbee(A7, A2); double GPS_x, GPS_y; // 現在地の座標 @@ -28,9 +27,8 @@ hs.TrigerOut(); wait(1); int distance; - distance = hs.GetDistance(); - pc.printf("distance=%d\r\n", distance); //距離出力 - xbee.printf("distance=%d\r\n", distance); + distance = hs.GetDistance(); + xbee.printf("distance=%d\r\n", distance); //距離出力 Ultra=0;//超音波off if(distance < 200) { @@ -44,20 +42,17 @@ void catchGPS() { - pc.printf("GPS Start\r\n"); xbee.printf("GPS Start\r\n"); /* 1秒ごとに現在地を取得してターミナル出力 */ while(1) { if(gps.getgps()) { //現在地取得 - pc.printf("%lf %lf\r\n", gps.latitude, gps.longitude);//緯度と経度を出力 - xbee.printf("%lf %lf\r\n", gps.latitude, gps.longitude);// + xbee.printf("%lf %lf\r\n", gps.latitude, gps.longitude);//緯度と経度を出力 GPS_x = gps.latitude; GPS_y = gps.longitude; break; } else { - pc.printf("No data\r\n");//データ取得に失敗した場合 - xbee.printf("No data\r\n"); + xbee.printf("No data\r\n");//データ取得に失敗した場合 wait(1); } } @@ -111,7 +106,6 @@ double theta; double delta; - pc.printf("gps.latitude=%f, gps.longitude=%f\r\n", gps.latitude, gps.longitude); xbee.printf("gps.latitude=%f, gps.longitude=%f\r\n", gps.latitude, gps.longitude); theta = atan2(next_CP_y - gps.longitude , next_CP_x - gps.latitude) * 180 / 3.14159265359; printf("theta=%f\r\n", theta); @@ -129,29 +123,24 @@ void Calibration() { - pc.printf("calibration start\r\n"); xbee.printf("calibration start\r\n"); compass.setCalibrationMode(0x43); Move('4', 0.1); - pc.printf("mortor mode:4 speed:1\n\r"); xbee.printf("mortor mode:4 speed:1\n\r"); wait(60); Move('1', 0); - pc.printf("mortor mode:1 speed:0\n\r"); xbee.printf("mortor mode:1 speed:0\n\r"); compass.setCalibrationMode(0x45); - pc.printf("calibration end\r\n"); xbee.printf("calibration end\r\n"); while(1) { if(gps.getgps()) { //現在地取得 - pc.printf("%lf %lf\r\n", gps.latitude, gps.longitude);//緯度と経度を出力 + xbee.printf("lati=%lf\nlong=%lf\r\n", gps.latitude, gps.longitude);//緯度と経度を出力 GPS_x = gps.latitude; GPS_y = gps.longitude; break; } else { - pc.printf("No data\r\n");//データ取得に失敗した場合 - xbee.printf("No data\r\n"); + xbee.printf("No data\r\n");//データ取得に失敗した場合 wait(1); } } @@ -166,11 +155,9 @@ int timeout_ms=500; char mess[100]; if(talk.IsActive(timeout_ms)==true){ - pc.printf("Active\n\rflag=xbee ni Input"); xbee.printf("Active\n\rflag="); wait(3); if(xbee.readable()){ - pc.printf("\n\rmessage=xbee ni Input"); xbee.printf("\n\rmessage="); int i=0; do{ @@ -180,13 +167,11 @@ talk.Synthe(mess); } else{ - pc.printf("preset_message speak\r\n"); xbee.printf("preset_message speak\r\n"); talk.Synthe("purissetommese-ji,,konnichiwa."); } } else{ - pc.printf("\r\nNot Active\n"); xbee.printf("\r\nNot Active\n"); } } \ No newline at end of file