-
Notifications
You must be signed in to change notification settings - Fork 0
Pulse hopper roller during shooting #358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
d52ae43
95f038c
0dab8ec
eff4e8a
0cac40d
f92a641
97c47da
e3b8de7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| package competition.subsystems.hopper_roller; | ||
|
|
||
| import competition.electrical_contract.ElectricalContract; | ||
| import edu.wpi.first.units.measure.AngularVelocity; | ||
| import edu.wpi.first.wpilibj2.command.Command; | ||
| import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; | ||
| import xbot.common.command.BaseSubsystem; | ||
| import xbot.common.command.NamedRunCommand; | ||
| import xbot.common.controls.actuators.XCANMotorController; | ||
|
|
@@ -26,10 +28,13 @@ public class HopperRollerSubsystem extends BaseSubsystem { | |
| final DoubleProperty collectPower; | ||
| final DoubleProperty intakePower; | ||
| final AngularVelocityProperty intakeVelocity; | ||
| final AngularVelocityProperty intakePulseVelocity; | ||
| final AngularVelocityProperty collectVelocity; | ||
| final AngularVelocityProperty ejectVelocity; | ||
| final BooleanProperty useVelocityControl; | ||
| final DoubleProperty voltageRampTime; | ||
| final DoubleProperty intakePulseDuration; | ||
| final DoubleProperty intakePulseHighDuration; | ||
|
|
||
| @Inject | ||
| public HopperRollerSubsystem(ElectricalContract electricalContract, | ||
|
|
@@ -67,8 +72,11 @@ public HopperRollerSubsystem(ElectricalContract electricalContract, | |
|
|
||
| useVelocityControl = pf.createPersistentProperty("Use Velocity Control", true); | ||
| intakeVelocity = pf.createPersistentProperty("Intake Velocity", RPM.of(3000)); | ||
| intakePulseVelocity = pf.createPersistentProperty("Intake Pulse Velocity", RPM.of(3200)); | ||
| collectVelocity = pf.createPersistentProperty("Collect Velocity", RPM.of(3000)); | ||
| ejectVelocity = pf.createPersistentProperty("Eject Velocity", RPM.of(-3000)); | ||
| intakePulseDuration = pf.createPersistentProperty("Intake Pulse Duration Seconds", 0.5); | ||
| intakePulseHighDuration = pf.createPersistentProperty("Intake Pulse High Duration Seconds", 0.5); | ||
|
|
||
| if (hopperRollerMotor != null) { | ||
| hopperRollerMotor.setClosedLoopRampRates( | ||
|
|
@@ -78,6 +86,13 @@ public HopperRollerSubsystem(ElectricalContract electricalContract, | |
| } | ||
| } | ||
|
|
||
| public void setVelocityTarget(AngularVelocity velocity) { | ||
| if (hopperRollerMotor == null) { | ||
| return; | ||
| } | ||
| hopperRollerMotor.setVelocityTarget(velocity); | ||
| } | ||
|
Comment on lines
+89
to
+94
|
||
|
|
||
| public void setEjectPower() { | ||
| if (hopperRollerMotor == null) { | ||
| return; | ||
|
|
@@ -149,4 +164,18 @@ public Command getStopCommand() { | |
| } | ||
|
|
||
| public Command getCollectCommand() {return new NamedRunCommand(getName() + "-collect", this::setCollectPower, this);} | ||
|
|
||
| public Command getIntakePulseCommand() { | ||
| var commandGroup = new SequentialCommandGroup(); | ||
| commandGroup.setName(getName() + "-intake-pulse"); | ||
| commandGroup.addCommands( | ||
| new NamedRunCommand( | ||
| getName() + "-intake-pulse-low", | ||
| () -> setVelocityTarget(intakeVelocity.get()), this).withTimeout(intakePulseDuration.get())); | ||
| commandGroup.addCommands( | ||
| new NamedRunCommand( | ||
| getName() + "-intake-pulse-high", | ||
| () -> setVelocityTarget(intakePulseVelocity.get()), this).withTimeout(intakePulseHighDuration.get())); | ||
| return commandGroup.repeatedly(); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Probably too late to change this but we shoulddd probably rename this to intakePulseHighVelocity just to sync its name with the duration properties