Skip to content

Commit 76c801f

Browse files
added safety init
More robot tuning. Chimney has IR sensors at 1 and 2. Tweaked drive D value. Drive the pivot down slightly.
1 parent e3da220 commit 76c801f

21 files changed

+216
-411
lines changed

src/main/java/frc/robot/Robot.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class Robot extends TimedRobot {
3535
@Override
3636
@SuppressWarnings("deprecation")
3737
public void robotInit() {
38-
// Instantiate our RobotContainer. This will perform all our button bindings,
38+
// Instantiate our RobotContainer. This will perform all our button bindings,
3939
// and put our autonomous chooser on the dashboard.
4040
m_robotContainer = new RobotContainer();
4141

@@ -81,6 +81,9 @@ public void disabledPeriodic() {
8181
*/
8282
@Override
8383
public void autonomousInit() {
84+
// ensure robot "safety" before anything else when entering new mode
85+
RobotContainer.safetyInit();
86+
8487
m_autonomousCommand = m_robotContainer.getAutonomousCommand();
8588

8689
// schedule the autonomous command (example)
@@ -98,6 +101,9 @@ public void autonomousPeriodic() {
98101

99102
@Override
100103
public void teleopInit() {
104+
// ensure robot "safety" before anything else when entering new mode
105+
RobotContainer.safetyInit();
106+
101107
// This makes sure that the autonomous stops running when
102108
// teleop starts running. If you want the autonomous to
103109
// continue until interrupted by another command, remove
@@ -106,7 +112,7 @@ public void teleopInit() {
106112
m_autonomousCommand.cancel();
107113
}
108114

109-
// RobotContainer.compressor.start();
115+
// for safety reasons, call
110116
}
111117

112118
/**

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public final class Talon {
3434
public static final int INTAKE_ROLLERS = 9;
3535
public static final int INTAKE_PIVOT = 10;
3636

37-
public static final int MAGAZINE_TURNTABLE = 11;
38-
public static final int MAGAZINE_CHIMNEY = 12;
37+
public static final int REVOLVER_TURNTABLE = 11;
38+
public static final int CHIMNEY_ROLLER = 12;
3939

4040
public static final int CLIMBER_WINCH_LEFT = 14; // high current
4141
public static final int CLIMBER_WINCH_RIGHT = 13; // high current

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

Lines changed: 49 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class RobotContainer {
3232
// The robot's subsystems and commands are defined here...
3333

3434
public static final Climber climber = new Climber();
35-
public static final Magazine magazine = new Magazine();
35+
public static final Revolver revolver = new Revolver();
3636
public static final ShooterWheel shooterWheel = new ShooterWheel();
3737
public static final Hood hood = new Hood();
3838
public static final Turret turret = new Turret();
@@ -74,33 +74,50 @@ public static void init() {
7474
shooterWheel.init();
7575
}
7676

77+
public static void safetyInit() {
78+
hood.setVBus(0.0);
79+
turret.setVBus(0.0);
80+
climber.setPistons(false);
81+
}
82+
7783
private void configureDefaultCommands() {
7884
drive.setDefaultCommand(new DriveDefault());
7985
// intake.setDefaultCommand(new IntakeExtenderVBus());
80-
magazine.setDefaultCommand(new MagazineDefault());
81-
82-
// TODO: Figure out if the current approach of "AirCompressorDefault()" is the way to go for compressor control.
83-
// KBS doesn't think the below is the right way to have the compressor be on "by default" because
84-
// it would require there to always be a command running to keep the compressor off. However, that
85-
// is a good way to ensure it doesn't get left off by accident. Not quite sure how to handle this;
86-
// would really rather that other commands which need the compressor off (such as a high-power command
87-
// which wants all the battery power available) would turn the compressor off when the command starts
88-
// and off when the command ends.) Then again, maybe the "defaultCommand" is a good way to do this
86+
revolver.setDefaultCommand(new RevolverDefault());
87+
88+
// TODO: Figure out if the current approach of "AirCompressorDefault()" is the
89+
// way to go for compressor control.
90+
// KBS doesn't think the below is the right way to have the compressor be on "by
91+
// default" because
92+
// it would require there to always be a command running to keep the compressor
93+
// off. However, that
94+
// is a good way to ensure it doesn't get left off by accident. Not quite sure
95+
// how to handle this;
96+
// would really rather that other commands which need the compressor off (such
97+
// as a high-power command
98+
// which wants all the battery power available) would turn the compressor off
99+
// when the command starts
100+
// and off when the command ends.) Then again, maybe the "defaultCommand" is a
101+
// good way to do this
89102
// and I just don't understand the style yet.
90103
// compressor.setDefaultCommand(new AirCompressorDefault());
91104
}
92105

93106
private void configureAutonomousPrograms() {
94107
LinkedList<Command> autonomousPrograms = new LinkedList<Command>();
95-
// TODO: fix "wierdness" with auto program selection - sometimes doesn't seem to work
96-
// TODO: fix so that auto program is shown not just when changed (as shows old setting sometimes)
97-
98-
// autonomousPrograms.push(/* 01 */ new StayStill());
99-
autonomousPrograms.push(/* 01 */ new DriveStraightOnly());
100-
autonomousPrograms.push(/* 00 */ new TrenchAuto());
101108

102-
// autonomousPrograms.push( new ShooterReadyAimFire());
103-
// autonomousPrograms.push(new TestTurret());
109+
autonomousPrograms.push(/* 11 */ new StayStill());
110+
autonomousPrograms.push(/* 10 */ new StartBWDriveOnlyToRP());
111+
autonomousPrograms.push(/* 09 */ new StartBWDriveOnlyToWall());
112+
autonomousPrograms.push(/* 08 */ new StartFWDriveOnlyToRP());
113+
autonomousPrograms.push(/* 07 */ new StartFWDriveOnlyToWall());
114+
autonomousPrograms.push(/* 06 */ new StartBWShoot3ThenToRP());
115+
autonomousPrograms.push(/* 05 */ new StartBWShoot3ThenToWall());
116+
autonomousPrograms.push(/* 04 */ new StartFWShoot3ThenToRP());
117+
autonomousPrograms.push(/* 03 */ new StartFWShoot3ThenToWall());
118+
autonomousPrograms.push(/* 02 */ new StartFWRendezvous());
119+
autonomousPrograms.push(/* 01 */ new StartBWOppTrench());
120+
autonomousPrograms.push(/* 00 */ new StartBWTrench());
104121

105122
autonomous.setAutonomousPrograms(autonomousPrograms);
106123

@@ -160,8 +177,8 @@ private void configureDriverPadButtons() {
160177
// about -30 degrees
161178
// DRIVER_PAD.DRIVER_PAD_D_PAD_RIGHT.whileHeld(new
162179
// ShooterSetTurretVBus(+0.2));// about +30 degrees
163-
DRIVER_PAD.DRIVER_PAD_D_PAD_UP.whenPressed(new HoodSetAbs(Hood.HOOD_INITIATION_LINE_POSITION));
164-
DRIVER_PAD.DRIVER_PAD_D_PAD_DOWN.whenPressed(new HoodSetAbs(Hood.HOOD_TARGET_ZONE_POSITION));
180+
DRIVER_PAD.DRIVER_PAD_D_PAD_UP.whenPressed(new HoodSetAbsWhileHeld(Hood.HOOD_INITIATION_LINE_POSITION));
181+
DRIVER_PAD.DRIVER_PAD_D_PAD_DOWN.whenPressed(new HoodSetAbsWhileHeld(Hood.HOOD_TARGET_ZONE_POSITION));
165182

166183
// DRIVER_PAD.DRIVER_PAD_D_PAD_LEFT.whenPressed(new
167184
// ShooterSetTurretRel(-200.0));
@@ -184,7 +201,8 @@ private void configureDriverPadButtons() {
184201
DRIVER_PAD.DRIVER_PAD_YELLOW_BUTTON.whenPressed(new ShooterWheelSet(3000));
185202

186203
DRIVER_PAD.DRIVER_PAD_BACK_BUTTON.whileHeld(new DriveStraight(0.1));
187-
// TODO: above hard-coded constant (3000) should be a named constant from Shooter.java
204+
// TODO: above hard-coded constant (3000) should be a named constant from
205+
// Shooter.java
188206

189207
DRIVER_PAD.DRIVER_PAD_LEFT_UPPER_TRIGGER_BUTTON.whileHeld(new FeederSet(1.0));
190208

@@ -194,37 +212,36 @@ private void configureOperatorStickButtons() {
194212
}
195213

196214
private void configureOperatorPadButtons() {
197-
OPERATOR_PAD.OPERATOR_PAD_BUTTON_ONE.whileHeld(new MagazineSetTurntable(0.2));
215+
OPERATOR_PAD.OPERATOR_PAD_BUTTON_ONE.whileHeld(new RevolverSetTurntable(0.2));
198216
OPERATOR_PAD.OPERATOR_PAD_BUTTON_TWO.whenPressed(new IntakeSetPosition(RobotContainer.intake.PIVOT_DOWN));
199-
OPERATOR_PAD.OPERATOR_PAD_BUTTON_THREE.whileHeld(new MagazineSetTurntable(0.5));
217+
OPERATOR_PAD.OPERATOR_PAD_BUTTON_THREE.whileHeld(new RevolverSetTurntable(0.5));
200218
OPERATOR_PAD.OPERATOR_PAD_BUTTON_FOUR.whenPressed(new IntakeSetPosition(RobotContainer.intake.PIVOT_UP));
201219

202220
// new ShooterSetWheel(1000));
203-
OPERATOR_PAD.OPERATOR_PAD_BUTTON_FIVE.whileHeld(new ChimneySetChimney(1.0));
204-
OPERATOR_PAD.OPERATOR_PAD_BUTTON_SIX.whileHeld(new IntakeSetRollers(-1.0));
221+
OPERATOR_PAD.OPERATOR_PAD_BUTTON_FIVE.whileHeld(new ChimneySet(1.0));
222+
OPERATOR_PAD.OPERATOR_PAD_BUTTON_SIX.whileHeld(new IntakeSetRollersWhileHeld(-1.0));
205223

206224
OPERATOR_PAD.OPERATOR_PAD_BUTTON_SEVEN.whileHeld(new TurretAimToTarget());
207-
OPERATOR_PAD.OPERATOR_PAD_BUTTON_EIGHT.whileHeld(new IntakeSetRollers(1.0));
208-
225+
OPERATOR_PAD.OPERATOR_PAD_BUTTON_EIGHT.whileHeld(new IntakeSetRollersWhileHeld(1.0));
226+
209227
OPERATOR_PAD.OPERATOR_PAD_BUTTON_NINE.whenPressed(new ClimberSetPistons(true));
210228
OPERATOR_PAD.OPERATOR_PAD_BUTTON_TEN.whenPressed(new ClimberSetPistons(false));
211229

212-
213230
// OPERATOR_PAD.OPERATOR_PAD_D_PAD_UP.whenPressed(new
214231
// IntakeSetPosition(RobotContainer.intake.PIVOT_UP));
215232
// OPERATOR_PAD.OPERATOR_PAD_D_PAD_DOWN.whenPressed(new
216233
// IntakeSetPosition(RobotContainer.intake.PIVOT_DOWN));
217-
OPERATOR_PAD.OPERATOR_PAD_D_PAD_LEFT.whileHeld(new TurretSetVBus(-0.2));
218-
OPERATOR_PAD.OPERATOR_PAD_D_PAD_RIGHT.whileHeld(new TurretSetVBus(+0.2));
234+
OPERATOR_PAD.OPERATOR_PAD_D_PAD_LEFT.whileHeld(new TurretSetVBus(-0.4));
235+
OPERATOR_PAD.OPERATOR_PAD_D_PAD_RIGHT.whileHeld(new TurretSetVBus(+0.4));
219236
OPERATOR_PAD.OPERATOR_PAD_D_PAD_UP.whileHeld(new HoodAdjust(+1000.0));
220237
OPERATOR_PAD.OPERATOR_PAD_D_PAD_DOWN.whileHeld(new HoodAdjust(-1000.0));
221238

222239
OPERATOR_PAD.OPERATOR_PAD_RIGHT_Y_AXIS_UP.whileHeld(new ClimberSetWinchesPower(1.0));
223240
OPERATOR_PAD.OPERATOR_PAD_RIGHT_Y_AXIS_DOWN.whileHeld(new ClimberSetWinchesPower(-1.0));
224241

225242
// OPERATOR_PAD.OPERATOR_PAD_LEFT_Y_AXIS_UP.whenPressed(new
226-
// MagazineSetTurntable());
227-
OPERATOR_PAD.OPERATOR_PAD_LEFT_Y_AXIS_DOWN.whileHeld(new ChimneySetChimney(-1.0));
243+
// RevolverSetTurntable());
244+
OPERATOR_PAD.OPERATOR_PAD_LEFT_Y_AXIS_DOWN.whileHeld(new ChimneySet(-1.0));
228245
}
229246

230247
/**

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

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

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

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

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

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

1010
import org.mayheminc.robot2020.RobotContainer;
1111

12-
import edu.wpi.first.wpilibj2.command.InstantCommand;
12+
import edu.wpi.first.wpilibj2.command.CommandBase;
1313

14-
public class HoodSetAbs extends InstantCommand {
14+
public class HoodSetAbs extends CommandBase {
1515
double m_set;
1616

1717
/**
@@ -30,4 +30,8 @@ public void initialize() {
3030
RobotContainer.hood.setPosition(m_set);
3131
}
3232

33+
@Override
34+
public boolean isFinished() {
35+
return (RobotContainer.hood.isAtPosition());
36+
}
3337
}

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

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,27 @@
1313

1414
public class IntakeSetPosition extends CommandBase {
1515
double m_position;
16+
boolean m_waitForDone;
1617

1718
/**
18-
* Creates a new IntakeSetPosition.
19+
* Creates a new IntakeSetPosition, with "wait" set to false
1920
*/
20-
public IntakeSetPosition(Double position) {
21+
public IntakeSetPosition(double position) {
22+
this (position, false);
23+
}
24+
25+
/**
26+
* Creates a new IntakeSetPosition
27+
*/
28+
public IntakeSetPosition(double position, boolean wait) {
2129
// Use addRequirements() here to declare subsystem dependencies.
2230
addRequirements(RobotContainer.intake);
23-
m_position = position;
2431

32+
m_position = position;
33+
m_waitForDone = wait;
2534
}
2635

36+
2737
// Called when the command is initially scheduled.
2838
@Override
2939
public void initialize() {
@@ -33,6 +43,10 @@ public void initialize() {
3343
// Returns true when the command should end.
3444
@Override
3545
public boolean isFinished() {
36-
return RobotContainer.intake.isPivotAtPosition();
46+
if (m_waitForDone) {
47+
return RobotContainer.intake.isPivotAtPosition();
48+
} else {
49+
return true;
50+
}
3751
}
3852
}

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

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

0 commit comments

Comments
 (0)