% Physical Constant
g = 9.81; % gravity acceleration重力加速度 [m/sec^2]
% NXTway-GS Parameters平衡車相關(guān)參數(shù)
m = 0.015; % wheel weight車輪重量(個人更改) [kg]
R = 0.04; % wheel radius車輪半徑(個人更改) [m]
Jw = m * R^2 / 2; % wheel inertia moment車輪慣性力矩 [kgm^2]
M = 1.5; % body weight車體重量(個人更改) [kg]
W = 0.23; % body width車體寬度(個人更改) [m]
D = 0.12; % body depth車體深度(個人更改) [m]
H = 0.17; % body height車體高度(個人更改) [m]
L = 0.075;%H / 2; % distance of the center of mass from the wheel axle [m]
% 車體重心高度,一般為車體高度一半(個人更改)
Jpsi = M * L^2 / 3; % body pitch inertia moment車體慣性力矩(取重心高度) [kgm^2]
Jphi = M * (W^2 + D^2) / 12; % body yaw inertia moment車體偏航慣性力矩 [kgm^2]
fm = 0.0022; % friction coefficient between body & DC motor
% 車體與電機之間的摩擦系數(shù)
fw = 0; % friction coefficient between wheel & floor
% 輪胎與地面之間的摩擦系數(shù)
% DC Motor Parameters電機相關(guān)參數(shù)
Jm = 5.7e-7; % DC motor inertia moment電機慣性力矩(基本可以忽略) [kgm^2]
Rm = 2.7; % DC motor resistance電機阻抗 [ohm]
Kb = 0.013; % DC motor back EMF constant電機反電動勢 [Vsec/rad]
Kt = 0.013; % DC motor torque constant電機轉(zhuǎn)矩常數(shù) [Nm/A]
n = 64; % gear ratio齒輪比吨铸,減速比
% NXTway-GS State-Space Matrix Calculation矩陣計算
alpha = n * Kt / Rm;
beta = n * Kt * n* Kb / Rm + fm;
tmp = beta + fw;
E_11 = (2 * m + M) * R^2 + 2 * Jw + 2 * n^2 * Jm;
E_12 = M * L * R - 2 * n^2 * Jm;
E_22 = M * L^2 + Jpsi + 2 * n^2 * Jm;
detE = E_11 * E_22 - E_12^2;
A1_32 = -g * M * L * E_12 / detE;
A1_42 = g * M * L * E_11 / detE;
A1_33 = -2 * (tmp * E_22 + beta * E_12) / detE;
A1_43 = 2 * (tmp * E_12 + beta * E_11) / detE;
A1_34 = 2 * beta * (E_22 + E_12) / detE;
A1_44 = -2 * beta * (E_11 + E_12) / detE;
B1_3 = alpha * (E_22 + E_12) / detE;
B1_4 = -alpha * (E_11 + E_12) / detE;
A1 = [
0 0 1 0
0 0 0 1
0 A1_32 A1_33 A1_34
0 A1_42 A1_43 A1_44
];
B1 = [
0 0
0 0
B1_3 B1_3
B1_4 B1_4
];
C1 = eye(4);
D1 = zeros(4, 2);
I = m * W^2 / 2 + Jphi + (Jw + n^2 * Jm) * W^2 / (2 * R^2);
J = tmp * W^2 / (2 * R^2);
K = alpha * W / (2 * R);
A2 = [
0 1
0 -J / I
];
B2 = [
0 0
-K / I K / I
];
C2 = eye(2);
D2 = zeros(2);
clear alpha beta tmp
clear E_11 E_12 E_22 detE
clear A1_32 A1_33 A1_34 A1_42 A1_43 A1_44 B1_3 B1_4 I J K
% Controller Parameters
% Servo Gain Calculation using Optimal Regulator
A_BAR = [A1, zeros(4, 1); C1(1, :), 0];
B_BAR = [B1; 0, 0];
QQ = [
1, 0, 0, 0, 0
0, 6e5, 0, 0, 0
0, 0, 1, 0, 0
0, 0, 0, 1, 0
0, 0, 0, 0, 4e2
];
RR = 1e3 * eye(2);
KK = lqr(A_BAR, B_BAR, QQ, RR);
k_f = KK(1, 1:4); % feedback gain
k_i = KK(1, 5); % integral gain
ts1 = 0.002;
a_r = 0.996; % smooth reference signal
dt = 0.005
% suppress velocity gain because it fluctuates NXTway-GS
% k_f(3) = k_f(3) * 0.85;
2020-12-09
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進店門掌逛,熙熙樓的掌柜王于貴愁眉苦臉地迎上來师逸,“玉大人,你說我怎么就攤上這事豆混÷ㄏ瘢” “怎么了?”我有些...
- 文/不壞的土叔 我叫張陵皿伺,是天一觀的道長员辩。 經(jīng)常有香客問我,道長鸵鸥,這世上最難降的妖魔是什么奠滑? 我笑而不...
- 正文 為了忘掉前任,我火速辦了婚禮,結(jié)果婚禮上养叛,老公的妹妹穿的比我還像新娘。我一直安慰自己宰翅,他們只是感情好弃甥,可當我...
- 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著汁讼,像睡著了一般淆攻。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上嘿架,一...
- 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼召川!你這毒婦竟也來了南缓?” 一聲冷哼從身側(cè)響起,我...
- 正文 年R本政府宣布童漩,位于F島的核電站,受9級特大地震影響春锋,放射性物質(zhì)發(fā)生泄漏矫膨。R本人自食惡果不足惜,卻給世界環(huán)境...
- 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望侧馅。 院中可真熱鬧危尿,春花似錦、人聲如沸馁痴。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽罗晕。三九已至济欢,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間小渊,已是汗流浹背法褥。 一陣腳步聲響...
推薦閱讀更多精彩內(nèi)容
- 點擊此處添加圖片說明文字 以太坊在經(jīng)過昨日晚間的震蕩之后在早間終于破位垛吗,幣價突破三角區(qū)間之后再次迅速下跌凹髓,在連續(xù)兩...