-
Notifications
You must be signed in to change notification settings - Fork 0
/
path_finder_robot.m
61 lines (36 loc) · 1.25 KB
/
path_finder_robot.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
clc
clear all
% Probabilistic Roadmap (PRM) path planner
% The imported maps are : simpleMap, complexMap and ternaryMap.
% Example Maps for Planning a Path
load exampleMaps.mat
map = binaryOccupancyMap(simpleMap,2)
show(map)
% To ensure that the robot does not collide with any
% obstacles, you should inflate the map by the
% dimension of the robot before supplying it to the PRM path planner
robotRadius = 0.2;
% PRM does not account for the dimension of the robot, and hence providing an
%inflated map to the PRM takes into account the robot dimension
mapInflated = copy(map);
inflate(mapInflated,robotRadius);
show(mapInflated);
%to define a path planner
prm = mobileRobotPRM;
%Assign the inflated map to the PRM object
prm.Map = mapInflated;
%define nodes or points over the map, more
% nodes, greater the complexity of the map and
% higher computation time
prm.NumNodes = 50;
% these denotes the Define the maximum allowed distance
% between two connected nodes on the map. PRM connects all
% nodes separated by this distance (or less) on the map
prm.ConnectionDistance = 10;
%define start location
startLocation = [2 1]
%define end locationk
endLocation = [7 2]
%final path
path = findpath(prm, startLocation, endLocation)
show(prm)