I'm working on a masters thesis and need to calculate Mass inertia matrix ($M$), Coriolis/Centrifugal matrix ($C$), and the gravity matrix ($G$) in the equation $M\ddot{\theta} + C\theta + G = \tau$ (to get the dynamic model). I'm trying to calculate PD control in matlab, but I'm unsure if I need to calculate $M$, $C$, $G$ for every orientation of the robot as it moves. I assume so, but I don't want to code it and then find out I didn't need to. Please advise.

  • $\begingroup$ You have to compute them. Have a look at this example and this. $\endgroup$
    – CroCo
    Jul 20, 2017 at 18:42

1 Answer 1


You haven't included a diagram of your robot, so I don't know how big or complex these matrices are to calculate, but I would argue that you might not need to constantly recalculate the values if your controller isn't sensitive to the parameter changes.

At the master's level, I would hope you have a good grasp on dynamics and kinematics and would be able to know what the "best" and "worst" case scenarios are for loading on your joint(s). For example, an arm that is fully extended would provide maximal torque to a shoulder joint, and arm that is curled up would provide the minimal torque to the shoulder joint.

Calculate your matrices at the nominal or average use case, then calculate your gains for that case. Then, calculate your matrices at the minimum and maximum use cases and compare performance with the nominal gains. This is referred to as a sensitivity analysis.

If you can prove that there is a "negligible" difference in performance between the min/max cases when you use the nominal control gains, then you're in the clear. If you fail this test (if there is a "non-negligible" difference in performance) then you need to calculate the system parameters in order to maintain satisfactory performance.

A couple notes:

  1. Be careful with PD control - the integral term I is what eliminates steady-state error. Derivative control is highly sensitive to noise.
  2. If you're going to go through the effort of modelling the system ("plant"), then you may want to consider using a more advanced control mechanism like a state feedback controller.
  3. On that note, also be careful with the state feedback controllers - they are for use with Linear, Time-Invariant (LTI) systems. LTI means that your model must be linear and the only thing that is allowed to change with respect to time is the state vector. I would suggest you look at LQR control for nonlinear systems.
  4. Finally, with regards to calculating the new matrices with every orientation, I would suggest you read more about Jacobian matrices. The Jacobian is basically a vector of vectors (matrix) that gives the mathematical expression for how a particular value changes when the underlying parameters change. It's a matrix of partial differentials, and you can use it to find how each of your control matrices changes when things like the joint angles change. A change of XX percent on a particular joint causes a YY percent change in your matrix, etc.
  • $\begingroup$ One can also design a controller for the system linearized at some point and then use something like a Lyapunov function to check stability for all other states. $\endgroup$
    – fibonatic
    Jul 23, 2017 at 5:28
  • $\begingroup$ @fibonatic - true, but there's an ocean between stability and desired performance. $\endgroup$
    – Chuck
    Jul 23, 2017 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.