0% found this document useful (0 votes)
226 views

Maze Solving Robot PDF

This document describes the theory and process for building a maze-solving robot. It explains that the robot uses a "left hand on the wall" algorithm to navigate the maze and find the end, storing its path as a series of moves (L, R, S, B). It then optimizes the path by substituting certain move combinations like LBL = S or LBS = R to eliminate unnecessary turns and dead ends. The goal is to optimize the initial path found to the shortest possible route through the maze. The document provides examples of applying this process to a sample maze to demonstrate how the robot solves and optimizes its path.

Uploaded by

monik
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
226 views

Maze Solving Robot PDF

This document describes the theory and process for building a maze-solving robot. It explains that the robot uses a "left hand on the wall" algorithm to navigate the maze and find the end, storing its path as a series of moves (L, R, S, B). It then optimizes the path by substituting certain move combinations like LBL = S or LBS = R to eliminate unnecessary turns and dead ends. The goal is to optimize the initial path found to the shortest possible route through the maze. The document provides examples of applying this process to a sample maze to demonstrate how the robot solves and optimizes its path.

Uploaded by

monik
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Food Living Outside Play Technology Workshop

Maze Solving Robot


by patrickmccb on July 2, 2011

Table of Contents

Maze Solving Robot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Intro: Maze Solving Robot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 1: The Theory Part 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Step 2: The Theory Part 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

Step 3: The Theory Part 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Step 4: The Theory Part 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

Step 5: The Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

Step 6: Attaching The Motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

Step 7: The Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

Step 8: The Motor Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

Step 9: The Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

Step 10: Attach The Top Deck . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

Step 11: Attach and Wire The Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

Step 12: Attach Power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

Step 13: The Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

http://www.instructables.com/id/Maze-Solving-Robot/
Intro: Maze Solving Robot

In this instructable I will be showing you how to build a maze solving robot. This is actually my 3rd attempt at making one. The first was a complete failure. The second
was alright at finding the end of the maze, but it could not go back and drive the quickest path. This is my current and 3rd one. It is able to find the end of the maze and
then, when put back at the start, drive the shortest path to the end of the maze without going down any dead ends. What surprises me is that it really does not mess up.

This was just a short introduction, everything else from theory, building, and programming will be explained in later steps.

Parts list:
2 Micro Gear Motors
Pair of Motor Brackets
Pair of Wheels
Ball Caster
Analog Reflectance Sensor Array
#2 Bolts and #2 Nuts
Arduino RBBB
Motor Driver IC
4AAA Battery Holder
4 Rechargeable AAA Batteries

General Parts:

3 1in Spacers (Home Depot)


Bolts and nuts that fit the spacers (Home Depot)
Hook up wire (I use 22 gauge)
Solder
.100" Female and Male headers
Velcro

Tools:

Soldering Iron
Philips Screw driver
Wire Strippers
Something to cut the wire with

http://www.instructables.com/id/Maze-Solving-Robot/
http://www.instructables.com/id/Maze-Solving-Robot/
Step 1: The Theory Part 1
What are the steps In maze solving?
There are basically 2 steps. The first is to drive through the maze and find the end of it. The second is to optimize that path so your robot can travel back through the
maze, but do it perfectly with out going down any dead ends.

How does the robot find the end of the maze?


I use a technique called the left hand on the wall. Imagine you are in a maze and you keep your left hand on a the edge of the wall at all times. Doing this would
eventually get you out of a non-looping maze. This instructable will only deal with mazes that do not loop back on themselves.

This left hand on wall algorithm can be simplified into these simple conditions:
- If you can turn left then go ahead and turn left,
- else if you can continue driving straight then drive straight,
- else if you can turn right then turn right.
- If you are at a dead end then turn around.

The robot has to make these decisions when at an intersection. An intersection is any point on the maze where you have the opportunity to turn. If the robot comes
across an opportunity to turn and does not turn then this is consider going straight. Each move taken at an intersection or when turning around has to be stored.

L = left turn
R= right turn
S= going straight past a turn
B= turning around

So let us apply this method to a simple maze and see if you can follow it. View the photos to see this method in action.
The red circle will be the robot.

As you can see in the photos for this example, the final path is LBLLBSR.

http://www.instructables.com/id/Maze-Solving-Robot/
http://www.instructables.com/id/Maze-Solving-Robot/
http://www.instructables.com/id/Maze-Solving-Robot/
Step 2: The Theory Part 2
Ok so now you have a path. In this case it is "LBLLBSR", but how does the robot change that into the correct path? Well lets take a look at what the correct path would
be. Look at the photos for the correct path.

Final correct path = SRR

So we need our path to go from LBLLBSR to the right path that is SRR. To start off we look at where we went wrong. A "B" indicates the robot turned around meaning it
went down the wrong path. To optimize the path we have to get rid of the "B" by using some substitution.

http://www.instructables.com/id/Maze-Solving-Robot/
http://www.instructables.com/id/Maze-Solving-Robot/
Step 3: The Theory Part 3
Lets look at the first 3 moves in the path "LBLLBSR". These moves are "LBL".
That move looks like the photo.

Instead of turning left then turning around and turning left again, the robot should have gone straight. So we can say that LBL = S.

This substitution is what the robot uses to optimize the path. That is one example but here is the whole list:

LBR = B
LBS = R
RBL = B
SBL = R
SBS = B
LBL = S

You may not come across all of these when maze solving, but they are required when optimizing the path. Some even put "B" back into the path. This is required to
further optimize the path correctly. You can figure out why for yourself or just trust me.

Lets optimize our path now that we know how to:


Path = LBLLBSR
LBL = S so our new path would be: SLBSR
We also know LBS = R so our new path would be: SRR
As you can see we got the path that we were looking for.

My robot optimizes the path as it travels. The path is stored in an array and every time it goes to store a new move, it checks to see if the previous move was a "B", if it
was then it optimizes the path. You need to know at least 3 moves to optimize the path: The move before and after the turn around (and the turn around itself).

http://www.instructables.com/id/Maze-Solving-Robot/
Step 4: The Theory Part 4
Here is another example.

Using the left hand on the wall algorithm, here is the path the robot would take:
LLLBLLLRBLLBSRSRS

Now here is the process of shortening that path:


LL(LBL = S)LL(RBL = B)(LBS = R)RSRS

The new path would be:


LLSLLBRRSRS

Continue shortening it until all the “B”s are gone:


LLSL(LBR = B)RSRS

The new path would be:


LLSLBRSRS

Continue shortening it:


LLS(LBR = B)SRS

The new path would be:


LLSBSRS

Continue shortening it:


LL(SBS = B)RS

The new path would be:


LLBRS

Continue shortening it:


http://www.instructables.com/id/Maze-Solving-Robot/
L(LBR = B)S

The new path would be:


LBS

The final path is:

LBS = R

Step 5: The Design


I first want to say that your robot does not have to built in the same manner mine is. The biggest thing I see is that I designed and laser cut a chassis for my robot. I will
post the AutoCAD file, but this is about all I can do. So if you are not able to laser cut the design, do not worry. As long as you have some Arduino, the same sensors, and
motors then you should be able to get my code to work on your robot with minor changes. Recently I was just helping some one online who made a copy of mine without
laser cut parts. The code ran on his robot with little tweaking.

You can see in the photos the design I made and the parts I used a laser cutter to make. The parts are made from acrylic that is .08" thick. This can be found at The
Home Depot.

In the third photo you can see the bottom deck in my 2 deck chassis design. The bottom deck has mounting holes in the rear to bolt the motors on, holes in the front to
bolt the ball caster on, a hole to bolt the Arduino on, and 2 tabs in the front where the sensor bolts onto. The bottom deck also has 3 mounting holes that allow it to be
connected to the top deck using bolts and spacers.

The top deck has a single, large hole to run wires from the battery pack that is velcroed on top to the electronics on the bottom deck. It also has 3 holes that allow it to be
connected to the bottom deck.

It is a simple, compact design that allows for a simple assembly with minimal wiring.

You will see in the next steps how and where the parts fit on.

Image Notes
1. Motor mount holes.
2. Motor mount holes
3. Holes for mounting the ball caster.
4. Hole for mounting the Arduino RBBB
5. Mounting holes for the analog sensor.

http://www.instructables.com/id/Maze-Solving-Robot/
File Downloads

maze_robot.dwg (55 KB)


[NOTE: When saving, if you see .tmp as the file ext, rename it to 'maze_robot.dwg']
Step 6: Attaching The Motors
In this step I simply attached my motors to the top side of the bottom deck using 2 #2 bolts for each one. You can see that I have a little bit of wire attached to each motor,
this is because the motors were removed from my previous maze robot. Then attach the wheels by simply pressing them onto the motor shaft. You have to line the "D"
shaped shaft up with hole in the center of the wheel.

http://www.instructables.com/id/Maze-Solving-Robot/
Image Notes Image Notes
1. Motors are bolted onto the holes of the bottom deck. 1. Underside view of the motors bolted on.

Step 7: The Arduino


