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
main.cpp@6:1cda8471adc3, 2021-10-24 (annotated)
- Committer:
- user_
- Date:
- Sun Oct 24 13:48:07 2021 +0000
- Revision:
- 6:1cda8471adc3
- Parent:
- 5:56eddb7b4a9e
- Child:
- 7:8fab045d2616
test;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| user_ | 6:1cda8471adc3 | 1 | // ライブラリ |
| ushiroji | 0:5a1b52164bbe | 2 | #include "mbed.h" |
| ushiroji | 0:5a1b52164bbe | 3 | #include "TB6612.h" |
| ushiroji | 0:5a1b52164bbe | 4 | #include "ATP3011.h" |
| user_ | 6:1cda8471adc3 | 5 | #include "HMC6352.h" |
| user_ | 6:1cda8471adc3 | 6 | // 自作関数 |
| user_ | 6:1cda8471adc3 | 7 | #include "AngleGet.h" |
| user_ | 6:1cda8471adc3 | 8 | #include "Avoid.h" // 廃止予定 |
| ushiroji | 0:5a1b52164bbe | 9 | #include "getGPS.h" |
| user_ | 6:1cda8471adc3 | 10 | #include "catchGPS.h" |
| ushiroji | 1:f6d4f374b130 | 11 | #include "FrontGet.h" |
| user_ | 6:1cda8471adc3 | 12 | #include "MotorDriver.h" |
| ushiroji | 0:5a1b52164bbe | 13 | |
| ushiroji | 0:5a1b52164bbe | 14 | |
| ushiroji | 0:5a1b52164bbe | 15 | int main() { |
| ushiroji | 0:5a1b52164bbe | 16 | // 変数宣言 |
| ushiroji | 0:5a1b52164bbe | 17 | int CP_num; // CPリストのインデックス |
| user_ | 6:1cda8471adc3 | 18 | int last_num; // CPリストの最後の要素のインデックス |
| user_ | 6:1cda8471adc3 | 19 | double GPS_x, GPS_y; // 現在地の座標 |
| user_ | 6:1cda8471adc3 | 20 | double direction; // 次CPへの向き |
| user_ | 6:1cda8471adc3 | 21 | double CPs_x[100]; // = []; //CPリスト(x座標) |
| user_ | 6:1cda8471adc3 | 22 | double CPs_y[100]; // = []; // CPリスト(y座標) |
| user_ | 6:1cda8471adc3 | 23 | double next_CP_x, next_CP_y; |
| user_ | 6:1cda8471adc3 | 24 | |
| user_ | 6:1cda8471adc3 | 25 | // 落下検知 |
| user_ | 6:1cda8471adc3 | 26 | |
| user_ | 6:1cda8471adc3 | 27 | // パラシュート分離 |
| ushiroji | 0:5a1b52164bbe | 28 | |
| user_ | 6:1cda8471adc3 | 29 | // 行動フロー開始 |
| user_ | 6:1cda8471adc3 | 30 | last_num = sizeof(CPs_x) / sizeof(double) - 1; // ゴール地点のインデックスを算出 |
| user_ | 6:1cda8471adc3 | 31 | while (next_CP_x != CPs_x[last_num] && next_CP_y != CPs_y[last_num]) { // ゴール判定 |
| user_ | 6:1cda8471adc3 | 32 | int i; |
| user_ | 6:1cda8471adc3 | 33 | for (i = CP_num; last_num; i++) { |
| user_ | 6:1cda8471adc3 | 34 | // 移動 |
| user_ | 6:1cda8471adc3 | 35 | catchGPS(&GPS_x, &GPS_y); |
| user_ | 6:1cda8471adc3 | 36 | AngleGet(); |
| user_ | 6:1cda8471adc3 | 37 | 回転(); |
| ushiroji | 5:56eddb7b4a9e | 38 | |
| user_ | 6:1cda8471adc3 | 39 | motor(1) |
| user_ | 6:1cda8471adc3 | 40 | while (True) { |
| user_ | 6:1cda8471adc3 | 41 | if (FrontGet()) { |
| user_ | 6:1cda8471adc3 | 42 | MotorDriver(1, 0); //停止() |
| user_ | 6:1cda8471adc3 | 43 | MotorDriver(4, 0.5); //回転 |
| user_ | 6:1cda8471adc3 | 44 | continue; |
| user_ | 6:1cda8471adc3 | 45 | } else { |
| user_ | 6:1cda8471adc3 | 46 | 移動(); |
| user_ | 6:1cda8471adc3 | 47 | } |
| user_ | 6:1cda8471adc3 | 48 | catchGPS(&GPS_x, &GPS_y);; |
| user_ | 6:1cda8471adc3 | 49 | if ((next_CP_x - GPS_x)*(next_CP_x - GPS_x) + (next_CP_y = GPS_y)*(next_CP_y = GPS_y) < 5) { // CP到着判定 //試験で調整 |
| user_ | 6:1cda8471adc3 | 50 | break; |
| ushiroji | 3:74d0faefdd78 | 51 | } |
| ushiroji | 5:56eddb7b4a9e | 52 | } |
| user_ | 6:1cda8471adc3 | 53 | // 行動フロー終了 |
| user_ | 6:1cda8471adc3 | 54 | return 0; |
| ushiroji | 5:56eddb7b4a9e | 55 | } |