Skip to content

Commit

Permalink
command factory method example
Browse files Browse the repository at this point in the history
  • Loading branch information
Vignesh1234587 committed Dec 7, 2024
1 parent 8c079f3 commit 45d9f2c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/frc/robot/subsystems/arms/Pivot.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import edu.wpi.first.math.trajectory.TrapezoidProfile;
import edu.wpi.first.units.measure.Angle;
import edu.wpi.first.units.measure.AngularVelocity;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.constants.SimConstants;
import frc.robot.constants.SubsystemConstants;
Expand Down Expand Up @@ -122,6 +124,16 @@ public void setPivotCurrent(double currentDegrees) {
pivotCurrentStateDegrees = new TrapezoidProfile.State(currentDegrees, 0);
}

public Command setPivotTarget(double goal, double threshold){


return new InstantCommand(()-> setPivotGoal(goal), this).until(()-> atGoal(threshold));

}




@Override
public void periodic() {
pivot.updateInputs(pInputs);
Expand All @@ -140,4 +152,5 @@ public void periodic() {
Logger.recordOutput("pivot goal", goalDegrees);
// This method will be called once per scheduler run
}

}

0 comments on commit 45d9f2c

Please sign in to comment.