Dynamics

TagsDynamics

Physics background

Math review

When we have d/dtcos(θ)d/dt \cos(\theta), we get sin(θ)θ˙-\sin(\theta)\dot \theta. Make sure that you follow the chain rule completely.

Lagrange equation

We let the Lagrange L=KVL = K - V. IT turns out that this formulation allows for a critical result.

This critical result is derivable from Newton’s equations and a lot of math.

In other words, the force into the system can be purely modeled in a differential equation. If there is no force, then the Lagrange equation’s right hand side is zero. This is critical because it allows us to describe a complicated system through time

For a degenerate example, if we are working with a particle in the z direction, we have L=1/2mv2mgxL = 1/2 mv^2 - mgx. When left without any perturbing forces, we have mamg=0ma - mg = 0, meaning that a=ga = g. This means that the particle accelerates downwards, as desired! But we can move this to any arbitrary system with high complexity. We just need to formulate the Lagrange, and solve the differential equation.

Why do we care about dynamics?

Dynamics is all about finding the forces, velocities, and accelerations on each link of a robot arm. It’s not as easy as you might think: forces on one joint will propagate to all other joints in a process known as “inertial coupling.”

The two approaches

The newton-euler algorithm derives velocities, acclerations, and dynamic forces through a forward propagation, and then backpropagates through the structure to find moments. This is rather complicated and we tend not to use this formulation.

The Lagrange formulation relies on energy and involves the mass matrix explicitly.

Both ways of understanding dynamics yields the same final equation:

M(q)q¨+v(q,q˙)+g(q)=τM(q)\ddot q + v(q, \dot q) + g(q) = \tau

These are called the equations of motion . An equation of motion is a differential equation. When solved, it allows you to compute the exact paths. Or, you can potentially solve the equation one way to derive the accelerations on the joints given the velocities and the positions, etc. There’s a lot we can do, and we’ll get to them later.

Newton-Euler

💡
The idea of an inertial tensor and momentum setup is what you should be taking out of this. For the actual equation of motion, refer to the Lagrange

There are two parts of this formulation. Newton’s equation tells us about linear motion, and Euler’s equation tells us about angular momentum and inertial tensor.

Linear and angular momentum relationship to force, moment

Let’s start with the motion of a single point.

Newton’s law tells us that F=maF = ma, which means that ddt(mv)=F\frac{d}{dt}(mv) = F. Turns out, mvmv is momentum, so you can understand force as a change in momentum (shouldn’t be news to you).

Angular momentum is a bit more complicated, but it’s the same as anything angular that we’ve done so far. Angular momentum is just p×mvp\times mv, which is the rotational analog of linear momentum. We take the derivative and apply the product rule to get

which is the applied moment NN.

Euler Equation

We extend our analysis from a single point to a collection of points. Let’s compute the angular momentum of any rigid body. We start with some knowns

Putting this together, we get that the angular momentum Φ\Phi of any rigid body is

The integral version is

where ρ\rho is density. This is a formulation that gives the angular momentum of any object.

We can replace the cross product with the operator to get

Now, the quantity inside the bracket is a matrix, and it is called the inertial tensor which we denote with an II. So, we can still write the angular momentum of the whole rigid body as

Φ=Iω\Phi = I\omega

As expected, when we take the time derivative, we get the moment NN

Notice that this gets you an equation of motion, relating applied force to acceleration.

Inertial tensor

As we hinted at, the inertial tensor is an integral defined as

Now this is the 3d analog of a MOI calculation which is r2dm\int r^2 dm. We can write the quantity p^p^-\hat{p}\hat{p} as

so the inertial tensor can be rewritten as

If pp uses a cartesian representation, the matrix is

If you want, you can integrate each component separately. The on-diagonal components are called moments of inertia, and the off-diagonal components are called products of inertia. These products of inertia tell us something interesting: there is typically some coupling between the different axes of rotation.

MOI, POI

The inertial tensor is a symmetric matrix with some interesting properties.

The MOI is the diagonal components of the inertial tensor. This represents the inertias that you’ll encounter when you rotate the object along the fixed axes. By definition, they must be positive

The POI are the off-diagonal components of the tensor, which can be positive or negative. Their actual values are less meaningful, but they can tell us something. Namely, they are non-zero only if the mass is distributed unevenly around the axis. The xz direction looks at imbalance in the xz plane, the xy direction in the xy plane, etc. This happens if you offset the reference axes from the center of mass.

This tells us something interesting: there is definitely some point on any object that yields a diagonal inertial tensor. The parallel axis theorem tells you how the off-diagonals change when you move that axis around.

Parallel Axis Theorem

Turns out, you can just find the inertial tensor at the center of mass and translate it into a new frame.

If the frame is parallel to the center of mass (i.e. just one translation), then we get

And if there is some rotation, we use the old trick of going in and out of that space

Lagrange Formulation

The Lagrangian is the difference between kinetic and potential energy of mechanism: L=KVL = K - V. This VV is a function of qq only, and this KK is a function of q,q˙q, \dot q. We discuss this formulation above.

💡
For more on this, look at this: https://mathworld.wolfram.com/Euler-LagrangeDifferentialEquation.html. You can imagine this torque as adding energy into the system. If there is no energy, the torque is zero.

Logistically, you let q˙\dot q be the variable (for example, it could be vv), you take the derivative, and then you treat this q˙\dot q as a derivative again and take the derivative through time. We’ll open up an example later.

And because potential energy only depends on qq, we can reformulate it as

The term dV/dqdV/dq is a gravity vector and should be pretty easy to derive. The first two terms are inertial forces. Together, this forms an equation of motion.

Inertial Components

We can express the kinetic energy as a quadratic form with the mass matrix (see below sections)

If you choose to take the derivative WRT q˙\dot q, we get

