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.
Diff: moves/moves.cpp
- Revision:
- 57:30cd20c654d1
- Parent:
- 53:4673b85e1d2a
- Child:
- 58:dc0faefeba39
diff -r 1b1e5839dde1 -r 30cd20c654d1 moves/moves.cpp --- a/moves/moves.cpp Mon May 20 11:51:19 2019 +0000 +++ b/moves/moves.cpp Sat May 25 04:50:48 2019 +0000 @@ -83,6 +83,7 @@ LEFT, RIGHT, }; + int is_turn = 0; static int lope_count = 0; const int max_count = 3; Mode mode; @@ -93,9 +94,10 @@ } else { mode = STRAIGHT; } - //カーブしすぎたら強制的に直進 + //カーブしても治らなければturnに切り替え if(lope_count >= max_count) { - mode = STRAIGHT; +// mode = STRAIGHT; + is_turn = 1; } switch(mode) { case STRAIGHT: @@ -103,11 +105,19 @@ lope_count=0; break; case LEFT: - curveLeft(); + if(is_turn == 1) { + turnLeft(); + } else { + curveLeft(); + } lope_count++; break; case RIGHT: - curveRight(); + if(is_turn == 1) { + turnRight(); + } else { + curveRight(); + } lope_count++; break; }