动态机器人轨迹的matlab仿真

function mobile_robot_NN()
clc
close all
clear all
%% =========== Set the paramters =======
T=0.01; % Sampling Time
k=2; % Sampling counter
x(k-1)=0; % initilize the state x
y(k-1)=0; % initilize the state y
theta(k-1)=0; % initilize the state theta
tfinal=100; % final simulation time
t=0; % intilize the time 
%=====================================
%% =========== The main loop ==========
while(t<=tfinal) 
t=t+T; % increase the time
V=0.5;W=1; 
theta(k)=W*T+theta(k-1); % calculating theta
x(k)=V*cos(theta(k))*T+x(k-1); % calculating x
y(k)=V*sin(theta(k))*T+y(k-1); % calculating y
draw_robot(); % Draw the robot and it's path
k=k+1; % increase the sampling counter
end
%=====================================
%% === Draw the mobile robot & Path ====
function draw_robot()
xmin=-1.2; % setting the figure limits 
xmax=1.2;
ymin=-1.2;
ymax=1.2;
mob_L=0.2; % The Mobile Robot length
mob_W=0.1; % The Mobile Robot width
Tire_W=0.05; % The Tire width
Tire_L=mob_L/2;  % The Tire length
plot(x,y,'-r') % Dawing the Path
axis([xmin xmax ymin ymax]) % setting the figure limits
axis square
hold on

% Body
v1=[mob_L;-mob_W];
v2=[-mob_L/4;-mob_W];
v3=[-mob_L/4;mob_W];
v4=[mob_L;mob_W];
%Right Tire
v5=[Tire_L/2;-mob_W-0.02];
v6=[Tire_L/2;-mob_W-Tire_W-0.02];
v7=[-Tire_L/2;-mob_W-Tire_W-0.02];
v8=[-Tire_L/2;-mob_W-0.02];
%Left Tire
v9=[Tire_L/2;mob_W+0.02];
v10=[Tire_L/2;mob_W+Tire_W+0.02];
v11=[-Tire_L/2;mob_W+Tire_W+0.02];
v12=[-Tire_L/2;mob_W+0.02];
%Line
v13=[0;-mob_W-0.02];
v14=[0;mob_W+0.02];
%Front Tire
v15=[mob_L;Tire_W/2];
v16=[mob_L;-Tire_W/2];
v17=[mob_L-Tire_L/1.5;-Tire_W/2];
v18=[mob_L-Tire_L/1.5;Tire_W/2];

R=[cos(theta(k)) -sin(theta(k));sin(theta(k)) cos(theta(k))]; % Rotation Matrix
P=[x(k);y(k)]; % Position Matrix

v1=R*v1+P;
v2=R*v2+P;
v3=R*v3+P;
v4=R*v4+P;

v5=R*v5+P;
v6=R*v6+P;
v7=R*v7+P;
v8=R*v8+P;

v9=R*v9+P;
v10=R*v10+P;
v11=R*v11+P;
v12=R*v12+P;

v13=R*v13+P;
v14=R*v14+P;

v15=R*v15+P;
v16=R*v16+P;
v17=R*v17+P;
v18=R*v18+P;

 B34

  • 4
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

fpga和matlab

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值