Skip to content

Commit 1e3550d

Browse files
Changes from late night Wednesday before GSD. Mostly related to targeting and initial curve-fits for shooter range determination, wheel speed, and hood angle.
1 parent afdeefe commit 1e3550d

File tree

12 files changed

+168
-35
lines changed

12 files changed

+168
-35
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ private void configureDriverPadButtons() {
177177
// about -30 degrees
178178
// DRIVER_PAD.DRIVER_PAD_D_PAD_RIGHT.whileHeld(new
179179
// ShooterSetTurretVBus(+0.2));// about +30 degrees
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));
180+
DRIVER_PAD.DRIVER_PAD_D_PAD_UP.whenPressed(new HoodSetAbsWhileHeld(Hood.INITIATION_LINE_POSITION));
181+
DRIVER_PAD.DRIVER_PAD_D_PAD_DOWN.whenPressed(new HoodSetAbsWhileHeld(Hood.STARTING_POSITION));
182182

183183
// DRIVER_PAD.DRIVER_PAD_D_PAD_LEFT.whenPressed(new
184184
// ShooterSetTurretRel(-200.0));
@@ -195,16 +195,17 @@ private void configureDriverPadButtons() {
195195
// DRIVER_PAD.DRIVER_PAD_D_PAD_DOWN.whileHeld(new ShooterSetHoodVBus(-1.0));
196196

197197
// Debug shooter pid velocity
198-
DRIVER_PAD.DRIVER_PAD_BLUE_BUTTON.whenPressed(new ShooterWheelAdjust(100.0));
199-
DRIVER_PAD.DRIVER_PAD_GREEN_BUTTON.whenPressed(new ShooterWheelAdjust(-100.0));
198+
DRIVER_PAD.DRIVER_PAD_BLUE_BUTTON.whenPressed(new ShooterWheelAdjust(50.0));
199+
DRIVER_PAD.DRIVER_PAD_GREEN_BUTTON.whenPressed(new ShooterWheelAdjust(-50.0));
200200
DRIVER_PAD.DRIVER_PAD_RED_BUTTON.whenPressed(new ShooterWheelSetVBus(0.0));
201201
DRIVER_PAD.DRIVER_PAD_YELLOW_BUTTON.whenPressed(new ShooterWheelSet(3000));
202202

203203
DRIVER_PAD.DRIVER_PAD_BACK_BUTTON.whileHeld(new DriveStraight(0.1));
204204
// TODO: above hard-coded constant (3000) should be a named constant from
205205
// Shooter.java
206206

207-
DRIVER_PAD.DRIVER_PAD_LEFT_UPPER_TRIGGER_BUTTON.whileHeld(new FeederSet(1.0));
207+
DRIVER_PAD.DRIVER_PAD_LEFT_UPPER_TRIGGER_BUTTON.whileHeld(new ShooterPermissionToFire());
208+
DRIVER_PAD.DRIVER_PAD_LEFT_LOWER_TRIGGER_BUTTON.whileHeld(new FeederSet(1.0));
208209

209210
}
210211

