Skip to content

Gains tuning - #112

Draft
vivi-o wants to merge 4 commits into
mainfrom
gains-tuning
Draft

Gains tuning#112
vivi-o wants to merge 4 commits into
mainfrom
gains-tuning

Conversation

@vivi-o

@vivi-o vivi-o commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

lowkey not that well written but I think it covers some useful tips.

@vivi-o
vivi-o marked this pull request as draft August 28, 2026 00:47
@vivi-o
vivi-o requested a review from SCool62 August 28, 2026 00:48

@SCool62 SCool62 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally good. I left some specific comments. Also, if you could go through and polish a little (like put capitals at the start of sentences etc.) that would be good.


## Feedforward constants:

kS is static friction. kS represents the amount of motor output required to overcome static friction and get the mechanism to move.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for all of these: maybe reword this to "kS is the static friction feedforward gain" or something to make it more clear what exactly the number refers to (like its not referring to the actual force of friction on the mechanism)

- if kP is too low the mechanism responds slowly and can't keep up with the target accurately
- if kP is too high the mechanism may overshoot, oscillate, or become unstable

kI is based on the accumulated error over time. An integral is the area under a curve or in our case the error accumulated over time so if error gradually builds up in our system I can help with that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would make the connection between kI, integrals, and accumulated error over time more clear.


kD is based on how quickly the error is changing, it is looking at the rate of change of the error or how quickly it's approaching the target.
- low kD can make the mechanism overshoot or oscillate.
- high kD can make the mechanism too slow to react or react excessively.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this is what you mean by "react excessively" but the most common symptom of high kD is very rapid, almost spasm-like oscillations when near the setpoint


Understanding these things conceptually is the first step, but now we will include a guide on tuning for practical use. In general, you should not tune everything at once. A solid approach is making feedforward reasonably accurate, then using feedback to reduce the rest of the error. The process and constants you will need depends on the mechanism because they all have different physics. The procedure can depend on the motor controller, control mode, and mechanism. For example, it's important to distinguish between velocity and position control. If you're tuning a roller to maintain a certain RPM then you're dealing with velocity. However, if you're dealing with an elevator that needs to move to particular heights that's position control.

In general, the order for tuning is: kS, kV, kA, kG, kP, kD, kI (note: not all may be needed)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually tune kG right after/along with kS


In general, the order for tuning is: kS, kV, kA, kG, kP, kD, kI (note: not all may be needed)

### Elevator tuning:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add kG tuning here. Usually, when tuning manually, I measure the voltage required to start moving up, representing (kS+kG), then the voltage required to start moving down (kS-kG). Then solve the system to get the correct gains

- kI may not be necessarily but if there's consistently small position error it may help.

### Arm tuning:
similar to elevator processes with kS, kV, kA if necessary, kG(when arm is horizontal), kP, kD, and kI is necessary

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this should say "kI if necessary"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also once again kG should be tuned either along with kS or before it

similar to elevator processes with kS, kV, kA if necessary, kG(when arm is horizontal), kP, kD, and kI is necessary

### roller tuning:
typical rollers only need kS, kV, kA, kP, and kD

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe note that kP and kD are usually very small (like on the order of 0.1 kP and 0.01 kD) if the feedforward has been properly tuned

typical rollers only need kS, kV, kA, kP, and kD

## Additional tips:
- using tools such as SysID (see sysId article) rather than this process can give you kS, kV, and kA

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sysid also gives kG


## Additional tips:
- using tools such as SysID (see sysId article) rather than this process can give you kS, kV, and kA
- your tuning process and gains need to make sense for the control system your using whether that position, velocity, voltage, etc

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would edit this sentence to be more clear. Also, you shouldn't need gains for voltage. I would also add that if you're planning to motion-profile a mechanism its PID should be tuned with a motion profile

kI is based on the accumulated error over time. An integral is the area under a curve or in our case the error accumulated over time so if error gradually builds up in our system I can help with that.
- kI is often not needed and will be set to 0 or a very small value in most cases. This is because kP and kD are often good enough. If kI is too high it can cause overshooting.

kD is based on how quickly the error is changing, it is looking at the rate of change of the error or how quickly it's approaching the target.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be 2 sentences

@SCool62

SCool62 commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Oh also, why are there a ton of files from kitbot stuff on here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants