<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Dynamics of a Spinning Symmetric Rigid Body
Step1:  Spinning Symmetric Rigid Body setup
Step2:  $\left[{}^\mathcal{I}\boldsymbol{\omega}^\mathcal{B}\right]_\mathcal{B}$
Step3:  ${}^\mathcal{I}\boldsymbol{\omega}^\mathcal{C} = {}^\mathcal{I}\boldsymbol{\omega}^\mathcal{B} + {}^\mathcal{B}\boldsymbol{\omega}^\mathcal{C}$. 
$\left[{}^\mathcal{I}\boldsymbol{\omega}^\mathcal{C}\right]_\mathcal{B}$
Step4:  $\left[ \mathbb I_G \right]_\mathcal B$
Step5:  $\left[{}^\mathcal{I} \mathbf h_G\right]_\mathcal{B}$
Step6:  $\vphantom{\frac{\mathrm{d}}{\mathrm{d}t}}^\mathcal{I}\frac{\mathrm{d}}{\mathrm{d}t}  {}^\mathcal{I} \mathbf h_G = \vphantom{\frac{\mathrm{d}}{\mathrm{d}t}}^\mathcal{B}\frac{\mathrm{d}}{\mathrm{d}t}  {}^\mathcal{I} \mathbf h_G + {}^\mathcal{I}\boldsymbol{\omega}^\mathcal{B} \times  \mathbf h_G$.
$\left[\vphantom{\frac{\mathrm{d}}{\mathrm{d}t}}^\mathcal{I}\frac{\mathrm{d}}{\mathrm{d}t}  {}^\mathcal{I} \mathbf h_G\right]_\mathcal{B}$
Step7:  Note that the $\mathbf b_2$ component of ${}^\mathcal{I}\boldsymbol{\omega}^\mathcal{B} \times  \mathbf h_G$  is zero
Step8:  Define $C \triangleq \Omega + \dot\psi\sin\theta$ and substitute into $\left[\vphantom{\frac{\mathrm{d}}{\mathrm{d}t}}^\mathcal{I}\frac{\mathrm{d}}{\mathrm{d}t}  {}^\mathcal{I} \mathbf h_G\right]_\mathcal{B}$
Step9:  Assume an external torque generating moment about $G$ of $\mathbf M_G = -M_1\mathbf b_1$
<ASSISTANT_TASK:>
Python Code:
from miscpy.utils.sympyhelpers import *
init_printing()
th,psi,thd,psidd,thdd,psidd,Omega,I1,I2,t,M1,C = \
symbols('theta,psi,thetadot,psidot,thetaddot,psiddot,Omega,I_1,I_2,t,M_1,C')
diffmap = {th:thd,psi:psid,thd:thdd,psid:psidd}
Explanation: Dynamics of a Spinning Symmetric Rigid Body
End of explanation
bCa = rotMat(1,th);bCa
Explanation: Spinning Symmetric Rigid Body setup:  The body's orientation in inertial frame $\mathcal I$ is described by a 3-1-2 $(\psi,\theta,\phi)$ rotation:  the body is rotated by angle $\psi$ about $\mathbf e_3$ (creating intermediate frame $\mathcal A$), by an angle $\theta$ about $\mathbf a_1$ (creating intermediate frame $\mathcal B$), and finally spinning about $\mathbf b_2 \equiv \mathbf c_2$ at a rate $\Omega \equiv \dot\phi$, creating body-fixed frame $\mathcal C$. Note that while the body fixed frame is $\mathcal C$, all computations here are performed in $\mathcal B$ frame components.
${}^\mathcal{B}C^\mathcal{A}$:
End of explanation
iWb_B = bCa*Matrix([0,0,psid])+ Matrix([thd,0,0]); iWb_B
Explanation: $\left[{}^\mathcal{I}\boldsymbol{\omega}^\mathcal{B}\right]_\mathcal{B}$:
End of explanation
iWc_B = iWb_B +Matrix([0,Omega,0]); iWc_B
Explanation: ${}^\mathcal{I}\boldsymbol{\omega}^\mathcal{C} = {}^\mathcal{I}\boldsymbol{\omega}^\mathcal{B} + {}^\mathcal{B}\boldsymbol{\omega}^\mathcal{C}$. 
$\left[{}^\mathcal{I}\boldsymbol{\omega}^\mathcal{C}\right]_\mathcal{B}$:
End of explanation
IG_B = diag(I1,I2,I1);IG_B
Explanation: $\left[ \mathbb I_G \right]_\mathcal B$:
End of explanation
hG_B = IG_B*iWc_B; hG_B
Explanation: $\left[{}^\mathcal{I} \mathbf h_G\right]_\mathcal{B}$:
End of explanation
dhG_B = difftotalmat(hG_B,t,diffmap) + skew(iWb_B)*hG_B; dhG_B
Explanation: $\vphantom{\frac{\mathrm{d}}{\mathrm{d}t}}^\mathcal{I}\frac{\mathrm{d}}{\mathrm{d}t}  {}^\mathcal{I} \mathbf h_G = \vphantom{\frac{\mathrm{d}}{\mathrm{d}t}}^\mathcal{B}\frac{\mathrm{d}}{\mathrm{d}t}  {}^\mathcal{I} \mathbf h_G + {}^\mathcal{I}\boldsymbol{\omega}^\mathcal{B} \times  \mathbf h_G$.
$\left[\vphantom{\frac{\mathrm{d}}{\mathrm{d}t}}^\mathcal{I}\frac{\mathrm{d}}{\mathrm{d}t}  {}^\mathcal{I} \mathbf h_G\right]_\mathcal{B}$:
End of explanation
skew(iWb_B)*hG_B
Explanation: Note that the $\mathbf b_2$ component of ${}^\mathcal{I}\boldsymbol{\omega}^\mathcal{B} \times  \mathbf h_G$  is zero:
End of explanation
dhG_B_simp = dhG_B.subs(Omega+psid*sin(th),C); dhG_B_simp
Explanation: Define $C \triangleq \Omega + \dot\psi\sin\theta$ and substitute into $\left[\vphantom{\frac{\mathrm{d}}{\mathrm{d}t}}^\mathcal{I}\frac{\mathrm{d}}{\mathrm{d}t}  {}^\mathcal{I} \mathbf h_G\right]_\mathcal{B}$:
End of explanation
solve([dhG_B_simp[0] + M1,dhG_B_simp[2]],[thdd,psidd])
Explanation: Assume an external torque generating moment about $G$ of $\mathbf M_G = -M_1\mathbf b_1$:
End of explanation
<END_TASK>