Skip to content

Commit 7f1baeb

Browse files
Code as of half-way through first day of Granite State District Event. Minor tweaks to autonomous programs and ShooterFiringSequence. Minor naming convention tweaks.
1 parent 17a749b commit 7f1baeb

File tree

7 files changed

+35
-28
lines changed

7 files changed

+35
-28
lines changed

src/main/java/org/mayheminc/robot2020/RobotContainer.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,10 @@ private void configureDriverPadButtons() {
199199
DRIVER_PAD.DRIVER_PAD_BLUE_BUTTON.whenPressed(new ShooterWheelAdjust(50.0));
200200
DRIVER_PAD.DRIVER_PAD_GREEN_BUTTON.whenPressed(new ShooterWheelAdjust(-50.0));
201201
DRIVER_PAD.DRIVER_PAD_RED_BUTTON.whenPressed(new ShooterWheelSetVBus(0.0));
202-
DRIVER_PAD.DRIVER_PAD_YELLOW_BUTTON.whenPressed(new ShooterWheelSet(3000));
202+
DRIVER_PAD.DRIVER_PAD_YELLOW_BUTTON
203+
.whenPressed(new ShooterWheelSet(RobotContainer.shooterWheel.SHOOTER_WHEEL_INITIATION_LINE_SPEED));
203204

204205
DRIVER_PAD.DRIVER_PAD_BACK_BUTTON.whileHeld(new DriveStraight(0.1));
205-
// TODO: above hard-coded constant (3000) should be a named constant from
206-
// Shooter.java
207206

208207
DRIVER_PAD.DRIVER_PAD_LEFT_UPPER_TRIGGER_BUTTON.whenHeld(new ShooterFiringSequence(60.0));
209208
DRIVER_PAD.DRIVER_PAD_LEFT_UPPER_TRIGGER_BUTTON.whenReleased(new ShooterCeaseFire());

src/main/java/org/mayheminc/robot2020/autonomousroutines/StartBWOppTrench.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public StartBWOppTrench() {
2727
// lower the intake and turn it on before driving forwards
2828
addCommands(new IntakeSetPosition(RobotContainer.intake.PIVOT_DOWN));
2929
addCommands(new IntakeSetRollers(-1.0));
30-
addCommands(new Wait(5.0));
30+
addCommands(new Wait(2.5));
3131

3232
// make sure the hood is down
3333
addCommands(new HoodSetAbsWhileHeld(Hood.TARGET_ZONE_POSITION));
@@ -53,6 +53,9 @@ public StartBWOppTrench() {
5353
// turn on the intake gently while shooting to help balls settle
5454
addCommands(new IntakeSetRollers(-0.2));
5555

56+
// wait 2/10 of a second to get some camera data after turning turret
57+
addCommands(new Wait(0.2));
58+
5659
// use the "one button" firing sequence
5760
addCommands(new ShooterFiringSequence(5.0));
5861

src/main/java/org/mayheminc/robot2020/commands/ShooterFiringSequence.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@ public ShooterFiringSequence(double waitDuration) {
2828
// one last aim at the target before starting shooting.
2929
addCommands(new ShooterAimToTarget());
3030

31-
addCommands(new ParallelRaceGroup(new ShooterWheelSetToTarget(true), new TurretAimToTarget()));
31+
addCommands(new ParallelRaceGroup(new ShooterWheelSetToTarget(true), new TurretAimToTargetContinuously()));
3232

3333
// turn on the feeder, wait 0.1, turn on the Chimney, wait 0.1, turn on the
3434
// revolver turntable, shoot for specified duration
3535
// TODO: should really shoot until no balls detected any more
36-
addCommands(
37-
new ParallelRaceGroup(new FeederSet(1.0), new SequentialCommandGroup(new Wait(0.1), new ChimneySet(1.0)),
38-
new SequentialCommandGroup(new Wait(0.2), new RevolverSetTurntable(0.3)), new Wait(waitDuration)));
36+
addCommands(new ParallelRaceGroup( //
37+
new TurretAimToTargetContinuously(), // continue aiming while shooting
38+
new FeederSet(1.0), new SequentialCommandGroup(new Wait(0.1), new ChimneySet(1.0)),
39+
new SequentialCommandGroup(new Wait(0.2), new RevolverSetTurntable(0.3)), new Wait(waitDuration)));
3940

4041
// turn off the feeder, chimney, and revolver, ending after 0.1 seconds
4142
addCommands(new ShooterCeaseFire());

src/main/java/org/mayheminc/robot2020/commands/ShooterReadyAimFire.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public ShooterReadyAimFire(double waitDuration) {
3232
// to speed
3333
addCommands(new ParallelRaceGroup(
3434
new ParallelCommandGroup(/* new TargetingIsOnTarget(), */ new ShooterWheelSet(3000.0, true)),
35-
new TurretAimToTarget()));
35+
new TurretAimToTargetContinuously()));
3636

3737
// turn on the feeder, wait 0.1, turn on the Chimney, wait 0.1, turn on the
3838
// revolver turntable, shoot for specified duration

src/main/java/org/mayheminc/robot2020/commands/TurretAimToTarget.java renamed to src/main/java/org/mayheminc/robot2020/commands/TurretAimToTargetContinuously.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111

1212
import edu.wpi.first.wpilibj2.command.CommandBase;
1313

14-
public class TurretAimToTarget extends CommandBase {
14+
public class TurretAimToTargetContinuously extends CommandBase {
1515
/**
1616
* Creates a new TurretAimToTarget.
1717
*/
18-
public TurretAimToTarget() {
18+
public TurretAimToTargetContinuously() {
1919
// Use addRequirements() here to declare subsystem dependencies.
2020
addRequirements(RobotContainer.turret);
2121
}
@@ -28,7 +28,11 @@ public void initialize() {
2828
// Called every time the scheduler runs while the command is scheduled.
2929
@Override
3030
public void execute() {
31+
// TODO: may want to only aim at the target if recent valid target data from the
32+
// camera
3133
double pos = RobotContainer.targeting.getDesiredAzimuth();
34+
// TODO: if the desired azimuth is "beyond the soft stop" should we turn the
35+
// robot?
3236
RobotContainer.turret.setPositionAbs(pos);
3337
}
3438

src/main/java/org/mayheminc/robot2020/subsystems/Climber.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ public class Climber extends SubsystemBase {
2323

2424
private final MayhemTalonSRX winchLeft = new MayhemTalonSRX(Constants.Talon.CLIMBER_WINCH_LEFT);
2525
private final MayhemTalonSRX winchRight = new MayhemTalonSRX(Constants.Talon.CLIMBER_WINCH_RIGHT);
26-
// private final MayhemTalonSRX walkerLeft = new MayhemTalonSRX(Constants.Talon.CLIMBER_WALKER_LEFT);
27-
// private final MayhemTalonSRX walkerRight = new MayhemTalonSRX(Constants.Talon.CLIMBER_WALKER_RIGHT);
26+
// private final MayhemTalonSRX walkerLeft = new
27+
// MayhemTalonSRX(Constants.Talon.CLIMBER_WALKER_LEFT);
28+
// private final MayhemTalonSRX walkerRight = new
29+
// MayhemTalonSRX(Constants.Talon.CLIMBER_WALKER_RIGHT);
2830

2931
private final Solenoid pistons = new Solenoid(Constants.Solenoid.CLIMBER_PISTONS);
3032

@@ -33,8 +35,6 @@ public class Climber extends SubsystemBase {
3335
*/
3436
public Climber() {
3537

36-
// TODO: Add position control to go all the way to the top, and nearly all the way in for climbing
37-
3838
winchLeft.setNeutralMode(NeutralMode.Brake);
3939
winchLeft.configNominalOutputVoltage(+0.0f, -0.0f);
4040
winchLeft.configPeakOutputVoltage(+12.0, -12.0);
@@ -52,7 +52,7 @@ public Climber() {
5252
winchRight.configForwardSoftLimitEnable(true);
5353
winchRight.configReverseSoftLimitThreshold(MIN_HEIGHT_SOFT_LIMIT);
5454
winchRight.configReverseSoftLimitEnable(true);
55-
55+
5656
// walkerRight.setNeutralMode(NeutralMode.Brake);
5757
// walkerRight.configNominalOutputVoltage(+0.0f, -0.0f);
5858
// walkerRight.configPeakOutputVoltage(+12.0, -12.0);
@@ -86,11 +86,11 @@ public void setWinchRightSpeed(double power) {
8686
}
8787

8888
// public void setWalkerLeftSpeed(double power) {
89-
// walkerLeft.set(ControlMode.Velocity, power);
89+
// walkerLeft.set(ControlMode.Velocity, power);
9090
// }
9191

9292
// public void setWalkerRightSpeed(double power) {
93-
// walkerRight.set(ControlMode.Velocity, power);
93+
// walkerRight.set(ControlMode.Velocity, power);
9494
// }
9595

9696
public void setPistons(boolean b) {

src/main/java/org/mayheminc/robot2020/subsystems/Intake.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ enum PivotMode {
3737
MANUAL_MODE, PID_MODE,
3838
};
3939

40-
PivotMode mode = PivotMode.MANUAL_MODE;
41-
boolean isMoving;
40+
PivotMode m_mode = PivotMode.MANUAL_MODE;
41+
boolean m_isMoving;
4242
double m_targetPosition;
4343
double m_feedForward;
4444
Timer m_pidTimer = new Timer();
@@ -104,14 +104,14 @@ public void setRollers(double power) {
104104

105105
public void setPivot(Double b) {
106106
m_targetPosition = b;
107-
mode = PivotMode.PID_MODE;
108-
isMoving = true;
107+
m_mode = PivotMode.PID_MODE;
108+
m_isMoving = true;
109109

110110
m_pidTimer.start();
111111
}
112112

113113
public boolean isPivotAtPosition() {
114-
return !isMoving;
114+
return !m_isMoving;
115115
}
116116

117117
@Override
@@ -125,12 +125,12 @@ public void periodic() {
125125

126126
private void updatePivotPower() {
127127

128-
if (mode == PivotMode.PID_MODE) {
128+
if (m_mode == PivotMode.PID_MODE) {
129129
// if the pivot is close enough or it has been on too long, turn the motor on
130130
// gently downards
131131
if ((Math.abs(pivotTalon.getPosition() - m_targetPosition) < PIVOT_CLOSE_ENOUGH)
132132
|| m_pidTimer.hasPeriodPassed(Intake.MAX_PID_MOVEMENT_TIME_SEC)) {
133-
isMoving = false;
133+
m_isMoving = false;
134134

135135
// if the current position is closer to PIVOT UP than PIVOT DOWN, apply a little
136136
// positive power.
@@ -171,14 +171,14 @@ public void updateSmartDashBoard() {
171171
SmartDashboard.putNumber("Intake Target", m_targetPosition);
172172
SmartDashboard.putNumber("Intake FeedForward", m_feedForward);
173173

174-
SmartDashboard.putBoolean("Intake Is Moving", isMoving);
175-
SmartDashboard.putBoolean("Intake PID Mode", (mode == PivotMode.PID_MODE));
174+
SmartDashboard.putBoolean("Intake Is Moving", m_isMoving);
175+
SmartDashboard.putBoolean("Intake PID Mode", (m_mode == PivotMode.PID_MODE));
176176
SmartDashboard.putNumber("Intake Rollers", rollerTalon.getMotorOutputPercent());
177177
}
178178

179179
public void setPivotVBus(double VBus) {
180180
pivotTalon.set(ControlMode.PercentOutput, VBus);
181-
mode = PivotMode.MANUAL_MODE;
181+
m_mode = PivotMode.MANUAL_MODE;
182182
}
183183

184184
@Override

0 commit comments

Comments
 (0)