Control

TagsControl

Basic physics

If you have a potential field, then you can create a conservative force by taking the negative gradient.

What is control?

Control is this: we have a target point and a current state. How do we get to this target?

We start with an equation of motion, like f=mx¨f = m\ddot x. This tells us how the system will respond, period.

Often, this equation of motion is not very interesting. What you really want might be to move this particle to a certain target. For this, you introduce a perturbance force, i.e. you derive some expression for ff.

Now, after you derive the expression for ff, you might get something like f(x,x˙)mx¨=0f(x, \dot x) - m\ddot x = 0. This gives us a new equation of motion. You can understand this as adding something to the existing system and changing its behavior. Commonly, ff depends on the distance from the goal and some speed component (viscous friction). We call this final formulation a closed-loop equation of motion.

Unactuated Systems

We want to work towards control, which involves putting an actuating force on the joints. But before we do that, let’s explore how unactuated systems behave. In these systems, we aren’t concerned with the force we apply FF.

The Spring and Damper system

It’s common to assume that we essentially set the target point and attach springs to the points (joints) and see what happens when we run time forward. We can imagine this as a simple mechanical system

The springs are often “damped” by some natural friction term.

Conservative systems

We can employ the Lagrange equation again. If we are not expecting to add any energy into the system

This gets us

And we know that V=(1/2)kx2V = (1/2)kx^2 with a derivative kxkx. The kinetic energy is (1/2)mv2(1/2)mv^2. The derivative is mvmv, and taking the time derivative again gets you mama. This gets yo uthe following equation of motion.

This gets you the following equation of motion:

mx¨+kx=0m\ddot x + kx = 0

This is actually a differential equation with a natural frequency ω=k/m\omega = \sqrt{k/m}. Meaning, the larger the mass, the slower the swing. The stiffer the spring, the faster the swing. We can model the path as

x(t)=ccos(ωnt+ϕ)x(t) = c * \cos(\omega_n t + \phi)

Dissipative systems

All you need to do is to add an external force into the Lagrange equation, which is the friction force.

If we care about viscous friction, i.e. fluid-based friction, it depends on velocity: f=bx˙f = -b\dot x. The force is negative because we must apply an opposing force. If we rearrange, we get the equation of motion.

mx¨+kx+bx˙=0m\ddot x + kx + b\dot x= 0

which we can rewrite as

x¨+kmx+bmx˙=0\ddot x + \frac{k}{m}x + \frac{b}{m}\dot x= 0

The damping comes from the velocity component, or b/mb/m. The oscillation frequency comes from ω2=k/m\omega^2 = k/m. We can create a new parameter (natural damping ratio) ξ\xi such that

ξn=b2ωnm=b2km\xi_n = \frac{b}{2\omega_n m} = \frac{b}{2\sqrt{km}}

Under this setup, we can rewrite the equation as the following:

x¨+2ξnωnx˙+ωn2x=0\ddot x + 2\xi_n\omega_n \dot x + \omega_n^2 x = 0

If you solve the differential equation, you’ll get the time response as

x(t)=ceξωtcos(ω1ξ2t+ϕ)x(t) = ce^{-\xi \omega t}\cos(\omega \sqrt{1 - \xi^2}t + \phi)

which gives you an interesting insight: if ξ=1\xi = 1, then the oscillation drops away. This is known as critical damping, and it depends on the parameters b,k,mb, k, m. At lower ξ\xi, we get under-damping, and at higher ξ\xi, we get overdamping (note that the time response changes; it’s no longer that function above)

More specifically, there are two things that you can change with these parameters

Robot Linear Control

Now, we are finally ready to talk about robot control. We have some setup

where we have a target, and we want to find the force to drive the current joint. We make it a simple prismatic for now. Let’s start with a simple, frictionless environment f=mx¨f = m\ddot x.

Now, we want to derive some controlling force FF that gets this actuator to the target while respecting the equation of motion.

Potential function

One way of deriving this controlling force is to start with a potential function.

V(x)=12kp(xxd)2V(x) = \frac{1}{2}k_p(x - x_d)^2

Because VV is a potential, the gradient is a conservative force. This is the force that is applied to the system. We know that the system follows an equation of motion, so we plug it in.

This gives us the control objective. A control objective gives the force FF given the current state of the system. In this case, we have

