
constraint equations translation
\begin{align*}
&\mathbf R_1+ \mathbf S_1\, \mathbf u_1-\left(\, \mathbf R_2+ \mathbf S_2\, \mathbf u_2\,\right)= \mathbf 0\tag 1
\end{align*}
where $~ \mathbf S_i~$ are the transformation of the body fixed coordinate system to inertial system
equations rotation
\begin{align*}
\mathbf\omega_2=\mathbf\omega_1+ \mathbf n\,\dot\psi\tag 2
\end{align*}
$~ \mathbf n~$ is the hinge axis
thus the generalized coordinate are the three positions of body 1 $~( \mathbf R_1)~$ three angular velocity $~\mathbf\omega_1~$ of body 1 ,plus the angular velocity ($~\dot\psi)$
with:
\begin{align*}
&\mathbf{\dot{S}_i}= \left[\mathbf\omega\right]_\times\,\mathbf S_i\,\quad\Rightarrow\\
&\mathbf\omega_i= \mathbf J_i\, \mathbf{ \dot{\phi}_i}\quad i=1,2 \quad,
\mathbf{ \dot{\phi}_i}= \mathbf{ J}_i^{-1}\mathbf\omega_i
\end{align*}
from the above you can obtain the kinematic equations
\begin{align*}
& \mathbf R_1= \mathbf R_1(t)\quad, \mathbf \omega_1= \mathbf \omega_1(t)\quad, \dot\psi=\dot\psi(t)\\
&\Rightarrow\\
&\mathbf\omega_2(t)=\mathbf\omega_1(t)+ \mathbf n\,\dot{\psi}(t)\\
&\mathbf{\dot{\phi}_i}=\mathbf{J}_i^{-1}\mathbf\omega_i(t)\\\\
&\text{from Eq. (1)}\\\\
&\mathbf R_2(t)=\mathbf R_1(t)+ \mathbf S_1(t)\, \mathbf u_1- \mathbf S_2(t)\, \mathbf u_2
\end{align*}
Example 2D
\begin{align*}
&\mathbf R_1=\begin{bmatrix}
x(t) \\
y(t)\\
0 \\
\end{bmatrix}\quad,
\mathbf S_1=\left[ \begin {array}{ccc} \cos \left( \varphi _{{1}} \right) &-\sin
\left( \varphi _{{1}} \right) &0\\ \sin \left(
\varphi _{{1}} \right) &\cos \left( \varphi _{{1}} \right) &0
\\ 0&0&1\end {array} \right]\quad,
\mathbf S_2=\left[ \begin {array}{ccc} \cos \left( \varphi _{{2}} \right) &-\sin
\left( \varphi _{{2}} \right) &0\\ \sin \left(
\varphi _{{2}} \right) &\cos \left( \varphi _{{2}} \right) &0
\\ 0&0&1\end {array} \right]\\
&\mathbf{u}_1=\left[ \begin {array}{c} u_{{{\it x1}}}\\ u_{{{\it
y1}}}\\ 0\end {array} \right]
\quad,
\mathbf{u}_2= \left[ \begin {array}{c} u_{{{\it x2}}}\\ u_{{{\it
y2}}}\\ 0\end {array} \right]\\
&\mathbf{\omega}_1=\left[ \begin {array}{c} 0\\ 0\\
\omega \left( t \right) \end {array} \right]
\quad,
\mathbf{n}=\begin{bmatrix}
0 \\
0 \\
1 \\
\end{bmatrix}\quad \dot{\varphi}_1=\omega(t)\quad, \varphi_1(t)=\int\omega(t)\,dt\\
\quad\Rightarrow\\
&\mathbf{\omega}_2= \left[ \begin {array}{c} 0\\ 0\\
\omega \left( t \right) +{\frac {d}{dt}}\psi \left( t \right)
\end {array} \right]
\quad,
\dot{\varphi_2}=\omega(t)+\dot{\psi}(t)\quad,\varphi_2(t)=\int ...\,dt\\\\
&\mathbf{R}_2=\left[ \begin {array}{c} x \left( t \right) +\cos \left( \varphi _{{1
}} \right) u_{{{\it x1}}}-\sin \left( \varphi _{{1}} \right) u_{{{\it
y1}}}-\cos \left( \varphi _{{2}} \right) u_{{{\it x2}}}+\sin \left(
\varphi _{{2}} \right) u_{{{\it y2}}}\\ y \left( t
\right) +\sin \left( \varphi _{{1}} \right) u_{{{\it x1}}}+\cos
\left( \varphi _{{1}} \right) u_{{{\it y1}}}-\sin \left( \varphi _{{2
}} \right) u_{{{\it x2}}}-\cos \left( \varphi _{{2}} \right) u_{{{\it
y2}}}\\ 0\end {array} \right]\\
&\mathbf v_2=\frac{d}{dt}\mathbf R_2(t)\quad,
\mathbf a_2=\frac{d}{dt}\mathbf v_2(t)
\end{align*}
3D and 2D
assume that the hinge rotation axis is fixed with body 1
input
$~x(t)~,y(t)~,z(t)~,\phi_x(t)~,\phi_y(t)~,\phi_z(t),~\psi(t)$
output
$~\mathbf{R}_2(t)~,\mathbf{S}_2(t)$
the equatiuons are:
\begin{align*}
&\mathbf{R}_2=\mathbf{R}_1+\mathbf{S}_1\,\mathbf{u}_1-\mathbf{S}_2\,\mathbf{u}_2\quad,\text{where}\\
&\mathbf{S}_2=\mathbf{S}_1\,\mathbf{S}_h(\mathbf{n}~,\psi)
\end{align*}
the hinge transformation matrix $~\mathbf S_h~$ you can use the rodriguez matrix
the velocity $~\mathbf v_2~$ and angular velocity $~\mathbf \omega_2~$
\begin{align*}
&\mathbf{v}_2=\mathbf{\dot{R}}_1+\mathbf{\dot{S}}_1\,\mathbf{u}_1-
\mathbf{\dot{S}}_2\,\mathbf{u}_2\\
&\mathbf{\omega}_2=\mathbf{\omega}+\mathbf{ S}_1\,\mathbf{\omega}_h\quad,\text{where}\\\\
&[~\mathbf \omega]_\times=\mathbf{\dot{S}}_1\,\mathbf S_1^T\quad,
[~\mathbf \omega_h]_\times=\mathbf{\dot{S}}_h\,\mathbf S_h^T
\end{align*}
Example
\begin{align*}
&\phi_x=3\,t~,\phi_y=t~,\phi_z=5\,t~,\psi(t)=10 t\\
&x=y=z=3\,t\quad,\dot{x}=\dot{y}=\dot{z}=3\\
&\mathbf n= \begin{bmatrix}
1 & 0 & 0 \\
\end{bmatrix}^T\quad,\Rightarrow\\
\\
&\mathbf S_1=\mathbf S_x(\phi_x)\,\mathbf S_y(\phi_y)\,\mathbf S_z(\phi_z)\quad,\mathbf{\dot{S}}_1=\frac{d}{dt}\,\mathbf S_1(t)\\\
&\mathbf S_h(\mathbf n,\psi)=\left[ \begin {array}{ccc} 1&0&0\\ 0&\cos \left(
\psi \right) &-\sin \left( \psi \right) \\ 0&\sin
\left( \psi \right) &\cos \left( \psi \right) \end {array} \right]
\quad,\mathbf{\dot{S}}_h=\frac{d}{dt}\mathbf S_h(\mathbf n,\psi) \\\\
&\mathbf\omega= \left[ \begin {array}{c} 3+5\,\sin \left( t \right)
\\ \cos \left( 3\,t \right) -5/2\,\sin \left( 2\,t
\right) -5/2\,\sin \left( 4\,t \right) \\ \sin
\left( 3\,t \right) +5/2\,\cos \left( 4\,t \right) +5/2\,\cos \left(
2\,t \right) \end {array} \right]
\\
&\omega_h=\dot{\psi} \\\\
&\mathbf R_2(t)=\ldots\quad,\mathbf S_2(t)=\ldots\\
&\mathbf v_2(t)=\ldots\quad,\mathbf\omega_2(t)=\ldots
\end{align*}
\begin{align*}
&\text{Rodriguez transformation matrix }\\
&\mathbf{S}_h= \mathbf{I}_3+\sin(\psi)\,[\mathbf{n}]_\times+
(1-\cos(\psi)) [\mathbf{n}]_\times\,[\mathbf{n}]_\times\\
&\mathbf{\omega}_h=\dot{\psi}\,\mathbf{n}\quad,\mathbf{n}\cdot\mathbf{n}=1
\end{align*}
how to obtain the angular velocity $~\mathbf\omega~$ from the rotation matrix $~\mathbf S~$ between the body and inertial system
\begin{align*}
&\dot{\mathbf{S}}=[\mathbf\omega]_\times\,\mathbf{S}\quad\Rightarrow
\begin{bmatrix}
0 & -\omega_z & \omega_y \\
\omega_z & 0 & -\omega_x \\
-\omega_y & \omega_x & 0 \\
\end{bmatrix}
=\dot{\mathbf{S}}\,\mathbf{S}^T \\
&\textbf{Example}\\
&\mathbf{S}=\left[ \begin {array}{ccc} 1&0&0\\ 0&\cos \left(
\phi \right) &-\sin \left( \phi \right) \\ 0&\sin
\left( \phi \right) &\cos \left( \phi \right) \end {array} \right] \quad,
\dot{\mathbf{S}}=\dot{\varphi} \left[ \begin {array}{ccc} 0&0&0\\ 0&-\sin \left(
\phi \right) &-\cos \left( \phi \right) \\ 0&\cos
\left( \phi \right) &-\sin \left( \phi \right) \end {array} \right]\quad\Rightarrow\\
&\begin{bmatrix}
0 & -\omega_z & \omega_y \\
\omega_z & 0 & -\omega_x \\
-\omega_y & \omega_x & 0 \\
\end{bmatrix}=
\begin{bmatrix}
0 & 0 & 0 \\
0 & 0 & -\dot{\varphi} \\
0 & \dot{\varphi} & 0 \\
\end{bmatrix}\quad,\vec{\omega}=\begin{bmatrix}
\dot{\varphi} \\
0 \\
0 \\
\end{bmatrix}
\end{align*}