I am trying to simulate a 2-DOF planar robotic manipulator (have its joints follow a predefined trajectory) that's described by its dynamic model:
$$ M(q)\ddot{q}+C(q,\dot{q})\dot{q}+G(q) = \tau $$
where $q = [q_1 \ q_2]^T $ are the angles of the two joints, $\dot{q}$ the angular velocities and $\ddot{q}$ the angular accerations of the joints. In order to simulate it, I convert it into its state-space representation (matrix $M$ is positive definite) by defining the state variables $x=[q_1 \ \dot{q_1} \ q_2 \ \dot{q_2}]^T$.
$$\dot{x_1} = x_2 $$ $$\dot{x_2} = -M^{-1}(1,:)\cdot [C\dot{q} + G] + M^{-1}(1,:)\tau $$ $$\dot{x_3} = x_4 $$ $$\dot{x_4} = -M^{-1}(2,:)\cdot [C\dot{q} + G] + M^{-1}(2,:)\tau $$
In order to close the loop, I have designed a prescribed performance controller, which uses performance functions making the whole system of the differential equations stiff. I managed to simulate the system by using the ode15s(...)
MATLAB solver by setting its tolerances as follows:
$$\text{RelTol = 1e-6} $$ $$\text{AbsTol = 1e-10} $$
However, in order to simulate the system I had to select a really large value for a controller gain $K$, which appears at the numerator of the controller expression:
$$ u = \frac{K\gamma(p-\Delta)s_i}{\dot{T}(w_{sq}-1)} $$
where $p$ is the performance function, $T$ is a strictly increasing function $T:(-1,1) \rightarrow \mathbb{R}$ and $\gamma, \Delta, s_q, w_{sq}$ some signals. I am wondering about the selection of the options for the ODE-Solver. My wish would be to try and select the least possible value for the gain $K$ of the controller.
What do the solver's tolerances mean practically or would it really be a good idea to provide the solver with the Jacobian matrix of the differential equations I want to simulate (cause I know the solver approximates it using Finite Differences)? I know this could be really hard and large to answer, so any possible proposal about a decent resource where I could read about these aspects (other than the matlab documentation) would be really appreciated.
ode15s
doesn't converge? Is there anything preventing you from computing the Jacobian? Unless your mass matrix is very simple, I would recommend using theMass
option forodeset
so the inverse of the mass matrix doesn't make the Jacobian any more complex. $\endgroup$