Docsity

Maze Solving with NXT Robot: A Depth-First Search Algorithm, Slides of Robotics

Partial preview of the text

Download Maze Solving with NXT Robot: A Depth-First Search Algorithm and more Slides Robotics in PDF only on Docsity!

Maze-Solving Mindstorms NXT

Robot

Our Mission

• Investigate the capabilities of the NXT robot

• Explore development options

• Build something interesting!

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

Robot Design, cont’d

Light Sensors

Ultrasonic Sensor

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

Maze Structure

GOAL

START

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

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 }

  • We start out at (0,0) – the “southwest” corner of the maze
  • Location of goal is unknown
  • Check for a wall – the way forward is blocked
  • Check for a wall – no wall in front of us
  • So we go forward; the red arrow indicates that (0,0) is (1,0)’s predecessor.
  • Turn right
  • We sense a wall here too, so we’re gonna have to look north.