4.9 Gains
withPID(translation, rotation) sets the path follower’s PID gains. The two kP values also take
a supplier, and withTunablePID(translation, rotation) takes two suppliers of PIDConstants, for
tunable kP, kI and kD. A new value reaches a running route at once
(Live tuning).
withPID
import com.tempo.PIDConstants;
public static final TempoConfig CONFIG = new TempoConfig()
// ... the rest of the config
.withPID(new PIDConstants(8.0, 0.0, 0.0), // translation kP, kI, kD
new PIDConstants(6.0, 0.0, 0.0)); // rotation kP, kI, kDfrom tempo import PIDConstants, TempoConfig
CONFIG = (TempoConfig()
# ... the rest of the config
.with_pid(PIDConstants(8.0, 0.0, 0.0), # translation kP, kI, kD
PIDConstants(6.0, 0.0, 0.0))) # rotation kP, kI, kDinline const tempo::TempoConfig kConfig = tempo::TempoConfig{}
// ... the rest of the config
.with_pid(tempo::PidConstants{8.0, 0.0, 0.0}, // translation kP, kI, kD
tempo::PidConstants{6.0, 0.0, 0.0}); // rotation kP, kI, kDwithPID(8.0, 6.0) sets the same gains from the two kP values. C++ spells
PIDConstants as tempo::PidConstants.
Without withPID the defaults are kP 8 on translation and 6 on rotation, with no
I or D (FollowerGains.defaults()). FollowerGains is the type that holds the six
gains.
The integral term’s output is capped at the leg’s velocity limit, or its turn-rate limit for rotation. The integral and derivative history clear when a trajectory starts, and setting an I gain to zero clears that axis’s stored integral.
On a differential drive, standard control is RAMSETE. The default kP values, 8 and 6, give
WPILib’s b = 2 and zeta = 0.7. Doubling a kP doubles its correction, and zero leaves
the axis on feedforward. I and D don’t apply.