# Calculating C for a 6-DOF robotic arm

I've seen this equation for calculating the dynamics of a robotic arm a bunch:

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

Now, I believe I have the ${M}$ and ${G}$ terms calculated properly (though not through single matrices, which perhaps is an error in itself) as well as a reasonably good PID controller, so I've been researching how to get ${C}$, which represents both centrifugal and Coriolis effects. My robot is pretty unstable without it, but I cannot figure out how to compute it. I don't have access to MATLAB; I'm using C++ with ROS and MoveIt!, so I can easily get the Jacobians and many other features of my robot.

Can anyone help me out? Everyone seems to just be saying along the lines of "Now calculate ${C}$..."

• Are you familiar with the Euler-Lagrange equation? Commented Jan 10, 2018 at 17:21
• @fibonatic I can become familiar with it. Could you please walk me through exactly how it applies? Commented Jan 10, 2018 at 17:38
• I'm familiar with the fact that there are two methods of calculating these terms -- the Newton-Euler method and the Lagrangian approach, but I have not really heard of the Euler-Lagrange equation. Commented Jan 10, 2018 at 17:42
• the Euler-Lagrange equation is just another name for Lagrangian mechanics. Commented Jan 10, 2018 at 19:03
• Yeah, if you don't have a symbolic representation for $M$ then the approach I cited won't help. You might want to check out Chapter 6 of Paul's book Robot Manipulators, in which he computes the Dynamics matrix $D$ using individual link masses instead of $M$. Commented Jan 11, 2018 at 14:41

Chapter 4 of this Cal tech paper derives C based on partial derivatives of the inertia matrix M and joint velocities. I think their explanation, which is based on Lagrangian dynamics, is pretty clear.

• I see... equations 4.29 and 4.30 are particularly enlightening to me (though I've seen 4.29 before, but not 4.30). Unfortunately, I understand extremely little of the notation in 4.30. I believe I understand how to get the twists, and I know how to transpose a matrix, but after that I'm pretty baffled. I don't understand the definition of A, I don't even see a definition for... cursive A?, and I haven't the foggiest idea what the double arrows and line subscripts are. A d keeps popping up everywhere... Do you think you could point me to a resource that would help me grok this? Commented Jan 10, 2018 at 21:47
• (thank you for your response, by the way; couldn't fit that into my last comment) Commented Jan 10, 2018 at 21:50
• @RiverTam - It looks like Equation 4.23 gives you the explicit definition for C and 4.11 gives the results of an actual example.
– Chuck
Commented Jan 10, 2018 at 22:15
• @Chuck Equation 4.29 gives the same definition, and 4.11 is for a specific, relatively simple case (where they don't use the general definition). I'm not sure how I could use 4.11 to help me derive C for a 6 DOF robot in 3 dimensions... They seem to be using the "hard-coded" equations for kinetic energy in two dimensions. This is not such a simple problem for me... Commented Jan 10, 2018 at 22:34
• I don't have it in front of me, but I remember Paul's book walking through the entire Lagrangian dynamics formulation in general, then applying it. Commented Jan 10, 2018 at 22:36

If you're calculating the moment of inertia for each link relative to each joint, then that's M! The only "tricky" thing to be aware of is that the moments of inertia compound - you must take into account the subsequent joints.

• Thanks for your help by the way. Yes, I'm including the moments of inertia for each subsequent joint. I suppose what I have does look like a matrix with all zeroes on one side of it -- it didn't occur to me that that is M (I'm representing it in C++ as a std::vector<std::vector<double>> where the inner vectors are of length 6 - i). I suppose, then, I do have M, but I don't have an equation for M. I'm using MoveIt! to get the distances and using an iterative process to calculate these terms, so I'm not sure how I could efficiently compute a partial derivative of this process. Commented Jan 11, 2018 at 14:57