And then we take the derivative through time using the product rule (note that it is not just Mq¨M \ddot q)

As for K/q\partial K/\partial q, we realize that the only thing dependent on qq is the mass matrix. This gets you a gradient of the form

Putting it all together, we get that the equation of motion is of the following form:

which we can rewrite into Mq¨+V(q,q˙)M \ddot q + V(q, \dot q) where the last two terms are grouped together.

Writing out kinetic energy in explicit form

What if you don’t have the mass matrix? We’ll talk about the mass matrix below. But you can also assemble it iteratively. First, note that K=12q˙TMq˙K = \frac{1}{2}\dot q^T M \dot q, but because energy is a scalar, we can also just say that the energy is the sum of the energies at each joint.

At each joint, the kinetic energy is just the sum of the linear and the angular velocities, which can be expressed as the following:

which means that you can build up the kinetic energy function iteratively. The velocities can be derived from the joint velocities through the Jacobian, so we get

Now, what are these Jacobians? Well, the velocity of any center of mass does not depend on any joints afterwards! So the Jacobians are zeros for anything after that joint. Otherwise, we just take the derivative of the COM functions of q

Gravity Component

💡
There is only ONE negative sign that references the negative direction of gg because the FF in JTFJ^TF is already applied force.

To complete the Lagrange formula, we need the gravity vector and dV/dqdV/dq. It helps to realize that we can add the potential of each COG

The potential energy is really easy to formulate. We can just have

where hh is the height of the center of gravity. This is also the projection of the gravity force along the direction.

If we take the gradient of this expression WRT qq, it’s very similar to computing the Jacobian. Indeed, you’ll get the form

Here’s another way of interpreting the gravity component. Recall that the GG is in units of torque. But we already know how to calculate static torque! Just use the fact that τ=JTF\tau = J^TF and add up the individual torques

This actually gets you the exact same formulation

Mass Matrix

💡
All calculations MUST be in references to the center of mass (even if the frames of reference aren’t the same in all parts of the summation). If you’re not in the center of mass, the linear mass calculations are off.

Sometimes, linear velocity component is zero. But just because the frame is around the COM doesn’t mean that the rotational component is zero, as there c an be moments of inertia.

When you calculate each joint, you only include the contributions of the links before it.

The mass matrix tells us how different joints influence different torques. In a static setting, Mq¨=τM\ddot q = \tau. Of course, this changes in the dynamic setting, but this tells us that there may be an interdependence between joints, held by the off-diagonal terms. The Lagrange formulation used this MM in the motion equations. Now, let’s talk about how we might compute it explicitly.

The mass matrix is symmetric, which is interesting. This tells us that if one joint influences another joint, then the other joint should also influence the original joint in the same way. The diagonal components of the mass matrix must be positive because of Newton’s law. The off-diagonal components can be negative because it just says that one torque has a negating effect on the other joint.

Explicit formulation

Previously, we asserted that the kinetic energy can be expressed as a summation.

We can just rearrange this to become

which indicates that

This gives us everything we need to explicitly compute a mass matrix. Make sure that the JωiJ_{\omega_i} and the ICiI_{C_i} are in the same reference frame. This JωJ_{\omega} need not to be in the same frame as JvJ_v. Indeed, usually JvJ_v is best represented in frame 0, while Jw needs to be in the frame of the inertial tensor. Different JvJ_v in the summation can also have different frames of reference.

Centrifugal and Coriolis Forces

In the Lagrange formulation, we had the vv component as follows.

This is actually a sum of centrifugal and Coriolis forces. Let’s dive deeper into what we mean.

Cristofel Symbols

The mass matrix element mijm_{ij} could depend on qq. We denote the partial derivative WRT qkq_k as the (slightly confusing)

We the Christoffel symbol defines

This sounds weird, but we’ll see why it exists in a second.

We also note that m˙ij\dot m_{ij} can be computed by the chain rule

Building from a 2d example

We want to create a general case for this V(q,q˙)V(q, \dot q), but it actually helps to start from a 2d example

which gets us

using the formulation that we previously discussed. If we multiply everything out, we see that there’s actually a special structure

where [q˙1q˙2][\dot q_1 \dot q_2] is a single number. This is where the previously-defined Christoffel symbols come in: we can replace this messy setup with. This gets you

and this is precisely the centrifugal and Coriolis contributions. This first matrix is related to the squared velocities, and so we have the Centrifugal forces. The second matrix is the Coriolis contrigution.

General case

We can this v(q,q˙)v(q, \dot q) as the follows:

where q˙2\dot q^2 is just element-wise squareing, and q˙q˙\dot q \dot q is the pairwise products of all joint velocities of size (n1)n/2(n -1)n/2

The general form of the matrix is

Building Intuition

Of course, the question becomes this: we’re seeing a lot of math, but what does it actually mean? Well, let’s consider this arm and a closed-form derivation.

Deriving mass matrix

We start by writing the mass matrix in explicit form:

And we can derive each Jacobian because we have the explicit position parameterization

which yields the Jacobians

Now, if we just shove everything into the formula, we get

We can compute the angular jacobians, which have a very simple form

Which gives us the following products

And when we finally put everything together, we get the mass matrix

This tells us that the two joints are not coupled, which makes sense.

Coriolis vector

If we follow the formula described above, we get the following format:

Gravity vector

We can just compose all of the forces on each joint,

We use frame 0 to be convenient. After doing this composition, we get

Putting it all together

The equations of motion look complicated, but it’s completely closed form. We can relate desired velocities and accelerations with joint torques

Debrief: the general steps

  1. Compute the Jacobians for each joint
  1. Use it to find the mass matrix
  1. Use the mass matrix to compute VV
  1. Compute the gravity vector separately
  1. Add everything together