7 ev3_speaker_set_volume ( 5 ) ;
12 ev3_speaker_play_tone ( NOTE_FS6, 100 ) ;
14 while ( traceDistance < 1860 ) {
29 void PuzzleField::runPuzzleField ( int8_t currentPosition, int8_t beforePosition, int8_t nextPosition ) {
30 runPuzzleFieldVectorChange ( currentPosition, beforePosition, nextPosition, 0 ) ;
33 void PuzzleField::avoidBlock ( int8_t currentPosition, int8_t beforePosition, int8_t nextPosition ) {
34 basicWalker.
backStraight ( 40, allconnectNumber[currentPosition][connectNumberManager[currentPosition][beforePosition]][
DISTANCE] ) ;
35 runPuzzleFieldVectorChange ( currentPosition, beforePosition, nextPosition, 180 ) ;
36 ev3_speaker_play_tone ( NOTE_FS6, 75 ) ;
38 ev3_speaker_play_tone ( NOTE_FS6, 75 ) ;
40 ev3_speaker_play_tone ( NOTE_FS6, 75 ) ;
43 void PuzzleField::runPuzzleFieldVectorChange ( int8_t currentPosition, int8_t beforePosition, int8_t nextPosition, int32_t vectorStatus )
47 connectNumber = connectNumberManager[currentPosition][nextPosition] ;
49 if ( beforePosition ==
X ) {
52 beforeconnectNumber = connectNumberManager[beforePosition][currentPosition] ;
53 currentDegree = allconnectNumber[beforePosition][beforeconnectNumber][
DEGREE] - vectorStatus ;
54 if ( vectorStatus == 180 && currentDegree < -180 ) {
55 currentDegree += 360 ;
58 nextDegree = allconnectNumber[currentPosition][connectNumber][
DEGREE] ;
59 spinDegree = nextDegree - currentDegree ;
60 if ( spinDegree < 0 ) {
63 sprintf ( msg,
"Spin Vector:SPIN_RIGHT" ) ;
65 }
else if ( 180 < spinDegree ) {
69 sprintf ( msg,
"Spin Vector:SPIN_RIGHT" ) ;
73 sprintf ( msg,
"Spin Vector:SPIN_LEFT " ) ;
77 nextDistance = allconnectNumber[currentPosition][connectNumber][
DISTANCE] ;
79 sprintf ( msg,
"Degree>Current:%ld,Next:%ld", currentDegree, nextDegree ) ;
81 sprintf ( msg,
" Spin:%ld", spinDegree ) ;
83 sprintf ( msg,
"Position>Current:%d->Next:%d", currentPosition, nextPosition ) ;
85 sprintf ( msg,
"Distance>Next:%ld", nextDistance ) ;
88 ev3_speaker_play_tone ( NOTE_FS5, 100 ) ;
89 basicWalker.
spin ( 16, spinVector, spinDegree ) ;
92 ev3_speaker_play_tone ( NOTE_FS6, 100 ) ;
94 if ( connectNumber < 4 && nextPosition != 0 ) {
111 ev3_speaker_play_tone ( NOTE_FS6, 100 ) ;
123 walker.
run ( 0, 0 ) ;
130 ev3_speaker_play_tone ( NOTE_FS5, 100 ) ;
135 runPuzzleField ( 10,
X, 1 ) ;
136 runPuzzleField ( 1, 10, 5 ) ;
137 runPuzzleField ( 5, 1, 8 ) ;
138 runPuzzleField ( 8, 5, 6 ) ;
139 runPuzzleField ( 6, 8, 0 ) ;
140 avoidBlock ( 6, 0, 9 ) ;
141 runPuzzleField ( 9, 6, 14 ) ;
142 runPuzzleField ( 14, 9, 0 ) ;
143 avoidBlock ( 14, 0, 8 ) ;
144 runPuzzleField ( 8, 14, 2 ) ;
145 runPuzzleField ( 2, 8, 3 ) ;
146 runPuzzleField ( 3, 2, 9 ) ;
147 runPuzzleField ( 9, 3, 15 ) ;
148 runPuzzleField ( 15, 9, 11 ) ;
void isLeftsideLine(bool b)
void resetDistance(int32_t countL, int32_t countR)
void backStraight(int32_t, int32_t)
void runLine(int32_t countL, int32_t countR, int8_t light_value)
void setPid(double _p_gain, double _i_gain, double _d_gain, double _target)
void msg_f(const char *str, int32_t line)
std::int32_t getDistanceTotal(std::int32_t countL, std::int32_t countR)
void spin(int32_t, bool, int32_t)
int8_t getBrightness(void) const
void preparatePuzzle(void)
colorid_t getColorNumber(void) const
void goStraight(int32_t, int32_t)
void run(int8_t pwm, int8_t turn)
SpeedControl speedControl