The first thing you should do in this step is follow the instructions to assemble your RBBB. Those instructions are available here. You will need to snip part of the board off
like it says you can do at the bottom of the instructions because you will not be needing it. "If you dont’ need the power jack or regulator just snip them both off. The
easiest way to cut the board is with a large pair of tin snips, but hack saws, jewelers saws and band saws also work well." Do not solder any headers onto the board
besides the ones used for the FTDI programming port.

Next solder a 9 pin strip of female headers on the left side of the board from pins labeled "5v" to "A0". This will mate with the sensor plug later. Solder a 4 pin strip of
female headers on the right side of the board from pins labeled "D5" to "D8". These pins will be used to control the motor controller. Finally solder a 2 pin strip of female
headers on the front right of the board on the GND and 5V pins. These will supply power to the motor controller.

You can ignore the fact that the motor controller and top deck in the photos. We will get to those.

Image Notes
1. 4 digital pins that will control the motor controller.
2. GND and 5V plug that will supply power to the motor controller.
3. Connector that will mate with the one on the sensor. This will take analog
readings and supply power to the sensorl
4. The rest of the board was cut off.

http://www.instructables.com/id/Maze-Solving-Robot/
Step 8: The Motor Controller
I designed a PCB for my motor controller. I have uploaded the Eagle files for you. I used the Dorkbot service to have them made.

If you do not use a PCB, you can always make this simple circuit on some prototype board.

Now to wire the motor controller up. I have a labeled diagram in the photos. Looking at the last photo, I have the motor on the bottom of the picture connected to the what
I have labeled as "M1-A" and "M1-B". These are the outputs of the motor controller for the first motor. I have the motor in the top of the last photo connected to what I
have labeled as "M2-A" and "M2-B". These are the outputs of the motor controller for the second motor.

Now time for the inputs of the motor controller. The Arduino digital output 7 gets wired to what I have labeled as "In 1A". This is the first input of the first motor. The
Arduino digital output 6 gets wired to what I have labeled as "In 1B". This is the second input of the first motor. The Arduino digital output 5 gets wired to what I have
labeled as "In 2A". This is the first input of the second motor. The Arduino digital output 8 gets wired to what I have labeled as "In 2B". This is the second input of the
second motor.

Finally Power and ground get connected to the Arduino's 5v and Gnd pins at the front of the board. In the picture I have the wires attached but not plugged in yet.

As you can see I also went ahead and used some of the #2 nuts and bolts to bolt down the ball caster and Arduino.

http://www.instructables.com/id/Maze-Solving-Robot/
Image Notes
1. Ball caster bolted on.

http://www.instructables.com/id/Maze-Solving-Robot/
Image Notes
1. Arduino is bolted on.

File Downloads

Motor Controller 2.zip (12 KB)


[NOTE: When saving, if you see .tmp as the file ext, rename it to 'Motor Controller 2.zip']
Step 9: The Sensor
The sensor comes as an array of 8 sensors. There are 2 on the end that can be removed and need to be removed. I used a pair of side cutters to do this. A 9 pin strip of
female headers has to be soldered on to the sensor from "GND" to pin "6" of the sensor. I then plugged in a strip of male headers.

These sensors put out an analog voltage based on how much IR light is being reflected back. We can use these to detect the white and black areas on the maze. The
sensor outputs a low voltage near 0V if the sensor detects a white surface. The sensor outputs a voltage near VIN if it detects a dark surface.

Image Notes Image Notes


1. 2 of the sensors are cut off along the perforated line because they are not 1. Female header is soldered on and male pins are inserted.
needed.

Step 10: Attach The Top Deck


Bolt the top deck on using the 1in spacers and some bolts and nuts. Use velcro to attached the battery pack to the top deck. Run the leads from the battery pack through
the hole in the top deck to the bottom deck. This battery pack already has a built in power switch.

I found it easiest to leave the screw out of the battery pack. The screw prevents the battery pack from opening, but it has clips that do a good job of keeping it closed
without the screw. This allows the batteries to easily be changed by sliding the battery pack open. That means you do not necessarily have to lift the battery pack off the
velcro to change the batteries.

Image Notes
1. Battery pack is velcroed down.
2. The screw is left out for ease of changing batteries.
http://www.instructables.com/id/Maze-Solving-Robot/
Image Notes Image Notes
1. Power switch. 1. AAA 1800mAh 1.2v batteries
2. Power leads are fed through the hole to the bottom plate.

Step 11: Attach and Wire The Sensor


