Skip to content

Commit a5e7fae

Browse files
authored
Merge pull request #225 from strykeforce/mwitcpalek/sandstorm
Mwitcpalek/sandstorm
2 parents 5b740b5 + 8993932 commit a5e7fae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1461
-525
lines changed

nt/dart-4-10.ini

Lines changed: 849 additions & 0 deletions
Large diffs are not rendered by default.

src/main/java/frc/team2767/deepspace/Robot.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public void robotInit() {
7878
}
7979

8080
SmartDashboard.putBoolean("Game/SandstormPickUp", false);
81+
SmartDashboard.putBoolean("Game/haveHatch", false);
8182

8283
// new SmartDashboardControls();
8384
}

src/main/java/frc/team2767/deepspace/command/TimedDriveTest.java

Lines changed: 0 additions & 44 deletions
This file was deleted.

src/main/java/frc/team2767/deepspace/command/approach/AlignToFieldPickupCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected void initialize() {
4343
@Override
4444
protected void execute() {
4545
// Calculate Yaw Term based on gyro
46-
yawError = targetYaw - DRIVE.getGyro().getAngle();
46+
yawError = targetYaw - Math.IEEEremainder(DRIVE.getGyro().getAngle(), 360);
4747
double yaw = kP_YAW * yawError;
4848
if (yaw > MAX_YAW) yaw = MAX_YAW;
4949
if (yaw < -MAX_YAW) yaw = -MAX_YAW;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package frc.team2767.deepspace.command.approach;
2+
3+
import edu.wpi.first.wpilibj.command.Command;
4+
import frc.team2767.deepspace.Robot;
5+
import frc.team2767.deepspace.control.DriverControls;
6+
import frc.team2767.deepspace.subsystem.DriveSubsystem;
7+
import org.slf4j.Logger;
8+
import org.slf4j.LoggerFactory;
9+
import org.strykeforce.thirdcoast.util.ExpoScale;
10+
11+
public class HoldHeadingCommand extends Command {
12+
private static final DriveSubsystem DRIVE = Robot.DRIVE;
13+
private static DriverControls controls;
14+
private final Logger logger = LoggerFactory.getLogger(this.getClass());
15+
private static double forward;
16+
private static ExpoScale driveExpo;
17+
18+
private static final double FWD_SCALE = 0.3;
19+
private static final double DRIVE_EXPO = 0.5;
20+
private static final double DEADBAND = 0.05;
21+
22+
@Override
23+
protected void initialize() {
24+
controls = Robot.CONTROLS.getDriverControls();
25+
logger.info("Hold Heading, Hatch Place");
26+
}
27+
28+
@Override
29+
protected void execute() {
30+
forward = driveExpo.apply(controls.getForward()) * FWD_SCALE;
31+
DRIVE.drive(forward, 0.0, 0.0);
32+
}
33+
34+
@Override
35+
protected boolean isFinished() {
36+
return false;
37+
}
38+
}

src/main/java/frc/team2767/deepspace/command/approach/HoldHeadingUntilSuctionCommand.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import edu.wpi.first.wpilibj.Timer;
44
import edu.wpi.first.wpilibj.command.Command;
5+
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
56
import frc.team2767.deepspace.Robot;
67
import frc.team2767.deepspace.control.DriverControls;
78
import frc.team2767.deepspace.subsystem.DriveSubsystem;
@@ -26,7 +27,7 @@ public class HoldHeadingUntilSuctionCommand extends Command {
2627
private static double outInitTime;
2728

2829
private static final double HATCH_SEAL_GOOD_ENOUGH = 7.5;
29-
private static final double FWD_SCALE = 0.3;
30+
private static final double FWD_SCALE = 0.2;
3031
private static final double DRIVE_EXPO = 0.5;
3132
private static final double DEADBAND = 0.05;
3233
private static final double OUT_TIME_SEC = 0.25;
@@ -54,6 +55,7 @@ protected void execute() {
5455
if ((currentPressure - initialPressure) > HATCH_SEAL_GOOD_ENOUGH) {
5556
driveState = DriveState.OUT;
5657
VISION.enableLights(false);
58+
SmartDashboard.putBoolean("Game/haveHatch", true);
5759
outInitTime = Timer.getFPGATimestamp();
5860
logger.info("Have Seal");
5961
}

src/main/java/frc/team2767/deepspace/command/approach/VisionAutoAlignPickupCommand.java

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package frc.team2767.deepspace.command.approach;
22

33
import edu.wpi.first.wpilibj.command.Command;
4+
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
45
import frc.team2767.deepspace.Robot;
56
import frc.team2767.deepspace.control.DriverControls;
67
import frc.team2767.deepspace.subsystem.DriveSubsystem;
@@ -16,17 +17,19 @@
1617
import org.strykeforce.thirdcoast.telemetry.grapher.Measure;
1718
import org.strykeforce.thirdcoast.telemetry.item.Item;
1819
import org.strykeforce.thirdcoast.util.ExpoScale;
20+
import org.strykeforce.thirdcoast.util.RateLimit;
1921

2022
public class VisionAutoAlignPickupCommand extends Command implements Item {
21-
public static final double kP_STRAFE = 0.05;
23+
public static final double kP_STRAFE = 0.1; // 0.09
2224
private static final double DRIVE_EXPO = 0.5;
2325
private static final double YAW_EXPO = 0.5;
2426
private static final double DEADBAND = 0.05;
2527
private static final double kP_YAW = 0.01; // 0.00625 tuning for NT method, 0.01 pyeye
2628
private static final double MAX_YAW = 0.3;
27-
private static final double MIN_RANGE = 70.0;
29+
private static final double MIN_RANGE = 35.0;
2830
private static final double FWD_SCALE = 0.3;
29-
private static final double goodEnoughYaw = 1.0;
31+
private static final double FWD_SCALE_FAST = 0.5;
32+
private static final double goodEnoughYaw = 1.5;
3033

3134
private static final DriveSubsystem DRIVE = Robot.DRIVE;
3235
private static final VisionSubsystem VISION = Robot.VISION;
@@ -40,11 +43,14 @@ public class VisionAutoAlignPickupCommand extends Command implements Item {
4043
private final Logger logger = LoggerFactory.getLogger(this.getClass());
4144
private double targetYaw;
4245
private boolean isGood = false;
46+
private static double strafeCorrection;
47+
private RateLimit rateLimit;
4348

4449
public VisionAutoAlignPickupCommand() {
4550
requires(DRIVE);
4651
this.driveExpo = new ExpoScale(DEADBAND, DRIVE_EXPO);
4752
this.yawExpo = new ExpoScale(DEADBAND, YAW_EXPO);
53+
rateLimit = new RateLimit(0.015);
4854

4955
TelemetryService telemetryService = Robot.TELEMETRY;
5056
telemetryService.stop();
@@ -53,10 +59,11 @@ public VisionAutoAlignPickupCommand() {
5359

5460
@Override
5561
protected void initialize() {
62+
SmartDashboard.putBoolean("Game/haveHatch", false);
5663
logger.info("Begin Vision Auto Align Pickup");
5764
controls = Robot.CONTROLS.getDriverControls();
5865
DRIVE.setDriveMode(SwerveDrive.DriveMode.CLOSED_LOOP);
59-
66+
strafeCorrection = VISION.getStrafeCorrection();
6067
if (VISION.direction == FieldDirection.LEFT) {
6168
targetYaw = -90.0;
6269
} else targetYaw = 90.0;
@@ -71,24 +78,26 @@ protected void execute() {
7178
isGood = range >= 0; // check if range is good (we have a target), not -1
7279

7380
// Calculate Yaw Term based on gyro
74-
yawError = targetYaw - DRIVE.getGyro().getAngle();
81+
yawError = targetYaw - Math.IEEEremainder(DRIVE.getGyro().getAngle(), 360.0);
7582
double yaw = kP_YAW * yawError;
7683
if (yaw > MAX_YAW) yaw = MAX_YAW;
7784
if (yaw < -MAX_YAW) yaw = -MAX_YAW;
7885

7986
// Determine if actual yaw is close enough to target
8087
boolean onTarget = Math.abs(yawError) <= goodEnoughYaw;
8188

89+
double forward;
8290
// forward is still normal
83-
double forward = driveExpo.apply(controls.getForward()) * FWD_SCALE;
84-
91+
if (isGood) {
92+
forward = driveExpo.apply(controls.getForward()) * FWD_SCALE;
93+
} else forward = driveExpo.apply(controls.getForward()) * FWD_SCALE_FAST;
8594
double strafe;
86-
strafeError = Math.sin(Math.toRadians(VISION.getRawBearing())) * range;
95+
strafeError = Math.sin(Math.toRadians(VISION.getRawBearing())) * range - strafeCorrection;
8796
// Only take over strafe control if pyeye has a target and the robot is straight to the field
8897
if (isGood && onTarget) strafe = strafeError * kP_STRAFE * forward;
8998
else strafe = driveExpo.apply(controls.getStrafe());
9099

91-
DRIVE.drive(forward, strafe, yaw);
100+
DRIVE.drive(forward, rateLimit.apply(strafe), yaw);
92101
}
93102

94103
@Override
@@ -142,6 +151,8 @@ public DoubleSupplier measurementFor(@NotNull Measure measure) {
142151
return () -> yawError;
143152
case RANGE:
144153
return () -> strafeError;
154+
// case COMPONENT_STRAFE:
155+
// return () -> strafe;
145156
default:
146157
return () -> 2767;
147158
}

src/main/java/frc/team2767/deepspace/command/approach/sequences/AutoHatchPickupCommandGroup.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
import frc.team2767.deepspace.command.approach.ApproachDirectionCommand;
55
import frc.team2767.deepspace.command.approach.HoldHeadingUntilSuctionCommand;
66
import frc.team2767.deepspace.command.approach.VisionAutoAlignPickupCommand;
7+
import frc.team2767.deepspace.command.biscuit.BiscuitConfigMotionAccelCommand;
78
import frc.team2767.deepspace.command.biscuit.BiscuitExecutePlanCommand;
89
import frc.team2767.deepspace.command.biscuit.BiscuitPositionAboveCameraCommand;
10+
import frc.team2767.deepspace.command.biscuit.ReleaseKrakenCommand;
911
import frc.team2767.deepspace.command.elevator.ElevatorExecutePlanCommand;
1012
import frc.team2767.deepspace.command.log.LogCommand;
1113
import frc.team2767.deepspace.command.states.SetActionCommand;
@@ -14,10 +16,7 @@
1416
import frc.team2767.deepspace.command.vacuum.PressureSetCommand;
1517
import frc.team2767.deepspace.command.vacuum.SetSolenoidStatesCommand;
1618
import frc.team2767.deepspace.command.vision.LightsOnCommand;
17-
import frc.team2767.deepspace.subsystem.Action;
18-
import frc.team2767.deepspace.subsystem.ElevatorLevel;
19-
import frc.team2767.deepspace.subsystem.GamePiece;
20-
import frc.team2767.deepspace.subsystem.VacuumSubsystem;
19+
import frc.team2767.deepspace.subsystem.*;
2120

2221
public class AutoHatchPickupCommandGroup extends CommandGroup {
2322

@@ -36,11 +35,13 @@ public AutoHatchPickupCommandGroup() {
3635

3736
addSequential(new PressureSetCommand(VacuumSubsystem.kHatchPressureInHg), 0.02);
3837
addSequential(new SetSolenoidStatesCommand(VacuumSubsystem.SolenoidStates.GAME_PIECE_PICKUP));
38+
addParallel(new ReleaseKrakenCommand(true));
3939
addParallel(new BiscuitPositionAboveCameraCommand());
4040
addParallel(new ElevatorExecutePlanCommand());
4141
addSequential(new VisionAutoAlignPickupCommand());
4242
addSequential(new BiscuitExecutePlanCommand());
4343
addSequential(new HoldHeadingUntilSuctionCommand());
44+
addParallel(new BiscuitConfigMotionAccelCommand(BiscuitSubsystem.kSlowAccel));
4445
addParallel(new SetActionCommand(Action.PLACE));
4546
addSequential(new LogCommand("END AUTO HATCH PICKUP"));
4647
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package frc.team2767.deepspace.command.approach.sequences;
2+
3+
import edu.wpi.first.wpilibj.DriverStation;
4+
import edu.wpi.first.wpilibj.command.CommandGroup;
5+
import edu.wpi.first.wpilibj.command.ConditionalCommand;
6+
import frc.team2767.deepspace.command.approach.*;
7+
import frc.team2767.deepspace.command.biscuit.BiscuitExecutePlanCommand;
8+
import frc.team2767.deepspace.command.biscuit.BiscuitPositionAboveCameraCommand;
9+
import frc.team2767.deepspace.command.log.LogCommand;
10+
import frc.team2767.deepspace.command.states.SetFieldDirectionCommand;
11+
import frc.team2767.deepspace.command.teleop.DriverPlaceAssistCommand;
12+
import frc.team2767.deepspace.command.vision.LightsOnCommand;
13+
import frc.team2767.deepspace.subsystem.FieldDirection;
14+
15+
public class AutoHatchPlaceCommandGroup extends CommandGroup {
16+
17+
public AutoHatchPlaceCommandGroup() {
18+
addSequential(new LogCommand("BEGIN AUTO HATCH PLACE"));
19+
20+
addSequential(
21+
new ConditionalCommand(new SetFieldDirectionCommand(FieldDirection.LEFT)) {
22+
@Override
23+
protected boolean condition() {
24+
return DriverStation.getInstance().isAutonomous();
25+
}
26+
});
27+
addSequential(new LightsOnCommand());
28+
addSequential(new BiscuitPositionAboveCameraCommand());
29+
addSequential(new DriverPlaceAssistCommand());
30+
addSequential(new BiscuitExecutePlanCommand());
31+
addSequential(new HoldHeadingCommand());
32+
addSequential(new LogCommand("END HATCH PLACE"));
33+
}
34+
}

src/main/java/frc/team2767/deepspace/command/approach/sequences/HatchPlaceCommandGroup.java

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)