MATLAB实现Bug1算法
HW 1 – Bugs running around
Due: 2019.09.11 End of day
G. Fainekos – Intro to Robotics – Fall 2019
For this homework problem, you will implement the Bug1 algorithm. You may use as a starting point the Bug2 algorithm posted on Canvas.
Recommended readings:
1. Lecture slides on Bug1 and Bug2 algorithms (detailed pseudocode provided)
2. Recommended textbook readings within slides
Files and templates provided
The following files are provided:
1. Bug1.m:thetemplatetoenteryoursolution
a. Do not change the function interface
b. Do not forget to write the name
2. hw1_maps.mat:3samplemapenvironmentstotestyourcode
3. run_bug1_hw.m:ascriptthatloadsthemapsandrunsBug1
4. edgelist.m:returnstheboundaryofanobstacle.Thisfunctionisdistributedwiththe
Robotics Toolbox for Matlab. You must not modify this function.
5. homline.m:describesalineinhomogeneousformgiven2points.Thisfunctionisdistributed
with the Robotics Toolbox for Matlab. You must not modify this function.
Notes
Run the script “run_bug1_hw.m” to load the sample map environments and execute Bug1. The current implementation of Bug1 just moves straight to the goal, i.e., the bug is so strong that can go through obstacles! See below if you do not believe me!
Use the debugging functionality to reverse engineer Bug2 and use code excerpts to implement Bug1.
The instruction
boundary = edgelist(occupancyMatrix(map)’, world2grid(map,curPos))
in Bug2 returns all the points on the boundary of the obstacle. You will have to use this list of points to circumvent an obstacle.
Do not forget to translate between world coordinates and occupancy array values using the grid2world andoccupancyMatrix methodsofrobotics.BinaryOccupancyGrid.Type
help robotics.BinaryOccupancyGrid
to see how to create additional maps for testing. If you would like to review the help file in html format then click on “Reference page for robotics.BinaryOccupancyGrid” at the end of the help file or type
matlab:doc robotics.BinaryOccupancyGrid.
In accordance with good testing practices, make sure that you achieve at least some level of branch
coverage of your code for your designed test cases.
Assumptions
The distance between two obstacles is at least 3. The bug_map{1} in hw1_maps.mat violates this assumption, but you can still use it for tests if you like.
No obstacles touch the boundary
Allowed movement actions: -1, 0, +1 for each axis in world coordinates
Grading
Max points: 100 Criteria:
Reach the goal when you can
Return as final position [inf inf] on the path when the goal is not reachable
Penalty for teleportation: the following coefficient will be used scale down your score:
scale = actual path length / (actual path length + teleportation
distance)
Penalty for infinite loop: -full points for tested scenario – infinite loops are NOT acceptable!
Penalty for longer paths than necessary: For example, you will be penalized for going around
obstacles more than once. Computed paths with length within 5% of the length of the optimal path will not be penalized. The following coefficient will be used to scale down your score: scale = optimal path length / your path length
You are allowed to resubmit as many times as you like subject to the late homework submission policy. We will only keep the score of your latest submission.
10% of the points will come from coding style: Did you write your name? Do you have comments? Do you use proper indentation? Is your code readable?
Deliverable/submission
Submit your modified Bug1.m file
Note: your submission will be checked for plagiarism and academic integrity violations.