\[\newcommand{\vect}[1]{\underline{#1}} % vector \newcommand{\mat}[1]{\mathbf{#1}} % matrices \newcommand{\est}[1]{\hat{#1}} % estimate \newcommand{\err}[1]{\tilde{#1}} % error \newcommand{\pd}[2]{\frac{\partial{#1}}{\partial{#2}}} % partial derivatives \newcommand{\transp}[1]{#1^{T}} % transpose \newcommand{\inv}[1]{#1^{-1}} % invert \newcommand{\norm}[1]{|{#1}|} % norm \newcommand{\esp}[1]{\mathbb{E}\left[{#1}\right]} % expectation \newcommand{\identity}[0]{\mathbb{I}} % identity\]

Solid Dynamics

Kinematics

Translational Dynamics

\[\dot{\vect{V}} = \frac{1}{m} \left( F^w + \transp{\begin{pmatrix} 0 & 0 & mg \end{pmatrix}} \right)\]

Rotational Dynamics

\[\dot{\vect{\Omega}} = \inv{\mat{J}} \left( \vect{M}^b - \vect{\Omega} \wedge \mat{J} \vect{\Omega} \right)\]

Code

def solid_cont_dyn(X, F_b, M_b, P):
    Xd = np.zeros(sv_size)
    p_w, v_w, q_w2b, om_b = X[sv_slice_pos], X[sv_slice_vel], X[sv_slice_quat], X[sv_slice_rvel]
    # Translational kinematics
    Xd[sv_slice_pos] = v_w
    # Newton for forces
    R_w2b =  pal.rmat_of_quat(q_w2b)
    Xd[sv_slice_vel] = 1./P.m*(np.dot(R_w2b.T, F_b) + [0, 0, P.m*P.g])
    # Rotational kinematics
    Xd[sv_slice_quat] = pal.quat_derivative(q_w2b, om_b)
    # Newton for moments
    Xd[sv_slice_rvel] = np.dot(P.invJ, M_b - np.cross(om_b, np.dot(P.J, om_b)))
    return Xd

link

Multirotor