基于PID控制器和卡尔曼滤波器的机器人控制(Matlab代码实现)

 👨‍🎓个人主页:研学社的博客   

💥💥💞💞欢迎来到本博客❤️❤️💥💥

🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。

⛳️座右铭:行百里者,半于九十。

📋📋📋本文目录如下:🎁🎁🎁

目录

💥1 概述

📚2 运行结果

2.1 Estimated vs Real Position

2.2 Estimated vs Real Velocity 

2.3 Acceleration - Controller Output 

🎉3 参考文献

🌈4 Matlab代码实现


💥1 概述

目标是使用线性卡尔曼滤波器估计速度,并使用PID控制器控制机器人。

考虑一个在无摩擦、笔直的车道上的机器人。最初,机器人静止在位置 0。我们每 \Delta t 秒测量一次机器人的位置,但这些测量并不精确;我们希望保持机器人位置和速度的模型。

我们在这里展示如何推导创建卡尔曼滤波器的模型。 由于 F、H、R 和 Q 是恒定的,因此它们的时间指数被删除。

机器人的位置和速度由线性状态空间描述 : 位置 ;: 速度

我们假设 a(k) 是未知的,并且呈正态分布,均值为 0,标准差为 \sigma_a。根据牛顿运动定律,我们得出结论:x(k) = F x(k-1) + G a(k)

我们假设 a(k)$ 项$G没有控制输入,其中 $$F = [1 \quad Δt;0 \quad 1]$$ $$G = [Δt^2/2;Δt]$$

然后,使用PID控制器生成加速度($a$),以使用估计的加速度($\tilde{v}$)来控制机器人的速度(v)。

 

 

📚2 运行结果

2.1 Estimated vs Real Position

2.2 Estimated vs Real Velocity 

2.3 Acceleration - Controller Output 

 部分代码:

%% Plot Data
maxfig
subplot(2,1,1)
plot(time,x(1,:),'-',time,x_hat(1,:),'--',time, y,'--','Linewidth',2)
xlabel('Time (s)','fontweight','bold')
ylabel('Distance (m)','fontweight','bold')
grid on
legend('True Position','Estimated Position','Measurement','Location','northwest')
title('Estimated vs Real Position', 'FontSize', 14)
axes('position',[.68 .64 .2 .2])
box on
your_index = 58<time & time<65;
plot(time(your_index),x(1,your_index),time(your_index),x_hat(1,your_index),time(your_index),y(your_index),'Linewidth',2)
axis tight

subplot(2,1,2)
plot(time,x(1,:)-x_hat(1,:),time,x_hat(1,:)-y,'Linewidth',1.5)
legend('True Position','Measurement','Location','northwest')
xlabel('Time (s)','fontweight','bold')
ylabel('Distance (m)','fontweight','bold')
grid on
title('Error', 'FontSize', 14)
saveas(gcf,'Position.png')

maxfig
subplot(2,1,1)
plot(time,Velocity,time,x(2,:),time,x_hat(2,:),'Linewidth',2)
xlabel('Time (s)','fontweight','bold')
ylabel('Velocity (m/s)','fontweight','bold')
legend('Velocity Profile','True Velocity','Estimated Velocity','Location','northeast')
grid on
title('Estimated vs Real Velocity ', 'FontSize', 14)
subplot(2,1,2)
plot(time,Velocity-x(2,:),'Linewidth',1.5)
xlabel('Time (s)','fontweight','bold')
ylabel('Velocity (m/s)','fontweight','bold')
grid on
title('Error', 'FontSize', 14)
saveas(gcf,'Velocity.png')

maxfig
plot(time,a,'Linewidth',2)
xlabel('Time (s)','fontweight','bold')
ylabel('Acceleration (m/s^2)','fontweight','bold')
grid on
title('Acceleration - Controller Output', 'FontSize', 14)
saveas(gcf,'Acceleration.png')

🎉3 参考文献

部分理论来源于网络,如有侵权请联系删除。

[1]彭道刚,赵晨洋,戚尔江.基于准模型校准卡尔曼滤波的巡检机器人运动系统辨识研究[J].电气传动,2020,50(04):74-80.DOI:10.19457/j.1001-2095.dqcd19286.

[2]赵泽锴,陈增,古依伶,王玲杜玉,彭晓波,冯文博,张明明.基于容积卡尔曼滤波-自适应PID的共轴无人机设计[J].科技创新与应用,2023,13(07):38-41.DOI:10.19981/j.CN23-1581/G3.2023.07.008.

🌈4 Matlab代码实现

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值