Mass matrix second order differential equation to first order ODEs

jacobianMATLABordinary differential equations

I want to simulate the behaviour of a 2-DOF robotic manipulator, which is described by the following model:

$$ M(q)\ddot{q} = -C(q,\dot{q})\dot{q}-G(q)+\tau \ \ \ \ \ (1) $$

Considering the fact that the $\text{2×2}$ mass matrix $M$ is positive definite, I could use the inverse matrix and break down the problem into the $4$ first order ordinary differential equations and simulate it:

$$ x_1 = q_1 \Rightarrow \dot{x_1} = x_2 $$
$$ x_2 = \dot{q_1} \Rightarrow \dot{x_2} = -M^{-1}(1,:)\cdot C\cdot \begin{bmatrix} x_2 & x_4 \end{bmatrix}^{T}-M^{-1}(1,:)\cdot G + M^{-1}(1,:)\cdot \tau $$
$$ x_3 = q_2 \Rightarrow \dot{x_3} = x_4 $$
$$ x_4 = \dot{q_2} \Rightarrow \dot{x_4} = -M^{-1}(2,:)\cdot C\cdot \begin{bmatrix} x_2 & x_4 \end{bmatrix}^{T}-M^{-1}(2,:)\cdot G + M^{-1}(2,:)\cdot \tau $$

Suppose I would like to use a solver that takes as an argument the mass matrix (a MATLAB ODE solver in particular) and don't use its inverse because this will also simplify the computation of the jacobian (I intend to simulate a 7-DOF robotic manipulator after that so providing the mass matrix would be great). How can I write the initial equation $(1)$ as a series of first order ordinary differential equations and be able to simulate its response by using some software solvers ?

Best Answer

Let us choose $\eta = \begin{bmatrix} q & \dot{q} \end{bmatrix}^\top$. Then $$\begin{bmatrix} I & 0\\ 0&M(q) \end{bmatrix}\dot{\eta} = \begin{bmatrix} 0 & I \\ 0 & -C(q,\dot{q})\end{bmatrix}\eta + \begin{bmatrix} 0 \\ -G(q) + \tau \end{bmatrix}.$$

Related Question