?? curveexample.m
字號:
%% Author: epokh
%% Website: www.epokh.org/drupy
%% This software is under GPL
%% This script initialize the simulation and uses
%% the PID controller with the approximated equations
close all
%% vl,vr expressed in meters/seconds
%%the left wheel velocity
vl=0.01
%%the maximum left speed
vlmax=0.1
%%the right wheel velocity
vr=0.01
%%the maximum right speed
vrmax=0.1
%%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=2;
timestep=0.1;
%%now define the number of time steps
nsteps=(tend-tstart)/timestep;
%%this is the starting position for the robot
start_pos=[0,0,0];
end_pos=[5,5,2];
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);
vel=curve(start_pos,end_pos,b,tend-tstart);
vr=vel(2);
for t=tstart:timestep:tend
new_pos=deadReckonTimeVelocity(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);
pause(0.5)
end
%% Draw the traces for the left and right wheel
figure(2)
DrawWheelTrace(lwheel_trace,'b');
DrawWheelTrace(rwheel_trace,'b');
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -