Skip to content

Commit

Permalink
Added HangingCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
sVampified committed Feb 24, 2024
1 parent ea30e4e commit 2e012a4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/java/competition/subsystems/arm/ArmSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class ArmSubsystem extends BaseSetpointSubsystem<Double> implements DataF

public double extendPower;
public double retractPower;
public double hangPower;

public final DoubleProperty powerMax;
public final DoubleProperty powerMin;
Expand Down Expand Up @@ -85,6 +86,7 @@ public class ArmSubsystem extends BaseSetpointSubsystem<Double> implements DataF
public enum ArmState {
EXTENDING,
RETRACTING,
HANGING,
STOPPED
}

Expand Down Expand Up @@ -125,6 +127,7 @@ public ArmSubsystem(PropertyFactory pf, XCANSparkMax.XCANSparkMaxFactory sparkMa
setBrakeEnabled(false);
extendPower = 0.1;
retractPower = -0.1;
hangPower = -0.2;

powerMax = pf.createPersistentProperty("PowerMax", 0.45);
powerMin = pf.createPersistentProperty("PowerMin", -0.25);
Expand Down Expand Up @@ -416,6 +419,11 @@ public void retract() {
armState = ArmState.RETRACTING;
}

public void hang() {
setPower(hangPower);
armState = ArmState.HANGING;
}

public void stop() {
setPower(0.0);
armState = ArmState.STOPPED;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package competition.subsystems.arm.commands;

import competition.electrical_contract.ElectricalContract;
import competition.subsystems.arm.ArmSubsystem;
import xbot.common.command.BaseCommand;

import javax.inject.Inject;

public class HangingCommand extends BaseCommand {
ArmSubsystem armSubsystem;

@Inject
public HangingCommand(ArmSubsystem armSubsystem) {
addRequirements(armSubsystem);
this.armSubsystem = armSubsystem;
}

@Override
public void initialize() {
log.info("HangingCommand initializing");
}

@Override
public void execute() {
armSubsystem.hang();
}

}

0 comments on commit 2e012a4

Please sign in to comment.