%global k1,Lfc,Kp,dt,L; %k1=0.1 ;%前视距离系数 %Lfc=2.0 ; %前视距离 %Kp=1.0 ; %速度P控制器系数 %dt=0.1 ; % 时间间隔,单位:s %L=2.9 ;% 车辆轴距,单位:m function [] =main1() dt=0.1; cx=0:1:50; cy=arrayfun(@(x)cos(x/5.0)*x/2.0,cx);%sin(x/5.0)*x/2.0 target_speed = 10.0 / 3.6;%[m/s] T = 100.0;% 最大模拟时间 %设置车辆的初始状态 state=struct('x',-0.0,'y',-3.0,'yaw',0.0,'v',0.0);%结构体表示当前状态的值 lastIndex = length(cx) - 1; time = 0.0; x = [state.x]; y = [state.y]; yaw = [state.yaw]; v = [state.v]; t = [0.0]; target_ind = calc_target_index(state, cx, cy); while T >= time && lastIndex > target_ind ai = PControl(target_speed, state.v); [di, target_ind] = pure_pursuit_control(state, cx, cy, target_ind); state = update1(state, ai, di); time = time + dt; x=[x state.x] y=[y state.y] yaw=[yaw state.yaw]
matlab的pure_pursuit纯跟踪算法实现(matlab2018及以上版本直接新建函数 全代码)
最新推荐文章于 2024-05-30 01:37:33 发布
本文档详细介绍了如何在MATLAB 2018及更高版本中实现pure_pursuit纯追踪算法,包括main1()、update1()、pure_pursuit_control()、PControl()和calc_target_index()等关键函数的代码实现。
摘要由CSDN通过智能技术生成