Skip to content

Commit

Permalink
woooo commands finally set up? - skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelx0281 committed Jan 10, 2024
1 parent 9b061d2 commit e1314a0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/main/java/org/sciborgs1155/robot/Climber/Climber.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import monologue.Logged;
import monologue.Monologue.LogFile;
import edu.wpi.first.wpilibj2.command.Subsystem;

public class Climber extends SubsystemBase{
public class Climber extends SubsystemBase implements Logged{
//need to add measurements for clamping(don't want to overextend the climber)

//sim objects
Expand All @@ -43,30 +45,31 @@ public class Climber extends SubsystemBase{
private final PIDController pid = new PIDController(kP, kI, kD);
private final ElevatorFeedforward ff = new ElevatorFeedforward(kS, kG, kV, kA);

//setVoltage or speed?? - DutyCyleEncoders?
public void setMotorSpeed(double speed){
motor.set(MathUtil.clamp(speed, -1.0, 1.0));
}

// public Command stopExtending() {

// }

// public Command fullyExtend() {
// moveToSetpoint();
// }

// run when first scheduled
public void climberInit() {
// sets position to be 0 (remember to keep climber retracted at first)
encoder.setPosition(0.0);
}

public Command stopExtending() {
return run(() -> setMotorSpeed(0.0));
}

public Command fullyExtend() {
moveToSetpoint(MAX_EXTENSION);
}

public Command retract(){
return moveToSetpoint(0);
}

public Command moveToSetpoint(double setpoint){
return run(() -> setMotorSpeed(ff.calculate(encoder.getVelocity()) + pid.calculate(encoder.getPosition(), setpoint)));
return run(() -> setMotorSpeed(ff.calculate(encoder.getVelocity()) + pid.calculate(encoder.getPosition(), setpoint))).withName("moving to setpoint");
}


Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/sciborgs1155/robot/Ports.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ public static final class ClimberPorts {
public static final int kV = -1;
public static final int kA = -1;
public static final int kG = -1;

public static final double MAX_EXTENSION = 1;
}
}

0 comments on commit e1314a0

Please sign in to comment.