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:
- 6:1cda8471adc3
- Parent:
- 5:56eddb7b4a9e
- Child:
- 7:8fab045d2616
--- a/main.cpp Sun Oct 24 06:38:24 2021 +0000
+++ b/main.cpp Sun Oct 24 13:48:07 2021 +0000
@@ -1,48 +1,55 @@
+// ライブラリ
#include "mbed.h"
#include "TB6612.h"
#include "ATP3011.h"
+#include "HMC6352.h"
+// 自作関数
+#include "AngleGet.h"
+#include "Avoid.h" // 廃止予定
#include "getGPS.h"
-#include "HMC6352.h"
-#include "Avoid.h"
+#include "catchGPS.h"
#include "FrontGet.h"
-#include "AngleGet.h"
+#include "MotorDriver.h"
int main() {
// 変数宣言
int CP_num; // CPリストのインデックス
-int last_num; // CPリストの最後の要素のインデックス
-double GPS_x, GPS_y; // 現在地の座標
-double *pGPS_x = &GPS_x, *pGPS_y = &GPS_y;
-double direction; // 次CPへの向き
-double CPs_x[100]; // = []; //CPリスト(x座標)
-double CPs_y[100]; // = []; // CPリスト(y座標)
-double next_CP_x, next_CP_y;
+ int last_num; // CPリストの最後の要素のインデックス
+ double GPS_x, GPS_y; // 現在地の座標
+ double direction; // 次CPへの向き
+ 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++) {
- // 移動
- catchGPS();
- AngleGet();
- 回転();
+ // 行動フロー開始
+ 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++) {
+ // 移動
+ catchGPS(&GPS_x, &GPS_y);
+ AngleGet();
+ 回転();
- motor(1)
- while (True) {
- if (FrontGet()) {
- MotorDriver(1, 0); //停止()
- MotorDriver(4, 0.5); //回転
- continue;
- }
- else {
- 移動();
- }
- 位置情報を取得();
- if ((next_CP_x - GPS_x)*(next_CP_x - GPS_x) + (next_CP_y = GPS_y)*(next_CP_y = GPS_y) < 5) { //試験で調整
- break;
+ motor(1)
+ while (True) {
+ if (FrontGet()) {
+ MotorDriver(1, 0); //停止()
+ MotorDriver(4, 0.5); //回転
+ continue;
+ } else {
+ 移動();
+ }
+ catchGPS(&GPS_x, &GPS_y);;
+ if ((next_CP_x - GPS_x)*(next_CP_x - GPS_x) + (next_CP_y = GPS_y)*(next_CP_y = GPS_y) < 5) { // CP到着判定 //試験で調整
+ break;
}
}
- // 行動フロー終了
+ // 行動フロー終了
+ return 0;
}