Advertisement
Ostu

Untitled

Jan 10th, 2023
1,061
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.58 KB | None | 0 0
  1. load exampleMaps.mat
  2. whos *Map*
  3. map = binaryOccupancyMap(simpleMap,2);
  4. show(map)
  5.  
  6. robotRadius = 0.2;
  7. mapInflated = copy(map);
  8. inflate(mapInflated,robotRadius);
  9.  
  10. show(mapInflated)
  11. prm = mobileRobotPRM;
  12. prm.Map = mapInflated;
  13. prm.NumNodes = 50;
  14. prm.ConnectionDistance = 5;
  15.  
  16. startLocation = [2 1];
  17. endLocation = [12 10];
  18. path = findpath(prm, startLocation, endLocation)
  19. show(prm)
  20.  
  21.  
  22. while isempty(path)
  23.     % No feasible path found yet, increase the number of nodes
  24.     prm.NumNodes = prm.NumNodes + 10;
  25.    
  26.     % Use the |update| function to re-create the PRM roadmap with the changed
  27.     % attribute
  28.     update(prm);
  29.    
  30.     % Search for a feasible path with the updated PRM
  31.     path = findpath(prm, startLocation, endLocation);
  32. end
  33. %%
  34. load exampleMaps.mat
  35. whos *Map*
  36. map = binaryOccupancyMap(simpleMap,2);
  37. show(map)
  38.  
  39. robotRadius = 0.2;
  40. mapInflated = copy(map);
  41. inflate(mapInflated,robotRadius);
  42.  
  43. show(mapInflated)
  44. prm = mobileRobotPRM;
  45. prm.Map = mapInflated;
  46. prm.NumNodes = 50;
  47. prm.ConnectionDistance = 5;
  48.  
  49. show(mapInflated)
  50.  
  51. prm.Map = mapInflated;
  52. prm.NumNodes = 20;
  53. prm.ConnectionDistance = 15;
  54.  
  55. startLocation = [3 3];
  56. endLocation = [45 35];
  57. path = findpath(prm, startLocation, endLocation);
  58.  
  59. while isempty(path)
  60.     % No feasible path found yet, increase the number of nodes
  61.     prm.NumNodes = prm.NumNodes + 10;
  62.    
  63.     % Use the |update| function to re-create the PRM roadmap with the changed
  64.     % attribute
  65.     update(prm);
  66.    
  67.     % Search for a feasible path with the updated PRM
  68.     path = findpath(prm, startLocation, endLocation);
  69. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement