代码拉取完成,页面将自动刷新
function [error, target_index] = calc_nearest_point(Reference, Vehicle_State)
cx = Reference.cx;cy = Reference.cy;cyaw = Reference.cyaw;s = Reference.s;
x = Vehicle_State(1);y = Vehicle_State(2);Odometer = Vehicle_State(4);
sequence = find(abs(s-Odometer)<5);
distance = sqrt((cx(sequence)-x).^2 + (cy(sequence)-y).^2);
[~,minindex] = min(distance);
target_index = minindex + sequence(1)-1;
theta_path = cyaw(target_index);
path_vector = [cos(theta_path+pi/2) sin(theta_path+pi/2)];
ref_point = [cx(target_index) cy(target_index)];
error = dot(ref_point-[x,y],path_vector);
% p0 = Vehicle_State(1:3);
% p1 = [cx(target_index),cy(target_index),cyaw(target_index)];
% p2 = [cx(target_index+1),cy(target_index+1),cyaw(target_index+1)];
% ref_point = calc_proj_pose(p0,p1,p2);
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。