Jump to content

PID settings? (MechJeb)


Tontow

Recommended Posts

I need help understanding PID settings in mechjeb.

I found: http://forum.kerbalspaceprogram.com/threads/49381-Mechjeb-How-to-make-SASS-chill-out-stop-wasting-RCS-and-shaking-things-apart?highlight=mechjeb+pid+settings

What does he mean by error? The amount of correction that SASS has to do?

What do I tweak for:

- Max acceleration / Max torque

- Max turn speed.

- Max deceleration.

- Point that deceleration should start.

Is there a more in depth guide to PID settings?

Link to comment
Share on other sites

That's actually an amazing write up.

The error is the difference between where you're pointing now, and where you want to end up pointing.

There are no individual "set points" for what you're asking--For lack of a better term, PID controllers are more "organic" than that. This is why they're good for handling many different situations. However, Kp is the "raw aggression" term.

The wikipedia page discusses tuning methodologies: http://en.wikipedia.org/wiki/PID_controller#Overview_of_methods

It's a trial-and-error process for each craft, because they all have different amounts of available torque and moments of inertia. Likewise, a particular set of PID parameters might work well for a full craft, but not an empty one.

Link to comment
Share on other sites

Would someone please explain it as you would to an average person that doesn't have a degree in astrophysics?

So????

Kp is how hard it will try to turn to correct over large distances.

Ki is how hard it will try to turn to correct over small distances.

Kd is some kind of multiplier for Kp.

Tf is how many times a second the circulations are run.

Ki_limit is needed because Ki and Kp can over lap and so Ki needs a limit to how much it can do.

Factor scales everything.

So do I have that right?

Will Kp and Ki also counter my turn acceleration as the error decreases?

Is there a way to add a limit to Kp and add a counter Kp? Maybe someway to put Kd on a curve so that it can make Kp negative once it hits a certain point?

Link to comment
Share on other sites

Kp is how hard it will try to turn to correct over large distances.

Proportional response typically dominates integral response at middling to large distances because its strength is linearly related to the size of the error. Kp controls the slope of the linear response so reducing Kp increases the error required to reach a certain output.

Ki is how hard it will try to turn to correct over small distances.

Integral response is based on a continuous sum of error (the total area bounded by the error function if we weren't bound to discrete measurements). The longer an offset remains, the greater the impact it has. Ki controls the amount of time it takes for a certain error to create a certain level of output (increasing Ki increases the rate at which output will change in response to an error). It is required because proportional response tends to zero as you get closer to a setpoint, causing output to fall to zero. If there is an offsetting force present (ie. asymmetric thrust) this will end with the controller not quite pointing where you told it to go because it can't compensate for the assymmetry with zero error. The integral term allows the required offset to be generated.

Note that the integral reduces stability due to it's oscillatory nature which is why it rarely gets used in KSP where asymmetry is rare

Kd is some kind of multiplier for Kp.

Derivative response is based on the rate of change of error. It acts against any change causing a reduced response. If you want your object to stop turning further away, you reduce Kp/Ki (less acceleration force) and increase Kd (more braking force). Increasing Derivative action too much causes it to fight it's own movements (move left => Kd pushes right => now moving right => Kd pushes left etc.) because we are limited to discrete time steps so if you see a vessel jerking it's way towards it's goal, you can probably blame Kd being too high

Tf is how many times a second the circulations are run.

Yes and no. The rate of calculation is constant, Tf scales the result such that the rate of action is reduced so if everything was constant, it would take Tf seconds longer for the same result to occur compared to if it didn't exist.

Ki_limit is needed because Ki and Kp can over lap and so Ki needs a limit to how much it can do.

The integral is just a continuous sum. When you have a big vessel with a large angle to turn through it could take you tens or hundreds of seconds to get all the way around to your target position. During that time the integral sum will have been adding on that large error and have become very large itself. This will require an opposite error to cancel out and so the vessel will swing right past it's target.

The limiter prevents this from occurring to an extreme degree (it's an inherent property of the integral to need to go slightly past it's target) by placing a limit on that sum, reducing the time it takes to bring integral response to the value it actually requires to set dead on your target.

Will Kp and Ki also counter my turn acceleration as the error decreases?

Kd will counter your turn speed/acceleration, not Ki/Kp

Manually tuning MJ's PID controller was a bit wierd last I used it because Kp/Ki scale with Kd (industrial standard is Ki/Kd scale with Kp which is much easier to work with (IMO) because you typically set Kp first).

Edited by Crzyrndm
Link to comment
Share on other sites

Manually tuning MJ's PID controller was a bit wierd last I used it because Kp/Ki scale with Kd (industrial standard is Ki/Kd scale with Kp which is much easier to work with (IMO) because you typically set Kp first).

If you have some advice on changing the UI or the under-laying math I welcome suggestion. I understand how PiD works but so far I fail at tuning them, and even more at auto-tuning :)

Link to comment
Share on other sites

Maybe some kind of torque over distance graph?

And then let us plug in override values for each stage of the rocket, including torque / turn rate acceleration overrides. - I keep having to adjust the limit or completely lock my gimbals to keep it from overshooting most of the time.

Also, duel values for vacuum vs atmo would go along ways to. Then some kind of editable value to scale between the two.

Note: The atmo values should also have an available scale vs speed of the craft.

Edited by Tontow
Link to comment
Share on other sites

If you have some advice on changing the UI or the under-laying math I welcome suggestion. I understand how PiD works but so far I fail at tuning them, and even more at auto-tuning :)

The math/existing auto tuning appears to be sound (if I had to criticise one thing, it'd be only using MOI/torque as a global modifier when it could be used on individual axes). What I couldn't understand at the time was why it insisted on running manually input factors through the same calculations (which means the Kp you get is based on the Kp AND Kd you enter. Ki being even worse, depending on all three factors).

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...