@@ -221,7 +222,7 @@ private void configureOperatorPadButtons() {
221222
OPERATOR_PAD.OPERATOR_PAD_BUTTON_FIVE.whileHeld(new ChimneySet(1.0));
222223
OPERATOR_PAD.OPERATOR_PAD_BUTTON_SIX.whileHeld(new IntakeSetRollersWhileHeld(-1.0));
223224

224-
OPERATOR_PAD.OPERATOR_PAD_BUTTON_SEVEN.whileHeld(new TurretAimToTarget());
225+
OPERATOR_PAD.OPERATOR_PAD_BUTTON_SEVEN.whenPressed(new ShooterAimToTarget());
225226
OPERATOR_PAD.OPERATOR_PAD_BUTTON_EIGHT.whileHeld(new IntakeSetRollersWhileHeld(1.0));
226227

227228
OPERATOR_PAD.OPERATOR_PAD_BUTTON_NINE.whenPressed(new ClimberSetPistons(true));

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public StartBWOppTrench() {
2929
addCommands(new IntakeSetRollers(-1.0));
3030

3131
// make sure the hood is down
32-
addCommands(new HoodSetAbsWhileHeld(Hood.HOOD_TARGET_ZONE_POSITION));
32+
addCommands(new HoodSetAbsWhileHeld(Hood.TARGET_ZONE_POSITION));
3333

3434
// drive to get balls from opponent's trench
3535
addCommands(new DriveStraightOnHeading(0.2, DistanceUnits.INCHES, 108, 180));
@@ -46,7 +46,7 @@ public StartBWOppTrench() {
4646
// in shooting position, prepare everything for shooting
4747
addCommands(new ParallelCommandGroup( // run the following commands in parallel:
4848
new ShooterWheelSet(ShooterWheel.SHOOTER_WHEEL_INITIATION_LINE_SPEED),
49-
new HoodSetAbsWhileHeld(Hood.HOOD_INITIATION_LINE_POSITION + 3000.0),
49+
new HoodSetAbsWhileHeld(Hood.INITIATION_LINE_POSITION + 3000.0),
5050
new TurretSetAbs((105.0 * Turret.TICKS_PER_DEGREE), Turret.WAIT_FOR_DONE)));
5151

5252
// turn on the intake gently while shooting to help balls settle
@@ -58,6 +58,6 @@ public StartBWOppTrench() {
5858
addCommands(new IntakeSetRollers(0.0));
5959

6060
// turn the wheel off now that the shooting is all done
61-
addCommands(new HoodSetAbsWhileHeld(Hood.HOOD_TARGET_ZONE_POSITION));
61+
addCommands(new HoodSetAbsWhileHeld(Hood.TARGET_ZONE_POSITION));
6262
}
6363
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public StartBWShoot3() {
2828
addCommands(new ParallelCommandGroup( // run the following commands in parallel:
2929
new IntakeSetPosition(RobotContainer.intake.PIVOT_DOWN),
3030
new ShooterWheelSet(ShooterWheel.SHOOTER_WHEEL_INITIATION_LINE_SPEED),
31-
new HoodSetAbsWhileHeld(Hood.HOOD_INITIATION_LINE_POSITION),
31+
new HoodSetAbsWhileHeld(Hood.INITIATION_LINE_POSITION),
3232
new TurretSetAbs((180.0 * Turret.TICKS_PER_DEGREE), Turret.WAIT_FOR_DONE)));
3333

3434
addCommands(new ShooterReadyAimFire(1.5));
@@ -37,6 +37,6 @@ public StartBWShoot3() {
3737
addCommands(new ParallelCommandGroup( // below commands in parallel
3838
new ShooterWheelSet(0.0), //
3939
new IntakeSetRollers(0.0), // turn off the rollers
40-
new HoodSetAbs(Hood.HOOD_STARTING_POSITION)));
40+
new HoodSetAbs(Hood.STARTING_POSITION)));
4141
}
4242
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public StartBWTrench() {
3232
// intake while driving down the trench
3333
new IntakeSetRollers(-1.0),
3434
// ensure the hood is down
35-
new HoodSetAbsWhileHeld(Hood.HOOD_STARTING_POSITION),
35+
new HoodSetAbsWhileHeld(Hood.STARTING_POSITION),
3636
// drive the path under the control panel to the end
3737
new DriveStraightOnHeading(0.3, DistanceUnits.INCHES, 180, 180)));
3838

@@ -50,7 +50,7 @@ public StartBWTrench() {
5050
// wheels, raising the hood, and re-aiming the turret
5151
addCommands(new ParallelCommandGroup(
5252
new ShooterWheelSet(ShooterWheel.SHOOTER_WHEEL_INITIATION_LINE_SPEED),
53-
new HoodSetAbsWhileHeld(Hood.HOOD_INITIATION_LINE_POSITION),
53+
new HoodSetAbsWhileHeld(Hood.INITIATION_LINE_POSITION),
5454
new TurretSetAbs((168.0 * Turret.TICKS_PER_DEGREE)),
5555
new DriveStraightOnHeading(-0.5, DistanceUnits.INCHES, 96, 160)));
5656

@@ -68,6 +68,6 @@ public StartBWTrench() {
6868
addCommands(new IntakeSetRollers(0.0));
6969

7070
// turn the wheel off now that the shooting is all done
71-
addCommands(new HoodSetAbsWhileHeld(Hood.HOOD_TARGET_ZONE_POSITION));
71+
addCommands(new HoodSetAbsWhileHeld(Hood.TARGET_ZONE_POSITION));
7272
}
7373
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public StartFWRendezvous() {
3131
addCommands(new ParallelCommandGroup( // run the following commands in parallel:
3232
new IntakeSetPosition(RobotContainer.intake.PIVOT_DOWN),
3333
new ShooterWheelSet(ShooterWheel.SHOOTER_WHEEL_INITIATION_LINE_SPEED),
34-
new HoodSetAbs(Hood.HOOD_INITIATION_LINE_POSITION),
34+
new HoodSetAbs(Hood.INITIATION_LINE_POSITION),
3535
new TurretSetAbs((10.0 * Turret.TICKS_PER_DEGREE), Turret.WAIT_FOR_DONE)));
3636

3737
addCommands(new ShooterReadyAimFire(1.0));
@@ -44,8 +44,7 @@ public StartFWRendezvous() {
4444
addCommands(new IntakeSetPosition(RobotContainer.intake.PIVOT_DOWN));
4545

4646
// rais the hood a little to shoot from this increased distance
47-
addCommands(new HoodSetAbsWhileHeld(
48-
(Hood.HOOD_INITIATION_LINE_POSITION + Hood.HOOD_TRENCH_MID_POSITION) / 2.0));
47+
addCommands(new HoodSetAbsWhileHeld((Hood.INITIATION_LINE_POSITION + Hood.TRENCH_MID_POSITION) / 2.0));
4948
addCommands(new DriveStraightOnHeading(-0.3, DistanceUnits.INCHES, 144, 50));
5049

5150
// turn on the intake to pick up balls
@@ -70,6 +69,6 @@ public StartFWRendezvous() {
7069
addCommands(new IntakeSetRollers(0.0));
7170

7271
// turn the wheel off now that the shooting is all done
73-
addCommands(new HoodSetAbsWhileHeld(Hood.HOOD_TARGET_ZONE_POSITION));
72+
addCommands(new HoodSetAbsWhileHeld(Hood.TARGET_ZONE_POSITION));
7473
}
7574
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public StartFWShoot3() {
2828
addCommands(new ParallelCommandGroup( // run the following commands in parallel:
2929
new IntakeSetPosition(RobotContainer.intake.PIVOT_DOWN),
3030
new ShooterWheelSet(ShooterWheel.SHOOTER_WHEEL_INITIATION_LINE_SPEED),
31-
new HoodSetAbsWhileHeld(Hood.HOOD_INITIATION_LINE_POSITION),
31+
new HoodSetAbsWhileHeld(Hood.INITIATION_LINE_POSITION),
3232
new TurretSetAbs((0.0 * Turret.TICKS_PER_DEGREE), Turret.WAIT_FOR_DONE)));
3333

3434
addCommands(new ShooterReadyAimFire(1.0));
@@ -37,6 +37,6 @@ public StartFWShoot3() {
3737
addCommands(new ParallelCommandGroup( // below commands in parallel
3838
new ShooterWheelSet(0.0), //
3939
new IntakeSetRollers(0.0), // turn off the rollers
40-
new HoodSetAbs(Hood.HOOD_STARTING_POSITION)));
40+
new HoodSetAbs(Hood.STARTING_POSITION)));
4141
}
4242
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*----------------------------------------------------------------------------*/
2+
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
3+
/* Open Source Software - may be modified and shared by FRC teams. The code */
4+
/* must be accompanied by the FIRST BSD license file in the root directory of */
5+
/* the project. */
6+
/*----------------------------------------------------------------------------*/
7+
8+
package org.mayheminc.robot2020.commands;
9+
10+
import org.mayheminc.robot2020.RobotContainer;
11+
12+
import edu.wpi.first.wpilibj2.command.CommandBase;
13+
14+
public class ShooterAimToTarget extends CommandBase {
15+
/**
16+
* Creates a new TurretAimToTarget.
17+
*/
18+
public ShooterAimToTarget() {
19+
// Use addRequirements() here to declare subsystem dependencies.
20+
addRequirements(RobotContainer.hood);
21+
addRequirements(RobotContainer.shooterWheel);
22+
addRequirements(RobotContainer.turret);
23+
}
24+
25+
// Called when the command is initially scheduled.
26+
@Override
27+
public void initialize() {
28+
// aim the hood and turret
29+
RobotContainer.hood.setPosition(RobotContainer.targeting.getDesiredHood());
30+
RobotContainer.turret.setPositionAbs(RobotContainer.targeting.getDesiredAzimuth());
31+
}
32+
33+
// Called every time the scheduler runs while the command is scheduled.
34+
@Override
35+
public void execute() {
36+
// aim the hood and turret
37+
RobotContainer.hood.setPosition(RobotContainer.targeting.getDesiredHood());
38+
RobotContainer.turret.setPositionAbs(RobotContainer.targeting.getDesiredAzimuth());
39+
}
40+
41+
// Called once the command ends or is interrupted.
42+
@Override
43+
public void end(boolean interrupted) {
44+
if (!interrupted) {
45+
RobotContainer.shooterWheel.setSpeed(RobotContainer.targeting.getDesiredWheelSpeed());
46+
47+
// want to also schedule a command here that does the shooting!
48+
}
49+
}
50+
51+
// Returns true when the command should end.
52+
@Override
53+
public boolean isFinished() {
54+
return (RobotContainer.hood.isAtPosition() && RobotContainer.turret.isAtDesiredPosition());
55+
}
56+
}

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,30 @@ public ShooterPermissionToFire() {
3030
// Called when the command is initially scheduled.
3131
@Override
3232
public void initialize() {
33-
// do the following: command the shooterWheel to turn at speed, aimTurret,
34-
// aimHood
33+
// command the shooterWheel to turn at speed, aimHood, aimTurret
34+
// RobotContainer.shooterWheel.setSpeed(RobotContainer.targeting.getDesiredWheelSpeed());
35+
RobotContainer.hood.setPosition(RobotContainer.targeting.getDesiredHood());
36+
RobotContainer.turret.setPositionAbs(RobotContainer.targeting.getDesiredAzimuth());
3537
}
3638

3739
// Called every time the scheduler runs while the command is scheduled.
3840
@Override
3941
public void execute() {
42+
// command the shooterWheel to turn at speed
43+
// RobotContainer.shooterWheel.setSpeed(RobotContainer.targeting.getWheelSpeedFromY());
44+
45+
// aim the hood
46+
RobotContainer.hood.setPosition(RobotContainer.targeting.getDesiredHood());
47+
48+
// aim the turret
49+
RobotContainer.turret.setPositionAbs(RobotContainer.targeting.getDesiredAzimuth());
50+
51+
// if speed is good, turret is aimed, and hood is aimed, start shooting!
4052
// if shooterWheels at speed, turret aimed, and hood aimed, then fire!
4153
// firing actions as follows:
4254
// feed roller after 0.0 seconds since start of firing
4355
// chimney after 0.1 seconds since start of firing
56+
4457
}
4558

4659
// Returns true when the command should end.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ public ShooterReadyAimFire(double waitDuration) {
4646
new ParallelRaceGroup(new FeederSet(0.0), new ChimneySet(0.0), new RevolverSetTurntable(0.0), new Wait(0.1)));
4747

4848
// Lower the hood now that we're done shooting
49-
addCommands(new HoodSetAbsWhileHeld(Hood.HOOD_STARTING_POSITION));
49+
addCommands(new HoodSetAbsWhileHeld(Hood.STARTING_POSITION));
5050
}
5151
}

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414
public class Hood extends SubsystemBase implements PidTunerObject {
1515
private final MayhemTalonSRX hoodTalon = new MayhemTalonSRX(Constants.Talon.SHOOTER_HOOD);
1616

17-
public final static double HOOD_STARTING_POSITION = 0;
18-
public final static double HOOD_TARGET_ZONE_POSITION = 5000;
19-
public final static double HOOD_INITIATION_LINE_POSITION = 65000;
20-
public final static double HOOD_TRENCH_MID_POSITION = 80000;
21-
17+
private final static int MIN_POSITION = 0;
18+
private final static int MAX_POSITION = 90000;
2219
private final static double POSITION_TOLERANCE = 1000.0;
2320

21+
public final static double STARTING_POSITION = 0;
22+
public final static double TARGET_ZONE_POSITION = 5000;
23+
public final static double INITIATION_LINE_POSITION = 65000;
24+
public final static double TRENCH_MID_POSITION = 80000;
25+
2426
private double m_desiredPosition = 0.0;
2527

2628
/**
@@ -49,9 +51,9 @@ private void configureTalon() {
4951
hoodTalon.setInverted(true);
5052
hoodTalon.setSensorPhase(true);
5153

52-
hoodTalon.configForwardSoftLimitThreshold(100000);
54+
hoodTalon.configForwardSoftLimitThreshold(MAX_POSITION);
5355
hoodTalon.configForwardSoftLimitEnable(true);
54-
hoodTalon.configReverseSoftLimitThreshold(0);
56+
hoodTalon.configReverseSoftLimitThreshold(MIN_POSITION);
5557
hoodTalon.configReverseSoftLimitEnable(true);
5658
}
5759

@@ -63,6 +65,7 @@ public void periodic() {
6365

6466
private void UpdateDashboard() {
6567
SmartDashboard.putNumber("Shooter Hood Pos", hoodTalon.getPosition());
68+
SmartDashboard.putNumber("Shooter Hood Setpoint", m_desiredPosition);
6669
}
6770

6871
public void zero() {

0 commit comments

Comments
 (0)