方法示意圖:
控制率公式:
其中theta是當前航向角與路徑航向角之差,e為橫向誤差,v為車輛速度,lambda為控制參數。
算法步驟如下:
1. 根據當前定位結果找到路徑最鄰近點。
2. 計算該點與定位結果橫向誤差e與航線誤差theta。
3. 根據控制率公式計算出前輪轉角。
4. 將前輪轉角轉化為航向角,帶入運動模型計算出下一時刻的位姿。
matlab代碼如下:
clear all;close all;clc; v = 1; lambda = 3; dt = 0.1; L=2.5; curp=[0 0 0]; x = 0:0.1:50; y = sin(x/5); path = [x' y']; for i=2:length(path) dx = path(i,1)-path(i-1,1); dy = path(i,2)-path(i-1,2); path(i-1,3) = atan2(dy,dx); end path(length(path),3) = path(length(path)-1,3); plot(path(:,1),path(:,2),'r.'); hold on; for i=1:length(path) d = path(:,1:2) - curp(1:2); dis = d(:,1).^2 + d(:,2).^2; [~,ind] = min(dis); %找路徑最近點索引 dx = curp(1) - path(ind,1); dy = curp(2) - path(ind,2); e = (sin(curp(3) - atan2(dy,dx)))*sqrt(dx*dx+dy*dy); %橫向偏差 u = (path(ind,3) - curp(3)) + atan2(lambda*e,v); %期望前輪轉角 curp(1) = curp(1) + dt*v*cos(curp(3)); curp(2) = curp(2) + dt*v*sin(curp(3)); curp(3) = curp(3) + dt*v*tan(u)/L; plot(curp(1),curp(2),'g.'); end
結果如下: