Skip to content

Commit

Permalink
Uncommented arm rotate in coldStart, fixed duty cycle encoder
Browse files Browse the repository at this point in the history
  • Loading branch information
Liammurray19 committed Feb 20, 2025
1 parent 9fcf361 commit 5630123
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
24 changes: 12 additions & 12 deletions src/main/java/frc/robot/maps/ColdStart.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,18 @@ public ElevatorMap getElevatorMap() {
new ValueRange(0, 57.5), new ValueRange(6, 53), pid, feedForward);
}

// @Override
// public ArmRotateMap getArmRotateMap() {
// CSSparkFlex motor = new CSSparkFlex(10);
// DutyCycleEncoder absEncoder = new DutyCycleEncoder(1);
// SparkFlexConfig config = new SparkFlexConfig();
// config.smartCurrentLimit(30);
// config.idleMode(IdleMode.kBrake);
// motor.getMotorController().configure(config, ResetMode.kNoResetSafeParameters, PersistMode.kPersistParameters);
// ProfiledPIDController pid = new ProfiledPIDController(0, 0, 0, new Constraints(0, 0));
// ArmFeedforward feedForward = new ArmFeedforward(0, 0, 0);
// return new ArmRotateMap(motor, absEncoder, new ArmRotateMap.ArmRotatePresetValues(0, 0, 0, 0, 0), pid, new ValueRange(0, 0), new ValueRange(0, 0), feedForward);
// }
@Override
public ArmRotateMap getArmRotateMap() {
CSSparkFlex motor = new CSSparkFlex(10);
DutyCycleEncoder absEncoder = new DutyCycleEncoder(1);
SparkFlexConfig config = new SparkFlexConfig();
config.smartCurrentLimit(30);
config.idleMode(IdleMode.kBrake);
motor.getMotorController().configure(config, ResetMode.kNoResetSafeParameters, PersistMode.kPersistParameters);
ProfiledPIDController pid = new ProfiledPIDController(0, 0, 0, new Constraints(0, 0));
ArmFeedforward feedForward = new ArmFeedforward(0, 0, 0);
return new ArmRotateMap(motor, absEncoder::get, new ArmRotateMap.ArmRotatePresetValues(0, 0, 0, 0, 0), pid, new ValueRange(0, 0), new ValueRange(0, 0), feedForward);
}

@Override
public CoralManipMap getCoralManipMap() {
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/frc/robot/maps/subsystems/ArmRotateMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.chopshop166.chopshoplib.logging.LoggableMap;
import com.chopshop166.chopshoplib.logging.data.MotorControllerData;
import com.chopshop166.chopshoplib.motors.SmartMotorController;
import com.chopshop166.chopshoplib.sensors.IAbsolutePosition;
import com.chopshop166.chopshoplib.sensors.IEncoder;
import com.chopshop166.chopshoplib.sensors.MockEncoder;

Expand Down Expand Up @@ -58,7 +59,7 @@ public double getValue(ArmRotatePresets preset) {
}

public SmartMotorController motor;
public final IEncoder encoder;
public final IAbsolutePosition encoder;
public final ArmRotatePresetValues armRotatePreset;
public final ProfiledPIDController pid;
public final ValueRange hardLimits;
Expand All @@ -72,7 +73,7 @@ public ArmRotateMap() {

}

public ArmRotateMap(SmartMotorController motor, IEncoder encoder, ArmRotatePresetValues armRotatePreset,
public ArmRotateMap(SmartMotorController motor, IAbsolutePosition encoder, ArmRotatePresetValues armRotatePreset,
ProfiledPIDController pid, ValueRange hardLimits, ValueRange softLimits, ArmFeedforward armFeedforward) {
this.motor = motor;
this.encoder = encoder;
Expand All @@ -87,12 +88,10 @@ public ArmRotateMap(SmartMotorController motor, IEncoder encoder, ArmRotatePrese
public void updateData(Data data) {
data.motor.updateData(motor);
data.rotationAbsAngleDegrees = encoder.getAbsolutePosition();
data.rotatingAngleVelocity = encoder.getRate();
}

public static class Data extends DataWrapper {
public MotorControllerData motor = new MotorControllerData();
public double rotationAbsAngleDegrees;
public double rotatingAngleVelocity;
}
}
4 changes: 2 additions & 2 deletions src/main/java/frc/robot/subsystems/ArmRotate.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public Command move(DoubleSupplier rotateSpeed) {
public Command moveTo(ArmRotatePresets level) {
PersistenceCheck setPointPersistenceCheck = new PersistenceCheck(30, pid::atGoal);
return runOnce(() -> {
pid.reset(getArmAngle(), getData().rotatingAngleVelocity);
pid.reset(getArmAngle(), 0.0);
}).andThen(run(() -> {
Logger.recordOutput("Pid at goal", pid.atGoal());
}).until(setPointPersistenceCheck)).withName("Move To Set Angle");
Expand Down Expand Up @@ -113,7 +113,7 @@ public void periodic() {

@Override
public void reset() {
getMap().encoder.reset();
// Nothing to reset
}

@Override
Expand Down

0 comments on commit 5630123

Please sign in to comment.