-
Notifications
You must be signed in to change notification settings - Fork 0
/
euler_lagrange_matrix.m
67 lines (56 loc) · 1.59 KB
/
euler_lagrange_matrix.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
%Calculate Euler_lagrange matrixs
clc;
clear;
close all;
%%
syms a r theta(t) t mt I Iw real
%Constraint matrix with c != p
% S = [(r/(2*a))*(a*cos(theta) - d*sin(theta)), (r/(2*a))*(a*cos(theta) + d*sin(theta));
% (r/(2*a))*(a*sin(theta) + d*cos(theta)), (r/(2*a))*(a*sin(theta)-d*cos(theta));
% r/(2*a), -r/(2*a);
% 1 , 0;
% 0 , 1];
d=0;
S = [(r/(2*a))*(a*cos(theta) - d*sin(theta)), (r/(2*a))*(a*cos(theta) + d*sin(theta));
(r/(2*a))*(a*sin(theta) + d*cos(theta)), (r/(2*a))*(a*sin(theta)-d*cos(theta));
r/(2*a), -r/(2*a);];
%Constraint matrix with c = p
% S = 1/2*[r*cos(theta(t)) r*cos(theta(t));
% r*sin(theta(t)) r*sin(theta(t));
% r/a -r/a;
% 2 0;
% 0 2];
%Inertia matrix
% H = [mt 0 mt*d*sin(theta(t)) 0 0;
% 0 mt -mt*d*cos(theta(t)) 0 0;
% mt*d*sin(theta(t)) -mt*d*cos(theta(t)) I 0 0;
% 0 0 0 Iw 0;
% 0 0 0 0 Iw];
H = [mt 0 mt*d*sin(theta(t));
0 mt -mt*d*cos(theta(t));
mt*d*sin(theta(t)) -mt*d*cos(theta(t)) I;];
H_bar = S.'*H*S;
H_dot = diff(H,t);
simplify(H_bar);
% C = [0 0 mt*d*diff(theta(t),t)*cos(theta(t)) 0 0;
% 0 0 mt*d*diff(theta(t),t)*sin(theta(t)) 0 0;
% 0 0 0 0 0;
% 0 0 0 0 0;
% 0 0 0 0 0];
C = [0 0 mt*d*diff(theta(t),t)*cos(theta(t));
0 0 mt*d*diff(theta(t),t)*sin(theta(t));
0 0 0;];
S_dot = diff(S, t);
C_bar = S.'*H*S_dot + S.'*C*S;
simplify(C_bar);
% E = [0 0;
% 0 0;
% 0 0;
% 1 0;
% 0 1];
E = 1/r*[cos(theta) cos(theta);sin(theta) sin(theta);a -a];
E_bar = S.'*E;
simplify(E_bar);
%Skew symmetric
H_bardot = S_dot.'*H*S + S.'*H_dot*S + S.'*H*S_dot;
simplify(H_bardot);