In [1]:
from sympyhelpers import *
init_printing()
In [2]:
th,psi,thd,psid,R,g,t,l,thdd,phdd,psidd,N1,N2,N3,mr,tau,J = \
symbols('theta,psi,thetadot,psidot,R,g,t,l,thetaddot,phiddot,psiddot,N_1,N_2,N_3,m_r,tau,J')
diffdict = {th:thd,thd:thdd,psi:psid,psid:psidd}
In [3]:
bCi = rotMat(3,psi) # I->B
cCb = rotMat(2,-th) # B->C
bCi,cCb
Out[3]:
In [4]:
iWb = Matrix([0,0,psid]) #B frame
bWc = Matrix([0,-thd,0]) #C frame
In [5]:
h_O = J*iWb;
M_O = Matrix([0,R,0]).cross(Matrix([-N1,-N2,N3]));
h_O,M_O
Out[5]:
In [6]:
eom1 = solve(transportEq(h_O,t,diffdict,iWb)-M_O,psidd); eom1
Out[6]:
In [7]:
r_GO = Matrix([0,R,0]) + cCb.T*Matrix([0,0,l/2]); r_GO
Out[7]:
In [8]:
v_GO = transportEq(r_GO,t,diffdict,iWb)
v_GO
Out[8]:
In [9]:
a_GO = transportEq(v_GO,t,diffdict,iWb);
simplify(a_GO)
Out[9]:
In [10]:
Ns = solve(mr*a_GO - Matrix([N1,N2,mr*g-N3]),(N1,N2,N3));Ns
Out[10]:
In [11]:
r_QG = Matrix([0,0,-l/2])
I_Q = mr*l**2/12*(eye(3) - diag(0,0,1)) + mr*((r_QG.transpose()*r_QG)[0]*eye(3) - r_QG*r_QG.transpose())
I_Q
Out[11]:
In [12]:
iWc = bWc + cCb*iWb
h_Q = I_Q*iWc
iWc,h_Q
Out[12]:
In [13]:
dh_Q = transportEq(h_Q,t,diffdict,iWc)
M_Q = Matrix([tau,mr*g*l/2*sin(th),0])
r_QO = cCb*Matrix([0,R,0])
a_QO = simplify(transportEq(transportEq(r_QO,t,diffdict,iWc),t,diffdict,iWc))
dh_Q,M_Q,a_QO
Out[13]:
In [14]:
r_QG = Matrix([0,0,-l/2])
eom2 = solve(dh_Q - (M_Q + mr*r_QG.cross(a_QO)),thdd)
eom2
Out[14]:
In [15]:
simplify(solve([thdd - eom2[thdd],psidd - eom1[psidd].subs(N1,Ns[N1])],(psidd,thdd)))
Out[15]: