⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simlego1.m

📁 该程序用PID系统实现差动转向车辆控制
💻 M
字号:
%% Author: epokh
%% Website: www.epokh.org/drupy
%% This software is under GPL


%% This script initialize the simulation and uses
%% the kinematics formula with a simple approssimation "point and shoot"
clf

%% vl,vr expressed in meters/seconds
%%the left wheel velocity
vl=0.01
%%the right wheel velocity
vr=0.02
%%the initial orientation of the robot
%%the angle is counter clockwise from the x axis
theta0=0
%%b is the axis length of the robot that connect the 2 wheels expressed in
%%meters
b=0.5;
%%the run time
tstart=0
tend=4
timestep=0.1

%%
%%[theta1,x1,y1]=deadReckonSpace([0,0],sr,sl,theta0,b);
%%

%%now define the number of time steps
nsteps=(tend-tstart)/timestep;
%%this is the starting position for the robot
start_pos=[0,0,theta0];
position_pts=[start_pos];
old_pos=start_pos;
lwheel_trace=LeftWheelLoc(start_pos,b);
rwheel_trace=RightWheelLoc(start_pos,b);
figure(1);
DrawRobotPosition(old_pos,b);
for t=tstart:timestep:tend
new_pos=deadReckonTimeVelocity3(old_pos,vr,vl,t,b);
position_pts=[position_pts; new_pos];
lwheel_trace=[lwheel_trace; LeftWheelLoc(new_pos,b)];
rwheel_trace=[rwheel_trace; RightWheelLoc(new_pos,b)];
old_pos=new_pos;
DrawRobotPosition(old_pos,b);
end

%% Draw the traces for the left and right wheel
DrawWheelTrace(lwheel_trace,'b');
DrawWheelTrace(rwheel_trace,'b');

%%now define the space boundaries
%%becareful to plan  the trajectory well or the robot will
%%go outside
xmin=min(position_pts(:,1))-b
xmax=max(position_pts(:,1))+b
ymin=min(position_pts(:,2))-b
ymax=max(position_pts(:,2))+b
box_space=[xmin xmax ymin ymax];
axis(box_space);

title('Differential steering robot simulation');
xlabel('X coordinate');
ylabel('Y coordinate');


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -