View Code? Open in Web Editor
NEW
Dubins path for path planning of UAV
License: GNU General Public License v3.0
dubins-path-pp's Introduction
Hey there fellow engineer π
- β always up for philosophy-101 discussions over a cup of tea/coffee
and also,
dubins-path-pp's People
Watchers
dubins-path-pp's Issues
- The speed direction does not match the path.
- All paths are not exhausted.
consider about the following file
%starting Pose
xs = 0; ys = 0; phis=deg2rad(90);
%final Pose
xf = 10; yf = 10; phif=deg2rad(70);
%curvature constraints:εεΎε€§ε°
rhos = 3; rhof = 1;
Mode = 3;%1γL+L 2γL+R 3γR+R 4γR+L
%center of curvature circles: 左转εεε³θ½¬ε
xcs_L = xs - rhoscos(phis - pi/2);
ycs_L = ys - rhossin(phis - pi/2);
xcf_L = xf - rhofcos(phif - pi/2);
ycf_L = xf - rhofsin(phif - pi/2);
xcs_R = xs + rhoscos(phis - pi/2);
ycs_R = ys + rhossin(phis - pi/2);
xcf_R = xf + rhofcos(phif - pi/2);
ycf_R = xf + rhofsin(phif - pi/2);
%%
switch Mode
case 1%L+L
%tangent entry (E) and exit (X)
c = sqrt((xcs_L - xcf_L)^2 + (ycs_L-ycf_L)^2);
alpha = asin((rhof-rhos)/c);
beta = atan2(ycf_L-ycs_L, xcf_L - xcs_L);
%E
% phi = alpha+beta +pi/2; % right turn
phi = beta-alpha +3pi/2; % left turn
xPX = xcs_L + rhoscos(phi);
yPX = ycs_L + rhossin(phi);
%X
%phi = alpha+beta +pi/2; %right turn
phi = beta-alpha +3pi/2; %left turn
xPN = xcf_L + rhofcos(phi);
yPN = ycf_L + rhofsin(phi);
xcs = xcs_L;ycs = ycs_L; xcf = xcf_L; ycf = ycf_L;
case 2%L+R
%tangent entry (E) and exit (X)
c = sqrt((xcs_L - xcf_R)^2 + (ycs_L-ycf_R)^2);
alpha = asin((rhof-rhos)/c);
beta = atan2(ycf_R-ycs_L, xcf_R - xcs_L);
%E
% phi = alpha+beta +pi/2; % right turn
phi = beta-alpha +3pi/2; % left turn
xPX = xcs_L + rhoscos(phi);
yPX = ycs_L + rhossin(phi);
%X
phi = alpha+beta +pi/2; %right turn
%phi = beta-alpha +3pi/2; %left turn
xPN = xcf_R + rhofcos(phi);
yPN = ycf_R + rhofsin(phi);
xcs = xcs_L;ycs = ycs_L; xcf = xcf_R; ycf = ycf_R;
case 3% R+R
%tangent entry (E) and exit (X)
c = sqrt((xcs_R - xcf_R)^2 + (ycs_R-ycf_R)^2);
alpha = asin((rhof-rhos)/c);
beta = atan2(ycf_R-ycs_R, xcf_R - xcs_R);
%E
phi = alpha+beta +pi/2; % right turn
%phi = beta-alpha +3pi/2; % left turn
xPX = xcs_R + rhoscos(phi);
yPX = ycs_R + rhossin(phi);
%X
phi = alpha+beta +pi/2; %right turn
%phi = beta-alpha +3pi/2; %left turn
xPN = xcf_R + rhofcos(phi);
yPN = ycf_R + rhofsin(phi);
xcs = xcs_R;ycs = ycs_R; xcf = xcf_R; ycf = ycf_R;
otherwise%R+L
%tangent entry (E) and exit (X)
c = sqrt((xcs_R - xcf_L)^2 + (ycs_R-ycf_L)^2);
alpha = asin((rhof-rhos)/c);
beta = atan2(ycf_L-ycs_R, xcf_L - xcs_R);
%E
phi = alpha+beta +pi/2; % right turn
%phi = beta-alpha +3pi/2; % left turn
xPX = xcs_R + rhoscos(phi);
yPX = ycs_R + rhossin(phi);
%X
%phi = alpha+beta +pi/2; %right turn
phi = beta-alpha +3pi/2; %left turn
xPN = xcf_L + rhofcos(phi);
yPN = ycf_L + rhofsin(phi);
xcs = xcs_R;ycs = ycs_R; xcf = xcf_L; ycf = ycf_L;
end
%%
%%%%%η»εΎ
close all;
figure()
hold on
%plot circles:
centers = [xcs ycs; xcf ycf]; radii = [rhos; rhof];
viscircles(centers,radii)%η»ε€δΈͺε
%plot poses:
scatter(xs, ys,45, '','r','LineWidth',5);
scatter(xf, yf,45, '','r','LineWidth',5);
%plot center line
xc = [xcs xcf];
yc = [ycs ycf];
plot(xc, yc, '--')
xT = [xPX xPN]; yT = [yPX yPN];
plot(xT, yT, 'k','lineWidth', 3)
hold off
daspect([1,1,1])