Skip to content

Commit 9061d1d

Browse files
authored
Merge pull request #33 from IgniteRobotics/feature/intake-improvements
Feature/intake improvements
2 parents 3d97a62 + 2a1858b commit 9061d1d

File tree

5 files changed

+41
-127
lines changed

5 files changed

+41
-127
lines changed

src/main/java/frc/robot/RobotContainer.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import frc.robot.subsystems.indexer.IndexerSubsystem;
2424
import frc.robot.subsystems.intake.IntakeSubsystem;
2525
import frc.robot.subsystems.shooter.ShooterSubsystem;
26-
import frc.robot.subsystems.shooter.SimpleShooterSubsystem;
2726

2827
@Logged
2928
public class RobotContainer {
@@ -46,7 +45,6 @@ public class RobotContainer {
4645
@Logged(name = "Shooter")
4746
public final ShooterSubsystem shooter = new ShooterSubsystem();
4847

49-
public final SimpleShooterSubsystem simpleShooter = new SimpleShooterSubsystem();
5048

5149
private final SendableChooser<Command> autoChooser;
5250

@@ -105,10 +103,10 @@ public void configureTestBindings() {
105103
driverJoystick.rightBumper().onTrue(Commands.runOnce(SignalLogger::start));
106104
driverJoystick.leftBumper().onTrue(Commands.runOnce(SignalLogger::stop));
107105

108-
operatorJoystick.y().whileTrue(simpleShooter.sysIdQuasistatic(SysIdRoutine.Direction.kForward));
109-
operatorJoystick.a().whileTrue(simpleShooter.sysIdQuasistatic(SysIdRoutine.Direction.kReverse));
110-
operatorJoystick.b().whileTrue(simpleShooter.sysIdDynamic(SysIdRoutine.Direction.kForward));
111-
operatorJoystick.x().whileTrue(simpleShooter.sysIdDynamic(SysIdRoutine.Direction.kReverse));
106+
operatorJoystick.y().whileTrue(shooter.sysIdQuasistatic(SysIdRoutine.Direction.kForward));
107+
operatorJoystick.a().whileTrue(shooter.sysIdQuasistatic(SysIdRoutine.Direction.kReverse));
108+
operatorJoystick.b().whileTrue(shooter.sysIdDynamic(SysIdRoutine.Direction.kForward));
109+
operatorJoystick.x().whileTrue(shooter.sysIdDynamic(SysIdRoutine.Direction.kReverse));
112110

113111
// Reset the field-centric heading on left bumper press.
114112
driverJoystick.start().onTrue(drivetrain.runOnce(drivetrain::seedFieldCentric));
@@ -140,7 +138,7 @@ public void configureTeleopBindings() {
140138
driverJoystick
141139
.leftTrigger()
142140
.whileTrue(shooter.launchLemonsCommand())
143-
.onFalse(simpleShooter.stopLaunchLemonsNoPIDCommand());
141+
.onFalse(shooter.stopLaunchLemonsNoPIDCommand());
144142

145143
driverJoystick
146144
.rightTrigger()
@@ -149,8 +147,8 @@ public void configureTeleopBindings() {
149147

150148
operatorJoystick
151149
.leftTrigger()
152-
.whileTrue(simpleShooter.launchLemonsCommandNoPID())
153-
.onFalse(simpleShooter.stopLaunchLemonsNoPIDCommand());
150+
.whileTrue(shooter.launchLemonsCommandNoPID())
151+
.onFalse(shooter.stopLaunchLemonsNoPIDCommand());
154152

155153
operatorJoystick
156154
.rightTrigger()

src/main/java/frc/robot/subsystems/intake/IntakeConstants.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package frc.robot.subsystems.intake;
22

3+
import com.ctre.phoenix6.configs.MotorOutputConfigs;
34
import com.ctre.phoenix6.configs.Slot0Configs;
45
import com.ctre.phoenix6.configs.SoftwareLimitSwitchConfigs;
6+
import com.ctre.phoenix6.signals.NeutralModeValue;
57

68
public class IntakeConstants {
79

@@ -53,6 +55,13 @@ public static SoftwareLimitSwitchConfigs createExtensionSoftwareLimitSwitchConfi
5355
return configs;
5456
}
5557

58+
public static MotorOutputConfigs createExtensionMotorOutputConfigs() {
59+
MotorOutputConfigs newConfigs = new MotorOutputConfigs();
60+
// newConfigs.Inverted = InvertedValue.Clockwise_Positive;
61+
newConfigs.NeutralMode = NeutralModeValue.Coast;
62+
return newConfigs;
63+
}
64+
5665
public static final double SAFE_HOMING_EFFORT = -0.2;
5766
public static final double SAFE_STATOR_LIMIT = 0.8;
5867
}

src/main/java/frc/robot/subsystems/intake/IntakePreferences.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,7 @@ private IntakePreferences() {}
1818
new DoublePreference("Intake/Retract Percent (for without PID)", -0.1); // in percent
1919
public static DoublePreference rollerIntakePercent =
2020
new DoublePreference("Intake/Roller Intake Percent (for without PID)", 0.1); // in percent
21+
22+
public static DoublePreference dislodgePosition =
23+
new DoublePreference("Intake/Extension Dislodge Position", 1.5);
2124
}

src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,19 @@ public IntakeSubsystem() {
5454
extensionMotor
5555
.getConfigurator()
5656
.apply(IntakeConstants.createExtensionSoftwareLimitSwitchConfigs());
57+
extensionMotor.getConfigurator().apply(IntakeConstants.createExtensionMotorOutputConfigs());
5758
extensionMotor.setPosition(0);
5859
extensionTarget = Rotations.of(0);
5960
extensionControl = new PositionTorqueCurrentFOC(0);
6061
}
6162

6263
@Override
6364
public void periodic() {
64-
// rollerMotor.setControl(rollerControl.withVelocity(rollerVelocityTarget.in(RotationsPerSecond)));
65-
// extensionMotor.setControl(extensionControl.withPosition(extensionTarget.in(Rotations)));
65+
rollerMotor.setControl(rollerControl.withVelocity(rollerVelocityTarget.in(RotationsPerSecond)));
66+
extensionMotor.setControl(
67+
extensionControl
68+
.withPosition(extensionTarget.in(Rotations))
69+
.withOverrideCoastDurNeutral(true));
6670
}
6771

6872
public Command spinRollerCommand() {
@@ -83,12 +87,12 @@ private void setRollerVoltage(double magnitude) {
8387
}
8488

8589
public Command startRollerNoPID() {
86-
return runOnce(() -> rollerMotor.set(IntakePreferences.rollerIntakePercent.getValue()))
90+
return run(() -> rollerMotor.set(IntakePreferences.rollerIntakePercent.getValue()))
8791
.withName("Set Roller Percent");
8892
}
8993

9094
public Command stopRollerNoPID() {
91-
return runOnce(() -> rollerMotor.set(0)).withName("Stop Roller No PID");
95+
return run(() -> rollerMotor.set(0)).withName("Stop Roller No PID");
9296
}
9397

9498
@Logged(name = "Extension Setpoint", importance = Importance.CRITICAL)
@@ -124,11 +128,23 @@ public Command collectCommand() {
124128
}
125129

126130
public Command stowCommand() {
127-
return stopRollerCommand()
128-
.andThen(setIntakeExtensionCommand(Rotations.of(0)))
131+
return setIntakeExtensionCommand(Rotations.of(0))
132+
.andThen(stopRollerCommand())
133+
.andThen(setIntakeExtensionCommand(Rotations.of(0)).repeatedly())
129134
.withName("Stow Intake");
130135
}
131136

137+
public Command dislodgeCommand() {
138+
return spinRollerCommand()
139+
.andThen(
140+
setIntakeExtensionCommand(Rotations.of(IntakePreferences.dislodgePosition.getValue()))
141+
.andThen(
142+
setIntakeExtensionCommand(
143+
Rotations.of(IntakePreferences.intakeCollectPosition.getValue()))))
144+
.repeatedly()
145+
.withName("Dislodge Intake");
146+
}
147+
132148
public Command homeIntakeCommand() {
133149
return runEnd(
134150
() -> extensionMotor.set(IntakeConstants.SAFE_HOMING_EFFORT),

src/main/java/frc/robot/subsystems/shooter/SimpleShooterSubsystem.java

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

0 commit comments

Comments
 (0)