Unformatted text preview:

6.081, Spring Semester, 2007—Work for Lucky Week 13 1MASSACHVSETTS INSTITVTE OF TECHNOLOGYDepartment of Electrical Engineering and Computer Science6.081—Introduction to EECS ISpring Semester, 2007Work for Lucky Week 13• Software lab for Tuesday, May 8• No pre-lab or tutor problems this week• Robot lab for Thursday, May 10• No Post-lab problemsRobot localizationIn SimulationDownload the file ps13-code.zip. It should have the following files:• AvoidWanderTB.py• GridMap.py• GridStateEstimator.py• KBest.py• Map.py• search.py• Sequence.py• utilities.py• WanderEstBrain.py• WriteIdealReadings.py• XYDriver.py• XYEstBrain.py• XYGridPlanner.pyEdit WanderEstBrain.py so that the variable dataDirectory is defined to be whateverpath you unpacked the code file into.Now, start up SoaR in simulation, using the She world, and use WanderEstBrain.py as the brain.When it starts up, you’ll see two new windows.The first window, labeled Belief, shows the outline of the obstacles in the world, and a grid ofcolored squares. Squares that are colored black represent locations that cannot be occupied by therobot. For the purposes of this window, for each (x, y) location, we find the θ∗value that is mostlikely, and then draw a color that’s related to the probability that the robot is at pose (x, y, θ∗).The colors go in order from more to less likely: yellow, red, blue, gray. At the absolutely mostlikely pose, the robot is drawn, with a nose, in green.The second window, labeled P(O|S), shows, each time a sonar observation o is received,maxθPr(o|x, y, θ) ,for each square x, y. That is, it draws a color, as above, that shows how likely the current observationwas in each square, using the most likely possible orientation. Note, though, that the values drawn6.081, Spring Semester, 2007—Work for Lucky Week 13 2in this window aren’t normalized (they don’t sum to 1); we’ve scaled the colors to make them sortof similar to the colors in the belief window, but they aren’t directly comparable.The brain WanderEstBrain.py just uses our standard avoid and wander program (from week 2!),but keeps the robot’s belief state about its pose updated as it does so.Run the simulation. Watch the colored boxes, and be sure they make sense to you. Try “kidnap-ping” the robot (dragging the simulated robot in the window) and see how well the belief statetracks the change. We recommend clicking the SoaR stop button, then dragging the robot, thenclicking the run button. It makes it less likely that the robot will get stuck in some random placealong the way.Question 1. Explain the relationship between the two windows, and why they often start outsimilar and diverge over time.Question 2. Why is it that, when you put the robot in a corner, all of the corners have highvalues in the P(o|s) window?Question 3. What happens when the robot is kidnapped?Checkpoint: Tuesday 4:00 PM• Find a staff member, and explain your answers to the previous set of questions.The CodeHere is much of the code from WanderEstBrain.py, with an explanation of what’s going on. It issimilar, in high-level structure, to the planner brains we used before.We start by telling this program where to look for its data files. You can do that by editing thedataDirectory line. The file maxRange2.465/she20.dat contains the ideal sensor readings atevery x, y, θ pose on a 20 × 20 × 20 grid, assuming that the walls of the She World in the simulatorare fixed. It takes a long time to compute them, so it’s better to do it off-line, and then just lookthem up when we’re running the state update routine.dataDirectory = " yourPathNameHere / ps13code / maxRan ge2 .465/ "Next, we make an instance of the GridStateEstimator class, first specifying the size of the world,and then calling the initializer.def setup ():( xmin , xmax , ymin , ymax ) = (0.0 , 4.0 , 0.0 , 4.0)m = GridStateEs t i m a t or ( Map ( sh eBoxes ), xmin , xmax , ymin , ymax , 20 ,\dataDi r e c t o r y + " she20 . dat " ,numB e s t P o ses = 5)Now, we make two windows, one for displaying the belief state and one for displaying the perceptionprobabilities. To display a belief state, we start by finding, for each grid value of x and y, the valueof θ so that P(x, y, θ) is maximized. What does this mean? It’s the orientation that would be mostlikely for the robot, if it were in that location. Now, we take all those values and draw the squareswith the highest values in yellow, next highest in red, next highest in blue, and least high in gray.We also show the most likely pose (both the location and orientation) in green.6.081, Spring Semester, 2007—Work for Lucky Week 13 3( xrange , yrange ) = ( xmax - xmin , ymax - ymin )( wxmin , wxmax , wymin , wymax ) = ( xmin - 0.05* xrange , xmax + 0.05* xrange ,ymin - 0.05* yrange , ymax +0.05* yrange )beli e f W i n dow = DrawingWindow (300 , 300 , wxmin , wxmax , wymin , wymax , \" Belie f " )pe r c Window = D r a w i ngWindow (300 , 300 , wxmin , wxmax , wymin , wymax ,"P ( O | S)" )m. drawBeli e f ( beliefWindo w )m. initPose ( pose ())In all the previous labs, when we issued a motor command to the robot, it would continue movingwith those velocities until it got the next command. In this lab, we’re going to do it differently,because doing belief state update can sometimes take a long time to compute, and if we go for along time without giving the robot a new command, it could run into the wall before we have achance to give it a stop command. So, this time we are going to run the robot in discrete motormode, where it moves for a tenth of a second at the commanded velocities and then stops until itgets another command.def discreteMotor ( trans , rot ):discreteMo t o r O u tput ( trans , rot , 0.1)Because the belief update is so expensive, we don’t want to do it on every primitive step. But we’regoing to need to make a function that can be executed on every primitive step. So, here, we definea function makeBeliefUpdateEveryN that takes n as an argument, allocates a counter that willkeep track of how long it has been since the last update. Then, we return a function that refers tothat counter: it checks to see whether it has been n steps since the last update. If so, it resets thecounter and updates the belief state based on the current sonar readings and the current pose andredraws the windows.Why are we handing the current pose into the belief state update, when the robot doesn’t reallyknow where it


View Full Document

MIT 6 01 - Study Notes

Documents in this Course
Week 1

Week 1

3 pages

Op-Amps

Op-Amps

8 pages

Op-Amps

Op-Amps

6 pages

Syllabus

Syllabus

14 pages

Planning

Planning

14 pages

Load more
Download Study Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Study Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Study Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?