How to locate a collide segment of a post-smoothed path?

조회 수: 5 (최근 30일)
YAAQOB AL-JAMALI
YAAQOB AL-JAMALI 2022년 6월 9일
댓글: YAAQOB AL-JAMALI 2022년 6월 9일
I am working on motion planning problem, and so fare i have generated irregular path and then prun it using Ramer–Douglas–Peucker algorithm later by utilizing piecewise cubic B-spline we could produce smoothed path. However, collision-freeness is not quarantee so that I am trying to check for a collision condition for a post-smoothed path. I have mangage to identify if there is a collision using the following code:
env = map;
% J = im2uint8( map );
% env = imnoise( J ,'salt & pepper');
v = pathSmooth;
for ii = 1:length(v)-1
if env(round(v(ii,1)), round(v(ii,2))) ~= 0
disp('There is no intersection')
else
disp('There is intersection')
pause;
end
end
My question, how to locate the first and last locations where the collision are detected based on the ii index and return them?
I have attached mat files for the used map as well as the resulted smoothed path for your reference as well as an image for the map, reduced path, and smoothed path.

채택된 답변

KSSV
KSSV 2022년 6월 9일
env = map;
% J = im2uint8( map );
% env = imnoise( J ,'salt & pepper');
v = pathSmooth;
iwant = zeros([],2) ;
count = 0 ;
for ii = 1:length(v)-1
if env(round(v(ii,1)), round(v(ii,2))) ~= 0
disp('There is no intersection')
else
count = count+1 ;
iwant(count,:) = [round(v(ii,1)), round(v(ii,2))] ;
disp('There is intersection')
end
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interpolation of 2-D Selections in 3-D Grids에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by