Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public class IntakeDeploySubsystem extends BaseSetpointSubsystem<Angle,Double>
public final DoubleProperty maxPidAcceleration;
public final DoubleProperty collectionDownwardPressure;
public final DoubleProperty voltageRampTime;
public AngleProperty offset;
public DoubleProperty tolerance;
public DoubleProperty readinessTimeoutSeconds;

@Inject
Expand Down Expand Up @@ -82,6 +84,7 @@ public IntakeDeploySubsystem(XCANMotorController.XCANMotorControllerFactory xcan

this.retractedPosition = propertyFactory.createPersistentProperty("RetractedPosition", -10.0);
this.extendedPosition = propertyFactory.createPersistentProperty("ExtendedPosition", -145.0);
this.offset = propertyFactory.createPersistentProperty("Offset from target", Degrees.of(3)); //TODO change to correct value

this.manualControlPower = propertyFactory.createPersistentProperty("ManualControlPower", 0.2);

Expand Down Expand Up @@ -194,4 +197,11 @@ public Current getMotorCurrent() {
public Command getWaitForAtGoalCommand() {
return new SimpleWaitForMaintainerCommand(this, () -> readinessTimeoutSeconds.get());
}

public boolean intakeDeployIsExtended() {
var current = getCurrentValue();
return current.isNear
(Degrees.of(extendedPosition.get()),
(Degrees.of(tolerance.get())));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package competition.subsystems.intake_deploy.commands;

import competition.subsystems.intake_deploy.IntakeDeploySubsystem;
import edu.wpi.first.wpilibj.Timer;
import xbot.common.command.BaseCommand;
import xbot.common.properties.DoubleProperty;
import xbot.common.properties.PropertyFactory;

public class IntakeDeployRetryCommand extends BaseCommand {
IntakeDeploySubsystem intakeDeploySubsystem;
public DoubleProperty timeout;
public double startTime = 0;

public IntakeDeployRetryCommand(IntakeDeploySubsystem intakeDeploy, PropertyFactory pf) {
this.intakeDeploySubsystem = intakeDeploy;
addRequirements(intakeDeploy);
this.timeout = pf.createPersistentProperty("SecondsInTimeout", 3.0);
}

public boolean isTimeoutExpired() {
return Timer.getFPGATimestamp() > startTime + timeout.get();
}


@Override
public boolean isFinished() {
return (isTimeoutExpired()) || intakeDeploySubsystem.intakeDeployIsExtended();
}
}
Loading