Gazebo | Ignition | Community
Ask Your Question

PID controller value exceeds CmdMax/Min value

asked 2016-04-23 16:41:53 -0500

missx gravatar image

I initialize my PID controller with specific max and min values:

common::PID posPID;

posPID.Init(0.01, 0.1, 1.0, 1.0, 0.0, 200.0, 0.0);

and when I do

posPID.Update(desiredVel - _spindle.angVel, _stepTime);

the value it returns can be negative or bigger than 200

Any hints what might be the problem?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-04-26 02:28:22 -0500

I ripped this right from the source...

// Check the command limits
if (!ignition::math::equal(this->cmdMax, 0.0) && this->cmd > this->cmdMax)
    this->cmd = this->cmdMax;
if (!ignition::math::equal(this->cmdMin, 0.0) && this->cmd < this->cmdMin)
this->cmd = this->cmdMin;

return this->cmd;

Looks to me like you can't have a min of zero. It has to be something other than zero to be a min. This is definitely a bug, and should be addressed. For now, you could just set it to a small number like 0.001 and see if that works.

I can't immediately see why it's not respecting the 200 limit however. How much greater are we talking about? Can you add a smallest-possible-reproducible example?

edit flag offensive delete link more


yea, you're right. with minimum 0 it doesn't work. thanks! and with maximum - my bad - output value has never reached it

missx gravatar imagemissx ( 2016-04-26 15:13:22 -0500 )edit

You should consider making a pull request to allow a minimum of 0! It would a simple first-time contribution. We could require -inf/inf as the values if you want no min or max, and then remove that check for zero.

Peter Mitrano gravatar imagePeter Mitrano ( 2016-05-09 11:55:43 -0500 )edit

Question Tools



Asked: 2016-04-23 16:41:53 -0500

Seen: 357 times

Last updated: Apr 26 '16