You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<Callouttype='warn'title="PIDFs vs. Predictive Braking">
6
6
You may either use PIDFs or Predictive Braking to control your robot.
7
-
However, swerve is currently not compatible with Predictive Braking.
7
+
However, swerve and tank are currently not compatible with Predictive Braking.
8
8
All further steps are for Predictive Braking users only.
9
9
</Callout>
10
10
11
-
# Prerequisites
12
-
-**Mecanum wheels** (support for swerve and tank coming soon)
13
-
-**Accurate Localization** (drive encoders alone are insufficient due to wheel slip)
14
-
- Works best with robots with a balanced center of mass and robots that do not lift off the ground or turn dramatically when braking. Do not worry if your robot does these things. This algorithm will still work. Just consider adding more weight to your robot.
15
-
16
-
# Tuning
17
11
1. Run the Tuning.java OpMode -> Automatic -> PredictiveBrakingTuner. This will give you values for `kQuadratic` and `kLinear`. In FollowerConstants, add `.predictiveBrakingCoefficients(new PredictiveBrakingCoefficients(kP, kLinear, kQuadratic))`. Insert the values given from the tuner into the method. Use a starting kP value around `0.1`.
18
-
-`kQuadratic` represents the braking distance proportional to velocity squared. This is caused by constant forces such as sliding friction.
19
-
-`kLinear` represents braking distance roughly proportional to velocity. This is caused by velocity-proportional forces such as back-EMF voltage and viscous friction.
12
+
-`kQuadratic` represents the braking distance proportional to velocity squared. This is caused by constant forces such as braking power and sliding friction.
13
+
-`kLinear` represents braking distance roughly proportional to velocity. This is caused by velocity-proportional forces such as back-EMF, torque delay, and viscous friction.
20
14
21
15
<iframe
22
16
width="560"
@@ -28,14 +22,18 @@ All further steps are for Predictive Braking users only.
28
22
allowFullScreen
29
23
></iframe>
30
24
25
+
Do not be worried if the robot's heading turns while braking in the tuner. This is expected and does not hurt the results. Consider making a more balanced center of mass to combat this. In the future, the tuner will have heading correction.
26
+
27
+
Also do not be worried if your robot lifts off the ground while braking. This is normal as long as odometry can still get accurate measurements.
28
+
31
29
2. Run LineTest and adjust kP to your liking. kP usually ranges from `0.05-0.3`. kP changes are harder to notice and have minimal effects due to kP accounting for predicted error. However, tune kP as high as possible to maximize holding strength and accuracy, without jittering the robot. If you want smoother or sooner deceleration, try experimenting with kP of 0.05 or lower and increasing the kQuadratic term, as this will act more like a motion profile.
32
30
33
31
3. Currently, it is recommended to turn **off centripetal** forces in auto, as predictive braking naturally accounts for this. This can be done by adding the following in FollowerConstants.
34
32
```java title="Constants.java"
35
33
.centripetalScaling(0)
36
34
```
37
35
38
-
4.**Lower the parametric end constraint**. Set it to a value like 0.97 or 0.95. PIDFs often overshoot and hit the parametric end early, but predictive braking fully stops in time, delaying when actions can trigger. Lowering the constraint lets actions trigger sooner and speeds up overall execution.
36
+
4.**Lower the parametric end constraint**. Set it to a value like 0.97 or 0.95. PIDFs often overshoot and hit the parametric end early, but predictive braking fully stops in time, delaying when actions can trigger. Lowering the constraint lets actions trigger sooner and speeds up overall execution. However, do not set the parametric value very low (<0.9)orpredictivebrakingwillnotworkasintendedbecauseitwillendthepathbeforebraking.
0 commit comments