Robotics in Wall Collision Problem
Show older comments
I was trying to do Path Planning for a robot by generating random nodes and linking them together. However, when nodes are linked, lines could be outside the map that I set. Therefore, I've tried to find intersections between the wall lines and nodes lines and delete them. The below shows my code of working :
map = [-30,0;-30,40;30,40;30,60;5,60;45,90;85,60;60,60;60,40;120,40;120,60;95,60;135,90;175,60;150,60;150,40;210,40;210,60;185,60;225,90;265,60;240,60;240,40;300,40;300,0]; %repeated features
botSim = BotSim(map,[0,0,0]); %sets up a botSim object a map, and debug mode on.
botSim.drawMap();
N_n = 20; % number of nodes
N = zeros(N_n,2);
a = size(map);
for i = 1:a(1)
n_cor(i,1) = map(i,1);
n_cor(i,2) = map(i,2);
L_w = line(n_cor(i,1),n_cor(i,2));
for i = 1:N_n
q = botSim.getRndPtInMap(10)';
N(i,:) = q;
plot(N(:,1),N(:,2),'o')
plot(N(:,1),N(:,2),'-')
L_n = line(N(:,1),N(:,2));
hold on
end
if L_w == L_n
L_n = [];
end
end
With the above code, I couldn't manage to delete those lines which intersect with walls. Can I know why and will there be an easier/efficient way to work on this?? Thank you
Accepted Answer
More Answers (0)
Categories
Find more on Robotics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!