How to reduce the time of running when using pathPlannerRRT?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
clc; clear all; close all;
tic
profile on
mapWidth = 35;
mapLength = 40;
costVal = 0.1;
cellSize = 0.5;
startPose = [5, 5, 90]; % [meters, meters, degrees]
goalPose = [31, 17, 90];
costmap = vehicleCostmap(mapWidth,mapLength,costVal,'CellSize',cellSize);
L = 4.7;
W = 1.8;
H = 1.4;
FrontOverhang = 0;
RearOverhang = L/2;
vehicleDims = vehicleDimensions(L, W, H, 'FrontOverhang', FrontOverhang, 'RearOverhang', RearOverhang); % 4.5 m long, 1.7 m wide
numCircles = 3;
ccConfig = inflationCollisionChecker(vehicleDims,numCircles);
costmap.CollisionChecker = ccConfig;
[x,y] = meshgrid(25:0.5:27,12:0.5:14);
xyPoints = [x(:),y(:)];
costVal = 0.9;
setCosts(costmap,xyPoints,costVal);
[x2,y2] = meshgrid(10:0.5:32,0:0.5:8);
xyPoints2 = [x2(:),y2(:)];
setCosts(costmap,xyPoints2,costVal);
[x3,y3] = meshgrid(33:0.5:35,12:0.5:14);
xyPoints3 = [x3(:),y3(:)];
setCosts(costmap,xyPoints3,costVal)
[x4,y4] = meshgrid(15:0.5:20,12:0.5:14);
xyPoints4 = [x4(:),y4(:)];
setCosts(costmap,xyPoints4,costVal)
plot(costmap);
isPathValid = false;
kk = 1;
while (isPathValid == 0) && (kk < 15)
planner = pathPlannerRRT(costmap, 'ApproximateSearch', false, 'MaxIterations', 1e4, 'MinTurningRadius', 3, 'ConnectionDistance', 10);
refPath = plan(planner,startPose,goalPose);
isPathValid = checkPathValidity(refPath,costmap);
kk = kk + 1;
end
transitionPoses = interpolate(refPath);
hold on
plot(refPath,'DisplayName','Planned Path')
scatter(transitionPoses(:,1),transitionPoses(:,2),[],'filled', ...
'DisplayName','Transition Poses')
hold off
p = profile('info')
save myprofiledata p
toc
0 comentarios
Respuestas (1)
Sachin Lodhi
el 16 de Feb. de 2024
Hello Hongtao, it appears that you are facing extended processing times with your code and are interested in strategies to decrease it. To shorten the execution time of the provided code, adjusting certain parameter values may be necessary.
An additional optimization tactic, once the goal has been achieved, involves lowering the limit on the number of iterations and enlarging the maximum allowable distance for connections. Currently, your maximum iterations are set at 10,000; by diminishing this value, you could potentially lessen the execution time.
For further details, you can consult the following link: https://www.mathworks.com/help/nav/ref/plannerrrtstar.html#d126e155691
0 comentarios
Ver también
Categorías
Más información sobre Motion Planning en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!