Maze-Solving Mindstorms NXT Robot - PowerPoint PPT Presentation

maze solving mindstorms nxt robot l.
Skip this Video
Loading SlideShow in 5 Seconds..
Maze-Solving Mindstorms NXT Robot PowerPoint Presentation
Download Presentation
Maze-Solving Mindstorms NXT Robot

play fullscreen
1 / 63
Maze-Solving Mindstorms NXT Robot
Download Presentation
Download Presentation

Maze-Solving Mindstorms NXT Robot

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Maze-Solving Mindstorms NXT Robot

  2. Our Mission • Investigate the capabilities of the NXT robot • Explore development options • Build something interesting!

  3. Problem Outline • Robot is placed in a “grid” of same-sized squares • (Due to obscure and annoying technical limitations, the robot always starts at the “southwest” corner of the maze, facing “north”) • Each square can be blocked on 0-4 sides (we just used note cards!) • Maze is rectangularly bounded • One square is a “goal” square (we indicate this by covering the floor of the goal square in white note cards ) • The robot has to get to the goal square

  4. Robot Design • Uses basic “driving base” from NXT building guide, plus two light sensors (pointed downwards) and one ultrasonic distance sensor (pointed forwards) • The light sensors are used to detect the goal square, and the distance sensor is used to detect walls

  5. Robot Design, cont’d Ultrasonic Sensor LightSensors

  6. Robot Design, cont’d

  7. Search Algorithm • Simple Depth-First Search • Robot scans each cell for walls and constructs a DFS tree rooted at the START cell • As the DFS tree is constructed, it indicates which cells have been explored and provides paths for backtracking • The DFS halts when the GOAL cell is found

  8. Maze Structure

  9. DFS Tree Example

  10. DFS Tree Data Structure • Two-Dimensional Array Cell maze[MAX_HEIGHT][MAX_WIDTH] typedef struct { bool isExplored; (= false) Direction parentDirection; (= NO_DIRECTION) WallStatus[4] wallStatus; (= {UNKNOWN}) } Cell; • Actually implemented as parallel arrays due to RobotC limitations

  11. DFS Algorithm while (true) { if robot is at GOAL cell victoryDance(); if there is an unexplored, unobstructed neighbor Mark parent of neighbor as current cell; Proceed to the neighbor; else if robot is not in START cell Backtrack; else return; //No GOAL cell exists, so we exit }

  12. Example 3x3 maze GOAL

  13. We start out at (0,0) – the “southwest” corner of the maze • Location of goal is unknown

  14. Check for a wall – the way forward is blocked

  15. So we turn right

  16. Check for a wall – no wall in front of us

  17. So we go forward; the red arrow indicates that (0,0) is (1,0)’s predecessor.

  18. We sense a wall

  19. Turn right

  20. We sense a wall here too, so we’re gonna have to look north.

  21. Turn left…

  22. Turn left again; now we’re facing north

  23. The way forward is clear…

  24. …so we go forward. • “When you come to a fork in the road, take it.”–Yogi Berra on depth-first search

  25. We sense a wall – can’t go forward…

  26. …so we’ll turn right.

  27. This way is clear…

  28. …so we go forward.

  29. Blocked.

  30. How about this way?

  31. Clear!

  32. Whoops, wall here.

  33. We already know that the wall on the right is blocked, so we try turning left instead.

  34. Wall here too! • Now there are no unexplored neighboring squares that we can get to. • So, we backtrack! (Retrace the red arrow)

  35. We turn to face the red arrow…

  36. …and go forward. • Now we’ve backtracked to a square that might have an unexplored neighbor. Let’s check!

  37. Ah-ha!

  38. Onward!

  39. Drat!

  40. There’s gotta be a way out of here…

  41. Not this way!

  42. Two 90-degree turns to face west…

  43. Two 90-degree turns to face west…

  44. No wall here!

  45. So we move forward and…

  46. What luck! Here’s the goal. • Final step: Execute victory dance. 

  47. Movement and Sensing • The search algorithm above requires five basic movement/sensing operations: • “Move forward” to the square we’re facing • “Turn left” 90 degrees • “Turn right” 90 degrees • “Sense wall” in front of us • “Sense goal” in the current square

  48. Movement and Sensing, cont’d • Sensing turns out not to be such a big problem • If the ultrasonic sensor returns less than a certain distance, there’s a wall in front of us; otherwise there’s not • Goal sensing is similar (if the floor is “bright enough”, we’re at the goal)

  49. Movement and Sensing, cont’d • The motion operations are a major challenge, however • Imagine trying to drive a car, straight ahead, exactly ten feet, with your eyes closed. That’s more or less what “move forward” is supposed to do – at least ideally. • In the current implementation, we just make our best estimate by turning the wheels a certain fixed number of degrees, and make no attempt to correct for error. • We’ll talk about other options later