1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//! PID controller implementations for robot motion control.
//!
//! This module provides PID (Proportional-Integral-Derivative) controllers
//! for precise drivetrain control during autonomous periods.
//!
//! # Available Controllers
//!
//! * `linear_pid`: Standard PID for controlling a differential drivetrain.
//! Supports linear movement, rotation, and swing turns.
//! * `arcpid`: Arc PID for curved movements where the robot doesn't
//! stop to turn.
//! * `singlepid`: Standalone PID for controlling a single motor group
//! (e.g., an arm or lift).
//!
//! # How PID Works
//!
//! PID control calculates motor output based on three terms:
//!
//! * **P (Proportional)**: Output proportional to the error (distance from target).
//! * **I (Integral)**: Output proportional to accumulated error over time.
//! * **D (Derivative)**: Output proportional to the rate of error change.
//!
//! The formula is: `output = Kp*error + Ki*integral + Kd*derivative`
//!
//! # Tuning
//!
//! Start with Kp and increase until the robot reaches the target.
//! Add Kd to reduce overshoot. Only add Ki if the robot consistently
//! undershoots.
/// Arc PID controller for curved movements.
///
/// Allows the robot to move in arcs rather than stopping to turn.
/// This is less precise than standard PID but faster for some maneuvers.
/// Standard PID controller for differential drivetrains.
///
/// Provides linear movement, rotation, and swing turn capabilities
/// with configurable PID gains.
/// Standalone PID controller for single motor groups.
///
/// Useful for controlling mechanisms like arms, lifts, or flywheels
/// independently from the drivetrain.
/// Physical configuration of the drivetrain for distance calculations.
///
/// These values are used to convert between motor rotations and
/// linear distance traveled by the robot.