Skip to content

Commit a6a0cc8

Browse files
committed
Add PID gains explanation
1 parent 7fbfb62 commit a6a0cc8

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

docs/leo-rover/documentation/ros-api.mdx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,36 @@ the firmware parameters accordingly.
311311

312312
The derivative gain of the PID regulator.
313313

314+
:::info
315+
316+
The PID loop controls the voltage applied to the wheels based on the difference
317+
between the target velocity and the actual velocity.
318+
319+
The output voltage $U(t)$ at time $t$ is calculated as:
320+
321+
$$
322+
U(t) = K_p \cdot e(t) + K_i \cdot \int e(t) \, dt + K_d \cdot \frac{de(t)}{dt}
323+
$$
324+
325+
where:
326+
327+
- $t$ is the time in seconds,
328+
- $e(t)$ is the velocity error at time $t$ (target velocity - actual velocity),
329+
- $K_p$ is the proportional gain (`wheels.pid.kp`),
330+
- $K_i$ is the integral gain (`wheels.pid.ki`),
331+
- $K_d$ is the derivative gain (`wheels.pid.kd`).
332+
333+
For example, if the target velocity is 1.0 $\frac{m}{s}$ and the actual velocity
334+
is 0.8 $\frac{m}{s}$, the velocity error $e(t)$ is 0.2 $\frac{m}{s}$. \
335+
A $K_p$ of 10.0 would contribute 2.0 $V$ to the output voltage, a $K_i$ of 50.0
336+
would contribute 10.0 $V$ per second of sustained error.
337+
338+
The firmware employs anti-windup measures to prevent the integral term from
339+
accumulating excessively when the output voltage is saturated at the battery
340+
voltage.
341+
342+
:::
343+
314344
- `wheels.max_voltage` (type: `float`, default: `26.0`)
315345

316346
Maximum voltage (in Volts) that can be applied to the wheels. If the battery

0 commit comments

Comments
 (0)