[ODE] Better way to find 'Desired Velocity'

Royce Mitchell III royce3 at ev1.net
Fri Jan 28 17:16:15 MST 2005

Andrew Schroeder wrote:

>I'm thinking that the equation 
>DesiredVelocity = Error * Gain
>is actually NOT a simple P-Gain situation that you are saying I should
>start with.  I think this because the Input (Error) is in POSITION,
>and the output is in VELOCITY, thus with the above equation we
>actually set an Integrated Controller, we have a simple I-Gain,
>instead of the recommended P-Gain.
>Is my thinking correct on this? If so is there a way to create a
>simple P-Gain like you suggest without setting the position directly?
>(obviously I don't want to set the position of my ode bodies directly)
>If my setpoint was a velocity then I would say the equation was a
>P-Gain, but it's a position.
I've written PID loops for real-world applications, so I have a good 
understanding of how they work.

Your error is a measurement of the distance you are from your target.

PGain is an **arbitrary** number that converts that distance into a 
velocity. The idea is that the farther you are away from your target, 
the faster you want to move. This will allow you to get where you want 
to go quickly without overshooting, because as you get close, you taper 
off the speed, and come to a smooth controlled stop.

Remember there are two types of PID loops, position and velocity. Notice 
the fundamental difference between the simple forms of them:

position: "requested velocity = err * pgain" where "err = target 
position - current position"
velocity: "requested velocity += err * pgain" where "err = target 
velocity - current velocity"

For starters, you want to have a PGain of about 0.01 or perhaps 0.1. Try 
incrementing it by orders of magnitude until it starts overshooting. Now 
you know you are close. It's possible you might find something you're 
happy with before it gets unstable. Just tweak it in from there.

PGain is your primary worker.

IGain is most often only useful for *extremely* slow-responding stimuli, 
like an oven for example. Use this when you have a simulation that gets 
unstable far before PGain is high enough for your needs. The way IGain 
works is that it accumulates error over time to get into it's final 
position. I used this on a dancer arm for a newpaper's printing press to 
help get the dancer dead center.

DGain is good for a system that might have a tendency to jerk 
unexpectedly. It's good for resisting too much acceleration.

As I said, 'I' and 'D' are not needed except in less than 5% of 
applications. In your application, I seriously doubt you will need them.

There's other little tricks you can play with that are part of 
commercial PID loops, though I've never found them necessary. For 
example, you can square your error for the D-Term and things of that nature.

But honestly, try a simple P-loop as I showed above, it should work fine.

Royce Mitchell III

More information about the ODE mailing list