Difference between revisions of "Tutorials/Arduino Projects/Mobile Robotics/BoeBot/Navigating Simple Maze"

From ROBOTC API Guide
Jump to: navigation, search
(Created page with "{{DISPLAYTITLE:Navigating a simple maze}} <yambe:breadcrumb>Arduino_Projects|Arduino Tutorials and Guided Projects</yambe:breadcrumb> {{tl|1|}} == objective == Now that we hav...")
 
(The Plan)
Line 10: Line 10:
 
The first step in programing a robot to follow a path is to plan the path the robot will take to navigate the maze. Since this maze has just one path, the planing has already been done. The path the robot will take is
 
The first step in programing a robot to follow a path is to plan the path the robot will take to navigate the maze. Since this maze has just one path, the planing has already been done. The path the robot will take is
  
[[image:Simple_Maze_Diagram_BoeBot_Path.png|thumb|c|center|400px]]
+
[[image:Simple_Maze_Diagram_BoeBot_Path.png|thumb|c|center|400px|simple maze drawing]]
  
 
However to follow this path we will need to find out how long it takes for the robot to turn 90° to the left and right at speed 15, and how long it takes the robot to travel 1 in. at speed 15. Getting the time to travel 1 in. is the simplest so we will start with that, then move on to finding the time to make the turns.
 
However to follow this path we will need to find out how long it takes for the robot to turn 90° to the left and right at speed 15, and how long it takes the robot to travel 1 in. at speed 15. Getting the time to travel 1 in. is the simplest so we will start with that, then move on to finding the time to make the turns.

Revision as of 14:37, 18 June 2012

ArduinoArduino Tutorials and Guided Projects → Tutorials/Arduino Projects/Mobile Robotics/BoeBot/Navigating Simple Maze

objective

Now that we have a grasp of how to make the robot move, we can use that understanding to complete a task. For this section we are going to make the robot navigate a very simple maze. Even though we are calling it a maze, we will be telling the robot exactly where to go so you don't need to worry about how to make the robot know where to go.

Layout of the maze we will be traversing

The Plan

The first step in programing a robot to follow a path is to plan the path the robot will take to navigate the maze. Since this maze has just one path, the planing has already been done. The path the robot will take is

simple maze drawing

However to follow this path we will need to find out how long it takes for the robot to turn 90° to the left and right at speed 15, and how long it takes the robot to travel 1 in. at speed 15. Getting the time to travel 1 in. is the simplest so we will start with that, then move on to finding the time to make the turns.

Distance Traveled vs Time

Since we are looking for the seconds per inch, we are just looking for the inverse of inches per second. In either case to find the relationship, you need to know the distance traveled and the time to travel of at least one sample to calculate the relationship. Since we already know that we can control the time that the robot will run for, it is a very simple matter to just program it drive for 10 seconds, then just measure the distance traveled. You can either write your own program to drive straight forward at speed 15 for 10 seconds or you can use the following code.

insert the 10 second drive code here

Now download the program to the robot and set it up so that the point where the wheel touches the driving surface is next to a yard/meter stick. now just turn it on, wait for the robot to stop and record the distance traveled. We recommend that you do this 2 more times to get an average value.

setup to measure the distance traveled

If you take the average distance traveled and divide by the time (10 seconds) and you will get the distance per second. This can be useful if you know how long your have been traveling, however we want to find how long we need to travel to go some distance. To find this relationship, we take the time (10 seconds) and divide it by the number of inches traveled.

Now that we have this ratio, we can take some distance, say 9 inches, and calculate the time needed to travel that distance by multiplying the desired distance by the ratio.

Adjusting Turning Time

While the process of calculating the time for driving straight for some distance is fairly simple, the physics involved with turning make it a little more complicated. Since we only need to make 90° turns, we will just create a program to make a left point turn and adjust he timing until the turn is sufficiently close to 90°. then we just repeat the process for a right point turn. From our testing, the following code should get you close to an 90° turn.