2 #include <mrm-action.h>
5 enum Direction{UP, LEFT, DOWN, RIGHT, NOWHERE};
6 enum LedSign { MAZE_IMU_FOLLOW, MAZE_LED_PAUSE, MAZE_LED_PLAY, MAZE_WALL_DOWN_FOLLOW, MAZE_WALL_LEFT_FOLLOW, MAZE_WALL_RIGHT_FOLLOW, MAZE_WALL_UP_FOLLOW };
7 enum WallStatus{ NO_WALL, WALL_UNKNOWN, WALL_WITH_VICTIM, WALL_WITHOUT_VICTIM};
8 enum TileSurvace{ SURFACE_BLACK, SURFACE_SILVER, SURFACE_UNKNOWN, SURFACE_WHITE};
31 Tile(int8_t x, int8_t y, Direction breadcrumb);
42 WallStatus
wallGet(Direction direction) {
return (WallStatus)((_wall >> (direction * 2)) & 0b11); }
48 void wallSet(Direction direction, WallStatus wallStatus) { _wall &= ~(0b11 << (direction * 2)); _wall |= (wallStatus << (direction * 2)); }
67 const uint16_t IMU_FOLLOW_STRENGTH = 5;
68 const uint16_t MAZE_MAX_STEPS = 0xFFFF;
69 const uint16_t MOVE_AHEAD_TIMEOUT_MS = 1300;
70 const uint16_t NO_WALL_DISTANCE = 250;
71 const uint8_t TOP_SPEED = 127;
72 const uint16_t WALL_FOLLOW_DISTANCE = 90;
73 const uint16_t WALL_FOLLOW_ERROR_ALLOWED = 40;
74 const uint16_t WALL_FOLLOW_DISTANCE_ADJUSTMENT_STRENGTH = 1.1;
75 const uint16_t WALL_FOLLOW_ROTATION_STRENGTH = 1.1;
87 Direction directionCurrent;
89 float imuLastValid = 9999;
101 RobotMaze(
char name[] = (
char*)
"RCJ Maze");
118 uint16_t
distance(Direction direction,
bool firstCCW) {
return mrm_lid_can_b->
reading(2 * mToR(direction) + firstCCW); }
161 Direction mToR(Direction directionAsSeenInMaze) { int8_t d = directionAsSeenInMaze - directionCurrent;
return (Direction) (d < 0 ? d + 4 : d); }
175 Direction rToM(Direction directionAsSeenByRobot) {
return (Direction)(directionCurrent + directionAsSeenByRobot % 4); }
204 WallStatus
wallGet(int8_t
x, int8_t
y, Direction direction);
210 void wallDisplay(WallStatus wallStatus, Direction direction);
220 int8_t
x(Direction direction);
226 int8_t
y(Direction direction);
255 void perform() { ((
RobotMaze*)_robot)->decide(); }
263 void perform() { ((
RobotMaze*)_robot)->map(); }
271 void perform() { ((
RobotMaze*)_robot)->move(); }
281 void perform() { ((
RobotMaze*)_robot)->moveAhead(); }
289 void perform() { ((
RobotMaze*)_robot)->moveTurn(); }
299 void perform() { ((
RobotMaze*)_robot)->rescueMaze(); }
307 void perform() { ((
RobotMaze*)_robot)->omniWheelsTest(); }
315 void perform() { ((
RobotMaze*)_robot)->wallsTest(); }
Definition: mrm-action.h:7
ActionBase(Robot *robot, const char shortcut[4], const char text[20], uint8_t menuLevel=1, BoardId boardsId=ID_ANY)
Definition: mrm-action.cpp:23
Definition: mrm-robot-maze.h:254
Definition: mrm-robot-maze.h:262
Definition: mrm-robot-maze.h:280
Definition: mrm-robot-maze.h:270
Definition: mrm-robot-maze.h:288
Definition: mrm-robot-maze.h:306
Definition: mrm-robot-maze.h:298
Definition: mrm-robot-maze.h:314
Definition: mrm-board.h:403
uint16_t reading(uint8_t deviceNumber=0)
Definition: mrm-lid-can-b.cpp:157
Definition: mrm-robot.h:42
Definition: mrm-robot-maze.h:65
void wallFollow(Direction wallDirection)
Definition: mrm-robot-maze.cpp:510
void omniWheelsTest()
Definition: mrm-robot-maze.cpp:407
void move()
Definition: mrm-robot-maze.cpp:309
void map()
Definition: mrm-robot-maze.cpp:235
int8_t y(Direction direction)
Definition: mrm-robot-maze.cpp:676
WallStatus wallGet(int8_t x, int8_t y, Direction direction)
Definition: mrm-robot-maze.cpp:556
int8_t x(Direction direction)
Definition: mrm-robot-maze.cpp:662
void decide()
Definition: mrm-robot-maze.cpp:145
void mazePrint()
Definition: mrm-robot-maze.cpp:256
void rescueMaze()
Definition: mrm-robot-maze.cpp:455
void loop()
Definition: mrm-robot-maze.cpp:222
uint16_t distance(Direction direction, bool firstCCW)
Definition: mrm-robot-maze.h:118
RobotMaze(char name[]=(char *)"RCJ Maze")
Definition: mrm-robot-maze.cpp:16
void directionDisplay(Direction direction)
Definition: mrm-robot-maze.cpp:191
void wallDisplay(WallStatus wallStatus, Direction direction)
Definition: mrm-robot-maze.cpp:567
void wallsDisplay()
Definition: mrm-robot-maze.cpp:595
Direction wallClosest()
Definition: mrm-robot-maze.cpp:487
void bitmapsSet()
Definition: mrm-robot-maze.cpp:54
void goAhead()
Definition: mrm-robot-maze.h:127
void moveAhead()
Definition: mrm-robot-maze.cpp:336
void moveTurn()
Definition: mrm-robot-maze.cpp:380
void imuFollow()
Definition: mrm-robot-maze.cpp:213
void wallsTest()
Definition: mrm-robot-maze.cpp:638
Tile * tileContaining(int8_t x, int8_t y)
Definition: mrm-robot-maze.cpp:477
Definition: mrm-robot-maze.h:13
WallStatus wallGet(Direction direction)
Definition: mrm-robot-maze.h:42
Tile * next()
Definition: mrm-robot-maze.h:36
void wallSet(Direction direction, WallStatus wallStatus)
Definition: mrm-robot-maze.h:48
Tile(int8_t x, int8_t y, Direction breadcrumb)
Definition: mrm-robot-maze.cpp:691