mx¨=F=kp(xxd)m\ddot x = F = -k_p(x - x_d)

Asymptotic stability

What does it mean for a system to be stable? Well, one thing we could consider is asymptotic stability, meaning that we approach a steady state as tt → \infty. As it stands, the previously described system is not stable; it oscillates.

Generally, the condition for asymptotic stability is

x˙TFd<0\dot x^TF_d < 0

We can easily satisfy this requirement by creating a dissipative force that is directly related to velocity, i.e. viscous friction.

which means that this dissipative force typically depends on x˙\dot x, like Fd=kvx˙F_d = -k_v \dot x. This allows us to formulate the following control objective

F=kp(xxd)kvx˙F = -k_p(x - x_d) - k_v \dot x

which gives us the Proportional-Derivative Control (PD)

PD Control

With the control being F=kp(xxd)kvx˙F = -k_p(x - x_d) - k_v \dot x, we plug this into the equation of motion to get

mx¨+kvx˙+kp(xxd)=0m \ddot x + k_v \dot x + k_p(x - x_d) = 0

Now, if we massage the equation and let ξ=kv/(2kpm\xi = k_v / (2\sqrt{k_p m} and ω=kp/m\omega = \sqrt{k_p / m}, then we get the following differential equation

x¨+2ξωx˙+ω2(xxd)=0\ddot x + 2\xi \omega \dot x + \omega^2(x - x_d) = 0

This is an equation we described in the dissipative systems section above, and we know how it responds. As before, if ξ=1\xi = 1, we get critical damping. Otherwise, we get overshooting / oscillation, or too slow.

The unit mass construction

We can just reverse the definitions of ξ,ω\xi, \omega and solve for kp,kvk_p, k_v. If we do this, we get kp=mω2k_p = m\omega^2 and kv=m(2ξω)k_v = m(2\xi\omega). Critically, notice that the controller gains are linear in the mass. Therefore, it’s possible to create a controller ff’ that assumes linear mass. Then, we have f=mff =mf’ once we know that mass of the system.

In other words, it’s possible to create an effective controller and scale it to any mass we need. If we don’t know the mass, we can estimate it. Here are some ways that you could get the gains

Nonlinear control

Let’s say that we have the robot joint again, but this time, there’s some friction term such that the equation motion is

How do we deal with this? Well, we could take the unit-mass controller and modify it to have

f=αf+βf = \alpha f' + \beta

where α=m^\alpha = \hat{m} and β=b^(x,x˙)\beta = \hat{b}(x, \dot x). We don’t necessarily assume we have access to the mass and friction, but we can have estimates. We’ll talk more about how we get these estimates later. If we estimate these components correctly, then the behavior of this nonlinear system will be identical to the behavior of the ff’ control under unit mass.

Also, note that this b^\hat{b} is constantly changing, so we need to edit our approximation. This gets us a control flowchart that looks like this

Moving towards motion control

We are getting closer to what we want in our control system: true motion control. What does this mean? Well, we want some system that allows us to input a desired trajectory, velocity, and accelerations x(t),x˙(t),x¨(t)x(t), \dot x(t), \ddot x(t) and get a controller that operates on the joints.

Previously, the unit mass controller ff’ had a target position. We can also add a target velocity and a target acceleration. This yields

and the closed-loop system

If we let e=xxde = x - x_d, then this is a second order system

that we know how to solve if we substitute the variables correctly. This gets us the following control loop

Disturbance rejection

The estimates of b^\hat{b} and m^\hat{m} can be inaccurate, which can create disturbances in the system that reduce stability. We can minimize these disturbances if we are smart about picking our gains. The larger the gain, the better we are at rejecting disturbances, because we are just operating in brute force mode.

Modeling the disturbance

Let’s assume that we can model this disturbance with some force fdistf_{dist}, which we can assume (potentially quite erroneously) that it is constant. This gets us the following equation of motion

and the following diagram

If we use the control structure as before, we actually see something pretty neat. Adding a constant force doesn’t change much; it just gets us a residual component in the closed loop behavior

Steady state error

If the closed loop system is at rest, then the equation becomes

which tells us that the steady state error of this stationary system is

What does this mean? Well, it tells us that the joint / manipulator will come to rest at a place that isn’t the target. This is because the controller isn’t prepared to handle this disturbance force, and so the equilibrium is achieved in an incorrect spot.

These results also tell us that higher kpk_p’s lead to smaller errors, as previously discussed. Now, we can’t make the gains too large, because it increases the closed loop frequency and the robot may start to chatter. So, how do we resolve this problem?

Integral control

We could make the gains higher, or we could add another element in the control equation, the “I” in the PID controller. This gets the controller

and the closed-loop behavior

If we take the derivative again, we get

which shows that the steady-state error equation has e=0e = 0, as desired.

PD for multi-link systems

Now, assuming that we had an IK solution and we are controlling in joint space, you can imagine little springs attached to each of the joints. This is in joint space control.

Now, you could just run a PD controller for each individual joint. And this works if we are moving sufficiently slow enough and don’t care too much about the intermediate points of the robot. This is because, given a sufficiently tuned controller, we will eventually reach the target position. However, as we saw previously in the equations of motion of a robot arm, joints can be coupled together, and they can also experience coriolis forces and centripital forces, etc. Therefore, no actuator is an island.

Or, more specifically, the PD controller at each joint would have a disturbance force as the following

Analysis on individual PD control

Let’s say that we didn’t accommodate these forces for now, or rather, we assume a robust enough controller with high gains and an integral control. What can we say?

Well, we start off with the torque equation

which is asymptotically stable because the forces are either conservative or dissipative.

Now, let’s show that this is truly stable. If we plug in the torque to the robot equation of motion (and use the fact that qqdq - q_d is a gradient of a potential field, we get

If we rearrange, we get

In essence, this additional control term is just another potential energy term. The τdissipative=kvq˙\tau_{dissipative} = -k_v \dot q. So we can imagine that this is just a robot coming to rest in a viscuous fluid.

Dynamic PD control (Nonlinear Dynamic Decoupling)

Decoupling is when you want to bring back the old equation of motion τ=Mq¨\tau = M \ddot q. In reality, we have this equation

Now, if you know v,gv, g, you can just subtract them from the controller to do the decoupling. That is what this looks like:

We implement this by using a torque controller on a unit mass (no coupling) and compensate

as long as we have an estimate of the different components. If you do this correctly, you’ll be able to send targets to all of the joints and prevent the other joints from unnecessary movement.

Operational Space Control

In task-oriented control (operational space control), you imagine a single spring added to the end of the robot

This gets you a potential field and an associated force at the end of the end-effector

Note that the force is negated because we are talking about the robot applying the force. We can use the jacobian to compute all the torques τ=JTF\tau = J^T F. This is much simpler than joint space control because we don’t have to worry about all the weird situations with joint coupling.

We can add an additional damping force by computing τd=JT(kvx˙)\tau_d = J^T(-k_v \dot x). The asymptotic stability condition is q˙Tτd\dot q^T \tau_d. If we put everything into joint space by using x˙=Jq˙\dot x = J\dot q, we get

The JTJJ^TJ is a positive definite matrix, so the quadratic form is positive. Therefore, as long as kv>0k_v > 0, the system is asymptotically stable.

Dynamics & Equations of Motion

We can write out the equations of motion in operational space as follows:

Now, how are these quantities related to the joint space quantities? Well, we can use the fact that Kq=12q˙TMq˙K_q = \frac{1}{2}\dot q^TM\dot q and that Kx=12x˙TMxx˙K_x = \frac{1}{2}\dot x^T M_x \dot x, but these quantities are equal. We also know that x˙=Jq˙\dot x = J \dot q. Putting all of this together, we get that

In summary, these relationships are

So if you know the mass matrix and the other quantities from joint space control, you can turn it into operational space control.

If you put this into the whole control framework, this looks like the following:

Velocity saturation

In joint space, you didn’t have to worry too much about having a really far-away target. But in operational space control, you could definitely have a situation where your target is far away and you don’t want the robot to move super quickly. You can do this by adding another control on the velocity. Just keep the direction and shrink the magnitude.

Compliant motion

Compliant motion is when you have motion that gets force feedback, i.e. you want to trace a surface with a robot. It’s a complicated subject, but the high level is that you turn down the gains of the controller in one direction. If you turn it completely down, that direction just becomes a damping system.