The sensor array bolts onto the front of the robot using #2 bolts. The pin on the far left of the sensor is GND and gets wired to GND on the Arduino. The second most left
pin is Vcc and it gets wired to the 5V pin on the Arduino. The pins labeled 6-1 on the analog sensor get wired to the Arduino analog pins from 5-0. So pin 6 on the sensor
gets wired to the Arduino analog pin 5, pin 5 of the sensor gets wired to the Arduino analog pin 4, etc.

Image Notes Image Notes


1. The sensor is bolted on to the front of the robot. 1. The sensor is connected to the Arduino.

http://www.instructables.com/id/Maze-Solving-Robot/
Step 12: Attach Power
The last thing to do is wire the battery pack to the Arduino. This is done by soldering the wires to the power pins at the rear of the Arduino RBBB. The battery pack has a
built in power switch so that is why we can simply solder the power leads straight to the back of the Arduino RBBB. The robot is now complete.

Image Notes
1. Power from the battery pack is connected to the back of the RBBB Arduino.

Step 13: The Program


I had fun writing this program. Basically there are a few functions that take care of the whole maze solving process. The left hand on the wall function holds the logic to
read the sensors and navigate the maze following those rules I outlined earlier. The turning functions are programmed in a fashion so that the robot continues to turn until
it sees the black line in which case it then drives forward. There is also a function programmed with a little line following capabilities. It is no PID line following, but does
allow the robot to stay on course. This function also controls the robot's speed.

The more detailed function is that of shortening the path. A letter is stored at every intersection that indicates the direction the robot took. If the previous letter was a "B",
indicating a wrong turn, the function that shortens the path is run to substitute letters in place of those 3 letter sequences outlined earlier.

Finally there is a function that replays the shortest path that the robot calculated when the robot is picked up and then placed back down on the black line. The robot can
detect when it is placed back down and then runs the shortest calculated path.

You can view the code here or of course download it on this page.

http://www.instructables.com/id/Maze-Solving-Robot/
File Downloads

Maze_Robot_V3.pde (11 KB)


[NOTE: When saving, if you see .tmp as the file ext, rename it to 'Maze_Robot_V3.pde']

Related Instructables

Simplest Ariadne - a 1st Arduinik, The DIY Android


Possible person maze on Humanoid/Biped Servo Ball Maze - An
Microcontroller- a 16x2 LCD by Robot! (Photos) Controlled Marble Disorder Introduction to
Based Maze- by simonfrfr Marble Maze by - a marble maze the Android
thedod
Solving Robot CarlS simulator with ADK by pcdevltd
(video) by tilt switches by
mikhalchuk thedod

Comments
13 comments Add Comment

BeFit says: Jul 26, 2011. 12:11 AM REPLY


Great work!

jobard says: Jul 22, 2011. 10:58 AM REPLY


What happens if after the first recognizing run, you place it in a different start location?

patrickmccb says: Jul 22, 2011. 11:20 AM REPLY


It would not work properly. It is meant to solve it from the same starting position. It has to be reset if you want it to solve it from another.

blinkyblinky says: Jul 21, 2011. 7:10 PM REPLY


Nice. How do you reset it if you want it to go the long way agaibn AFTER it has calculated the shortest path.? Nice, though.

patrickmccb says: Jul 21, 2011. 7:15 PM REPLY


Hit the reset button on the Arduino or turn it off and on again.

kimvellore says: Jul 14, 2011. 3:29 PM REPLY


Nice concept. Thank you for explaining in detail. I enjoyed reading it.

http://www.instructables.com/id/Maze-Solving-Robot/
hyruler_ says: Jul 6, 2011. 2:23 PM REPLY
that is awesome

maximeke2 says: Jul 6, 2011. 11:36 AM REPLY


Can you please give me some information about your sensor? Does it use LEDs or infrared, and also the type/datasheet of emitter/transmitter?

patrickmccb says: Jul 6, 2011. 11:38 AM REPLY


On the first page of the instructable I provided the links to all of the different parts, including this one. Here is the link where you can find more information
about it http://www.pololu.com/catalog/product/960

maximeke2 says: Jul 6, 2011. 12:15 PM REPLY


oops... I was just looking for the sensor and didn't read it. Sorry about that

error32 says: Jul 4, 2011. 11:00 AM REPLY


I have used some parts from the pololu store before. Very good quality!
Though i personally liked it better to make my own PIC based board instead of the too easy arduino solution.

SHIFT! says: Jul 3, 2011. 9:47 PM REPLY


This is a great 'ible, but you forgot the most crucial thing- The Title! Please name this project soon!

patrickmccb says: Jul 3, 2011. 11:26 PM REPLY


Thanks for the heads up. I thought I named it...

http://www.instructables.com/id/Maze-Solving-Robot/

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy