@@ -16,9 +16,11 @@ public final class TeleOpDriveCommand extends Command {
1616 private static final DriveSubsystem DRIVE = Robot .DRIVE ;
1717 private static final VisionSubsystem VISION = Robot .VISION ;
1818 private static final double DEADBAND = 0.05 ;
19- private static final double YAW_EXPO = 0.5 ;
20- private static final double DRIVE_EXPO = 0.5 ;
19+ private static final double YAW_EXPO = 0.65 ; // 0.5
20+ private static final double DRIVE_EXPO = 0.65 ; // 0.5
2121 private static final double kP = 0.1 ;
22+ private static final double MAX_FWD_STR = 0.7 ;
23+ private static final double MAX_YAW = 0.6 ;
2224 private static DriverControls controls ;
2325 private final Logger logger = LoggerFactory .getLogger (this .getClass ());
2426 private final ExpoScale yawExpo ;
@@ -39,33 +41,15 @@ protected void initialize() {
3941
4042 @ Override
4143 protected void execute () {
42- /*VISION.queryPyeye(); // gets corrected heading and range from NT
43-
44- double maxYawVelocity = 0.3; // max yaw input
45-
46- double error = VISION.getCorrectedHeading();
47- boolean isGood =
48- VISION.getCorrectedRange() >= 0; // check if range is good (we have a target), not -1*/
4944 double yaw ;
50-
51- /*if (isGood) {
52-
53- yaw = error * kP; // corrected heading is error from camera center
54-
55- // normalize yaw
56- if (yaw > maxYawVelocity) {
57- yaw = maxYawVelocity;
58- } else if (yaw < -maxYawVelocity) {
59- yaw = -maxYawVelocity;
60- }
61- } else {*/
6245 yaw = yawExpo .apply (controls .getYaw ());
63- // }
64-
65- // forward and strafe are still normal
6646 double forward = driveExpo .apply (controls .getForward ());
6747 double strafe = driveExpo .apply (controls .getStrafe ());
6848
49+ forward = maximum (forward , MAX_FWD_STR );
50+ strafe = maximum (strafe , MAX_FWD_STR );
51+ yaw = maximum (yaw , MAX_YAW );
52+
6953 DRIVE .drive (forward , strafe , yaw );
7054 }
7155
@@ -83,4 +67,10 @@ private double deadband(double value) {
8367 if (Math .abs (value ) < DEADBAND ) return 0.0 ;
8468 return value ;
8569 }
70+
71+ private double maximum (double value , double max ) {
72+ if (value > max ) return max ;
73+ else if (value < -max ) return -max ;
74+ else return value ;
75+ }
8676}
0 commit comments