Skip to content

Commit

Permalink
fix: addressed comments from Reviewers (setPositionMeters method name…
Browse files Browse the repository at this point in the history
… and lowering elevator after scoring in trap)

Co-authored-by: Luna <[email protected]>
  • Loading branch information
rutmanz and gonzalezgonzalezl committed Feb 4, 2024
1 parent 8120e58 commit 9577b9d
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ public TrapAndClimbSequence(Elevator elevator, Hooks hooks, Tramp tramp) {
new ParallelDeadlineGroup(
new WaitCommand(Constants.Tramp.TRAP_SCORING_TIME_SECONDS),
new ScoreInTrap(tramp) //TODO: Do whatever to this but not my job
),
new ElevatorSetpointCommand(elevator, ElevatorState.BOTTOM)
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,43 @@
import static org.team1540.robot2024.Constants.Elevator.*;

public class Elevator extends SubsystemBase {
private final ElevatorIO io;
private final ElevatorIOInputsAutoLogged inputs = new ElevatorIOInputsAutoLogged();
private final AverageFilter positionFilter = new AverageFilter(10);
private final ElevatorIO elevatorIO;
private final ElevatorIOInputsAutoLogged elevatorInputs = new ElevatorIOInputsAutoLogged();
private final AverageFilter elevatorPositionFilter = new AverageFilter(10);
private double setpointMeters;


public Elevator(ElevatorIO elevatorIO) {
this.io = elevatorIO;
this.elevatorIO = elevatorIO;
}

// periodic
public void periodic(){
io.updateInputs(inputs);
Logger.processInputs("Elevator", inputs);
MechanismVisualiser.setElevatorPosition(inputs.positionMeters);
elevatorIO.updateInputs(elevatorInputs);
Logger.processInputs("Elevator", elevatorInputs);
MechanismVisualiser.setElevatorPosition(elevatorInputs.positionMeters);

positionFilter.add(inputs.positionMeters);
elevatorPositionFilter.add(elevatorInputs.positionMeters);
}

public void setElevatorPosition(double positionMeters) {
positionMeters = MathUtil.clamp(positionMeters, Constants.Elevator.ELEVATOR_MINIMUM_HEIGHT, Constants.Elevator.ELEVATOR_MAX_HEIGHT);
setpointMeters = positionMeters;
io.setPositionMeters(setpointMeters);
public void goToSetpoint(double newSetpointMeters) {
newSetpointMeters = MathUtil.clamp(newSetpointMeters, Constants.Elevator.ELEVATOR_MINIMUM_HEIGHT, Constants.Elevator.ELEVATOR_MAX_HEIGHT);
setpointMeters = newSetpointMeters;
elevatorIO.setSetpointMeters(setpointMeters);

positionFilter.clear();
elevatorPositionFilter.clear();
}

public boolean isAtSetpoint() {
return MathUtil.isNear(setpointMeters, positionFilter.getAverage(), ERROR_TOLERANCE);
return MathUtil.isNear(setpointMeters, elevatorPositionFilter.getAverage(), ERROR_TOLERANCE);
}

public void setVoltage(double voltage) {
io.setVoltage(voltage);
elevatorIO.setVoltage(voltage);
}

public void stop() {
io.setVoltage(0.0);
elevatorIO.setVoltage(0.0);
}

@AutoLogOutput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ElevatorIOInputs {

default void updateInputs(ElevatorIOInputs inputs) {}

default void setPositionMeters(double position) {}
default void setSetpointMeters(double position) {}

default void setVoltage(double voltage) {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void setVoltage(double volts) {
elevatorAppliedVolts = MathUtil.clamp(volts, -12.0, 12.0);
}
@Override
public void setPositionMeters(double position) {
public void setSetpointMeters(double position) {
isClosedLoop = true;
setpoint = new TrapezoidProfile.State(position, 0.0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void updateInputs(ElevatorIOInputs inputs) {
}

@Override
public void setPositionMeters(double positionMeters) {
public void setSetpointMeters(double positionMeters) {
leader.setControl(motionMagicOut.withPosition(positionMeters));
}

Expand Down
10 changes: 5 additions & 5 deletions vendordeps/photonlib-json-1.0.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"fileName": "photonlib.json",
"name": "photonlib",
"version": "v2024.2.2",
"version": "v2024.2.3",
"uuid": "515fe07e-bfc6-11fa-b3de-0242ac130004",
"frcYear": "2024",
"mavenUrls": [
Expand All @@ -14,7 +14,7 @@
{
"groupId": "org.photonvision",
"artifactId": "photonlib-cpp",
"version": "v2024.2.2",
"version": "v2024.2.3",
"libName": "photonlib",
"headerClassifier": "headers",
"sharedLibrary": true,
Expand All @@ -29,7 +29,7 @@
{
"groupId": "org.photonvision",
"artifactId": "photontargeting-cpp",
"version": "v2024.2.2",
"version": "v2024.2.3",
"libName": "photontargeting",
"headerClassifier": "headers",
"sharedLibrary": true,
Expand All @@ -46,12 +46,12 @@
{
"groupId": "org.photonvision",
"artifactId": "photonlib-java",
"version": "v2024.2.2"
"version": "v2024.2.3"
},
{
"groupId": "org.photonvision",
"artifactId": "photontargeting-java",
"version": "v2024.2.2"
"version": "v2024.2.3"
}
]
}

0 comments on commit 9577b9d

Please sign in to comment.