270 likes | 499 Views
Maze Running Robots. EGR106 Project Spring 2004. Computer control (through a Matlab program) of a Lego robot to:. Explore a maze (start to end) Recognize the final room to drop cargo Return the robot to its starting place. Project Goal.
E N D
Maze Running Robots EGR106 Project Spring 2004
Computer control (through a Matlab program) of a Lego robot to: Explore a maze (start to end) Recognize the final room to drop cargo Return the robot to its starting place Project Goal
You will not be assembling the robot, but controlling it • Basic control will be through a Matlab function Typical robot circa 2002
Maze Assumptions • Size is known • Start is at the lower left corner, robot pointing up/north • Drop site for the cargo is at the upper right corner
The Robot Interface MATLAB function robot.m: [l,c,r] = robot(command) • one input value • three binary outputs
Value for command (plus the robot always looks around): 0 drive forward one unit (room) 1 turn left by 90o 2 turn right by 90o 3 do nothing (just look around) 4 play a sound (drop the cargo) ≥ 10 initialize and run the simulator
Three binary output variables: • Returned for all commands • Denote the presence or absence of wall openings from the current room/orientation • Left, Center, Right walls only • Value = 1 for opening present, 0 for no opening • Note – result is dependent upon the orientation of the robot.
Output is [ L, C, R ] = [ 1 0 0 ] Output is [ L, C, R ] = [ 1 1 0 ]
Robot Simulator • Useful for program development • Virtual robot, much faster than the real thing • Available 24/7 (download file) • Includes multiple practice mazes to test your programs – maze and robot progress shown in a figure window
Programming Notes 4 parts: • Search/wander the maze • Build a map of what you see • Drop the cargo; analyze the map • Return to start
Search/wander the maze • Make good moves – remember that the goal is to get to the upper right corner; don’t just make random turns, aim the robot • Keep track of the robot location – row and column notation makes it easy to recognize the end room • Orientation determines where the robot goes
Build a map of what you see • At the beginning you know nothing of the maze; for each new room visited, you learn a bit more • Use the map to help the exploration (i.e. recognize areas/directions to be ignored, don’t revisit rooms, …) • One idea on mapping is …..
A map “matrix” for a M by N maze: • Number the rooms 1 to M*N • The (m,n) and (n,m) entries (identical) describe the connection between rooms m and n using 3 values: • connection unknown • no direct connection • a direct connection
Example Map Legend: white = not adjacent red = closed wall green = open wall
Drop the cargo; analyze the map • Identify the end room by beeping • Use the map matrix to find a short path back to start • While many ideas could be tried, one simple analysis tool is Bellman’s flooding algorithm…..
Bellman’s flooding algorithm: • Start analysis at the “end” room • Assign costs to each room of going from that room to the end • Sequentially expand to connected adjacent rooms • Stop when you hit “start”
Path identified by tracing from “start” to “end” following decreasing costs • Result: room path 1, 2, 6, 10, 11, 7, 8, 12 forward
Return to start • Convert reverse path to robot commands 12, 8, 7, 11, 10, 6, 2, 1 reverse
12 8 7 11 10 6 2 1 robot(1) robot(1) robot(0) robot(2) robot(0) robot(2) robot(0) robot(1) robot(0) robot(1) robot(0) robot(0) robot(2) robot(0)
Team Deliverables • Working program(s): • electronic copy for testing • written description (with examples) • Written report: • details of format later • Oral Presentation to class: • each person describes an aspect of the work • Due May 4 (final class day)
Scoring in the Demonstration • Sum of two parts (a lower score is better): • 1 point per forward movement while searching • 2 points per forward movement while returning • Must: • Drop the cargo in the “end” room • Return to “start” • Not cross walls
Schedule • Today: • meet your team (Preassigned) • brainstorm issues and ideas, ask questions • Homework (due this Thursday): • team name
Schedule (continued) • April 15, 20, 22, 27 & 29 • in-class work time • Quiz 3 on the 20th • weekly reviews with me (5 minute schedule per team) • May 4: • Presentations including maze running demos