統合試験用です。

Dependencies:   ATP3012 mbed TB6612FNG HMC US015 getGPS

Committer:
ushiroji
Date:
Sun Oct 24 06:17:23 2021 +0000
Revision:
3:74d0faefdd78
Parent:
1:f6d4f374b130
Child:
5:56eddb7b4a9e
test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ushiroji 0:5a1b52164bbe 1 #include "mbed.h"
ushiroji 0:5a1b52164bbe 2 #include "TB6612.h"
ushiroji 0:5a1b52164bbe 3 #include "ATP3011.h"
ushiroji 0:5a1b52164bbe 4 #include "getGPS.h"
ushiroji 0:5a1b52164bbe 5 #include "HMC6352.h"
ushiroji 1:f6d4f374b130 6 #include "Avoid.h"
ushiroji 1:f6d4f374b130 7 #include "FrontGet.h"
ushiroji 1:f6d4f374b130 8 #include "AngleGet.h"
ushiroji 0:5a1b52164bbe 9
ushiroji 0:5a1b52164bbe 10
ushiroji 0:5a1b52164bbe 11 int main() {
ushiroji 0:5a1b52164bbe 12 // 変数宣言
ushiroji 0:5a1b52164bbe 13 int CP_num; // CPリストのインデックス
ushiroji 0:5a1b52164bbe 14 int last_num; // CPリストの最後の要素のインデックス
ushiroji 0:5a1b52164bbe 15 double GPS_x, GPS_y; // 現在地の座標
ushiroji 0:5a1b52164bbe 16 double *pGPS_x = &GPS_x, *pGPS_y = &GPS_y;
ushiroji 0:5a1b52164bbe 17 double direction; // 次CPへの向き
ushiroji 3:74d0faefdd78 18 double CPs_x[100]; // = []; //CPリスト(x座標)
ushiroji 3:74d0faefdd78 19 double CPs_y[100]; // = []; // CPリスト(y座標)
ushiroji 0:5a1b52164bbe 20 double next_CP_x, next_CP_y;
ushiroji 0:5a1b52164bbe 21
ushiroji 0:5a1b52164bbe 22 // 行動フロー開始
ushiroji 0:5a1b52164bbe 23 last_num = sizeof(CPs_x) / sizeof(double) - 1;
ushiroji 0:5a1b52164bbe 24 while (next_CP_x != CPs_x[last_num] && next_CP_y != CPs_y[last_num]) {
ushiroji 0:5a1b52164bbe 25 int i;
ushiroji 3:74d0faefdd78 26 for (i = CP_num; last_num; i++) {
ushiroji 0:5a1b52164bbe 27 // 移動
ushiroji 3:74d0faefdd78 28 catchGPS();
ushiroji 3:74d0faefdd78 29 AngleGet();
ushiroji 0:5a1b52164bbe 30 回転();
ushiroji 0:5a1b52164bbe 31 while(i >= 5) // 5°ずれると方向転換する
ushiroji 0:5a1b52164bbe 32 {
ushiroji 0:5a1b52164bbe 33
ushiroji 0:5a1b52164bbe 34
ushiroji 0:5a1b52164bbe 35 }
ushiroji 0:5a1b52164bbe 36 motor(1)
ushiroji 0:5a1b52164bbe 37 while (True) {
ushiroji 3:74d0faefdd78 38 if (FrontGet()) {
ushiroji 3:74d0faefdd78 39 MotorDriver(1, 0); //停止()
ushiroji 3:74d0faefdd78 40 Avoid();
ushiroji 3:74d0faefdd78 41 }
ushiroji 3:74d0faefdd78 42 else {
ushiroji 3:74d0faefdd78 43 移動();
ushiroji 3:74d0faefdd78 44 }
ushiroji 0:5a1b52164bbe 45 位置情報を取得();
ushiroji 3:74d0faefdd78 46 if ((next_CP_x - GPS_x)*(next_CP_x - GPS_x) + (next_CP_y = GPS_y)*(next_CP_y = GPS_y) < 5) { //試験で調整
ushiroji 3:74d0faefdd78 47 break;
ushiroji 3:74d0faefdd78 48 }
ushiroji 0:5a1b52164bbe 49 }
ushiroji 0:5a1b52164bbe 50 // 行動フロー終了
ushiroji 0:5a1b52164bbe 51 }