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:
- 53:4673b85e1d2a
- Parent:
- 36:e1398ff45b12
- Child:
- 57:30cd20c654d1
--- a/moves/moves.cpp Mon May 20 04:26:15 2019 +0000 +++ b/moves/moves.cpp Mon May 20 10:27:02 2019 +0000 @@ -76,6 +76,42 @@ else if(degree0 - target_degree > tolerance_degree) curveRight(); else straight(); } +void lopeAndInfinity(float target_degree, float tolerance_degree) +{ + enum Mode { + STRAIGHT, + LEFT, + RIGHT, + }; + static int lope_count = 0; + const int max_count = 3; + Mode mode; + if(target_degree - degree0 > tolerance_degree) { + mode = LEFT; + } else if(degree0 - target_degree > tolerance_degree) { + mode = RIGHT; + } else { + mode = STRAIGHT; + } + //カーブしすぎたら強制的に直進 + if(lope_count >= max_count) { + mode = STRAIGHT; + } + switch(mode) { + case STRAIGHT: + straight(); + lope_count=0; + break; + case LEFT: + curveLeft(); + lope_count++; + break; + case RIGHT: + curveRight(); + lope_count++; + break; + } +} void climbAndInfinity(float target_degree, float tolerance_degree) { if(target_degree - degree0 > tolerance_degree) {//左に曲がる