-
Notifications
You must be signed in to change notification settings - Fork 0
/
derive_eom.m
146 lines (98 loc) · 4.44 KB
/
derive_eom.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
% Originally : Daniel Kawano, Rose-Hulman Institute of Technology
% Last modified: Feb 13, 2016
% Modified for a motion of disc with thickness L, and dissipative moment
clear all
close all
clc
% Specify symbolic parameters and symbolic variables that are functions of
% time:
syms psi(t) theta(t) phi(t) Dpsi(t) Dtheta(t) Dphi(t) x1(t) x2(t)
syms m g r lambdat lambdaa L R k1 k2 k3
assume((m > 0) & (g > 0) & (r > 0) & (lambdat > 0) & (lambdaa > 0) & ...
(L > 0) & (k1 > 0) & (k2 > 0) & (k3 > 0))
% (1) Angular velocity kinematics:
% Relate the space-fixed basis {E1,E2,E3} to the corotational basis
% {e1,e2,e3} using a 3-1-3 set of Euler angles:
R1 = [cos(psi), sin(psi), 0;
-sin(psi), cos(psi), 0;
0, 0, 1];
R2 = [1, 0, 0;
0, cos(theta), sin(theta);
0, -sin(theta), cos(theta)];
R3 = [cos(phi), sin(phi), 0;
-sin(phi), cos(phi), 0;
0, 0, 1];
% Express the angular velocity vector in terms of {e1,e2,e3}:
omega = simplify((R3*R2*R1)*[0; 0; diff(psi)] + ...
(R3*R2)*[diff(theta); 0; 0] + R3*[0; 0; diff(phi)]);
% (2) Kinematic constraints:
% For rolling without slipping, the disk's instantaneous point of contact
% with the ground has zero velocity.
% vCOM in frame {E1,E2,E3}
vCOM = simplify(transpose(R3*R2*R1)*cross(omega, R3*[0; r; 0]));
% Non-integrable constraints:
Dx1 = [1, 0, 0]*vCOM;
Dx2 = [0, 1, 0]*vCOM;
% Integrable constraint:
Dx3 = [0, 0, 1]*vCOM;
x3 = simplify(int(Dx3));
% Simplify the kinematic equations for future manipulation:
omega = subs(omega, [diff(psi), diff(theta), diff(phi)], [Dpsi, Dtheta, ...
Dphi]);
Dx1 = subs(Dx1, [diff(psi), diff(theta), diff(phi)], [Dpsi, Dtheta, Dphi]);
Dx2 = subs(Dx2, [diff(psi), diff(theta), diff(phi)], [Dpsi, Dtheta, Dphi]);
Dx3 = subs(Dx3, [diff(psi), diff(theta), diff(phi)], [Dpsi, Dtheta, Dphi]);
% (3) Balance of linear momentum:
% Solve for the normal (constraint) force and the required components of
% the lateral static friction force to prevent slipping:
F1 = m*diff(Dx1) + R*cos(psi);
F2 = m*diff(Dx2) + R*sin(psi);
N = m*diff(Dx3) + m*g;
% (4) Balance of angular momentum with respect to the disk's mass center:
% Taking the disk to be axisymmetric, evaluate the absolute time
% derivative of the angular momentum about the mass center:
H = diag([lambdat, lambdat, lambdaa])*omega;
omegaRF = omega;
DH = diff(H) + cross(omegaRF, H);
% Sum moments about the mass center:
sumM = cross(R3*[0; -r; -L/2], (R3*R2*R1)*[F1; F2; N]) + ...
cross(R3*[0; 0; -L], R3*[-R; 0; 0]);
% adding disspative moment in ground frame which retards angular motion
% of disc
e1_pp = R3*R2*[1;0;0];
e2_pp = R3*R2*[0;1;0];
e3_pp = R3*R2*[0;0;1];
% assume normal reaction is always positive
Md1 = -k1*N*sign(omega'*e1_pp)*e1_pp;
Md2 = -k2*N*sign(omega'*e2_pp)*e2_pp;
Md3 = -k3*N*sign(omega'*e3_pp)*e3_pp;
sumM = sumM + Md1 + Md2 + Md3;
% Construct the second-order ODEs for rotational motion of the disk:
ODEsRot = DH == sumM;
% (5) Manipulate the system of ODEs into a form suitable for numerical
% integration:
% Express the second-order ODEs in first-order form:
ODEsRot1 = simplify(subs(ODEsRot, [diff(psi), diff(theta), diff(phi)], ...
[Dpsi, Dtheta, Dphi]));
% Manipulating the first two ODEs ultimately yields a cleaner form for the
% state equations:
ODEsRot1 = [sin(phi), -cos(phi), 0;
cos(phi), sin(phi), 0;
0, 0, 1]*ODEsRot1;
% Relate the state variables in first-order form. The first-order ODEs
% associated with the non-integrable constraints are incorporated here:
ODEsRot2Constr = [diff(psi) == Dpsi; diff(theta) == Dtheta; ...
diff(phi) == Dphi; diff(x1) == Dx1; diff(x2) == Dx2];
% Compile the state equations and arrange the state variables:
StateEqns = simplify([ODEsRot1; ODEsRot2Constr]);
StateVars = [Dpsi; Dtheta; Dphi; psi; theta; phi; x1; x2];
% Express the state equations in mass-matrix form, M(t,Y)*Y'(t) = F(t,Y):
[Msym, Fsym] = massMatrixForm(StateEqns, StateVars);
Msym = simplify(Msym)
Fsym = simplify(Fsym)
% Convert M(t,Y) and F(t,Y) to symbolic function handles with the input
% parameters specified:
M = odeFunction(Msym, StateVars, m, g, r, lambdat, lambdaa, L, R, k1, k2, k3);
F = odeFunction(Fsym, StateVars, m, g, r, lambdat, lambdaa, L, R, k1, k2, k3);
% Save M(t,Y) and F(t,Y):
save rolling_disk_ODEs.mat Msym Fsym StateVars M F