1 package org
.usfirst
.frc3501
.RiceCatRobot
;
6 * This method gives speed as a function of % distance covered so the speed
7 * forms a parabola starting and ending at minSpeed when you start and end and
8 * achieving maxSpeed exactly halfway.
11 * the starting and ending speed, in range [0, 1]
13 * the max speed, achieved at percentComplete = 1/2.
14 * @param percentComplete
15 * should be currentDistance / targetDistance
16 * @return the speed (motor value) to set motors to for smooth acceleration.
17 * Note that since velocity is a parabola, acceleration is linear. It
18 * may exceed the maximum value robot can accelerate without wheel
21 public static double getSpeedForLinearAccel(double minSpeed
, double maxSpeed
,
22 double percentComplete
) {
23 return 4 * (minSpeed
- maxSpeed
) * (percentComplete
- 0.5)
24 * (percentComplete
- 0.5) + maxSpeed
;
28 * This method gives speed as a function of % distance covered so the speed
29 * increases linearly from minSpeed to maxSpeed and then back down again.
32 * the starting and ending speed, in range [0, 1]
34 * the max speed, achieved at percentComplete = 1/2.
35 * @param percentComplete
36 * should be currentDistance / targetDistance
37 * @return the speed (motor value) to set motors to.
39 public static double getSpeedForConstantAccel(double minSpeed
,
40 double maxSpeed
, double percentComplete
) {
41 return maxSpeed
+ 2 * (minSpeed
- maxSpeed
)
42 * Math
.abs(percentComplete
- 0.5);