👨🎓个人主页:研学社的博客
💥💥💞💞欢迎来到本博客❤️❤️💥💥
🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。
⛳️座右铭:行百里者,半于九十。
📋📋📋本文目录如下:🎁🎁🎁
目录
💥1 概述
📚2 运行结果
部分代码:
function [cost] = error(kp, kd)
%close all
%clear all
clc
% Initialisations
ki = 0; % Setting k = 0 as it is pd controller
M = 0.5; m = 0.2; % Mass of body and wheels
g = 9.8; % Acceleration due to gravity
l = 0.3; % Length of body
F = 0; % Control Force
x = 0; % Initial position of robot
x_dot = 0; % Initial velocity of robot
theta = pi/10; % Initial tilt i.e. angle
theta_dot = 0; % Initial angular velocity of body
dt = 0.005; % Discretizing time
error = 0; % Declaring error
prev_error = 0; % Declaring prev_error
cost = 0;
% Iterations
t=0;
while(t < 10)
curr_error = (0+theta);
error = error + curr_error;
f = kp*(curr_error) + ki*(error) + kd*(curr_error - prev_error );
prev_error = curr_error;
% Calculation theta_next
d_theta_dot = (((g*theta*(M+m)-F)/(M*l)))*dt;
theta_dot = theta_dot + d_theta_dot;
d_theta = theta_dot*dt;
theta = theta + d_theta;
% Calculation of x_next
d_x_dot = ((F-(1/M)*(m*g*theta)))*dt;
x_dot = x_dot + d_x_dot ;
d_x = (x_dot)*dt;
x = x + d_x;
% The controller
F = f;
cost = abs(theta) + cost;
t = t+dt ;
end
🎉3 参考文献
部分理论来源于网络,如有侵权请联系删除。
[1]艾福强,包建东,刘正权.基于粒子群优化模糊PID控制的多足式真空吸附机器人控制方案设计[J].电子测量技术,2023,46(02):67-72.DOI:10.19651/j.cnki.emt.2210451.
[2]朱龙英,成磊,郑帅,陆宝发,赫建立.基于粒子群优化神经网络自适应控制算法的并联机器人仿真研究[J].组合机床与自动化加工技术,2015(01):114-117+122.DOI:10.13462/j.cnki.mmtamt.2015.01.032.