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.
Dependencies: mbed HMC6352 US015 TB6612FNG2 getGPS ATP3011
Diff: main.cpp
- Revision:
- 3:74d0faefdd78
- Parent:
- 1:f6d4f374b130
- Child:
- 5:56eddb7b4a9e
--- a/main.cpp Sun Oct 24 05:28:29 2021 +0000
+++ b/main.cpp Sun Oct 24 06:17:23 2021 +0000
@@ -15,18 +15,18 @@
double GPS_x, GPS_y; // 現在地の座標
double *pGPS_x = &GPS_x, *pGPS_y = &GPS_y;
double direction; // 次CPへの向き
-double CPs_x[] = []; // CPリスト(x座標)
-double CPs_y[] = []; // CPリスト(y座標)
+double CPs_x[100]; // = []; //CPリスト(x座標)
+double CPs_y[100]; // = []; // CPリスト(y座標)
double next_CP_x, next_CP_y;
// 行動フロー開始
last_num = sizeof(CPs_x) / sizeof(double) - 1;
while (next_CP_x != CPs_x[last_num] && next_CP_y != CPs_y[last_num]) {
int i;
- for (i = CP_num, last_num, i++) {
+ for (i = CP_num; last_num; i++) {
// 移動
- 位置情報を取得();
- 方向取得();
+ catchGPS();
+ AngleGet();
回転();
while(i >= 5) // 5°ずれると方向転換する
{
@@ -35,13 +35,17 @@
}
motor(1)
while (True) {
- 前方取得();
- if (/* 障害物あり */) 停止()
- 回避行動();
- else 移動();
+ if (FrontGet()) {
+ MotorDriver(1, 0); //停止()
+ Avoid();
+ }
+ else {
+ 移動();
+ }
位置情報を取得();
- if (next_CP_x = GPS_x &&next_CP_y = GPS_y) blake;
- }
+ if ((next_CP_x - GPS_x)*(next_CP_x - GPS_x) + (next_CP_y = GPS_y)*(next_CP_y = GPS_y) < 5) { //試験で調整
+ break;
+ }
}
// 行動フロー終了
}