Skip to content

Conversation

@Lyssia-Seiden
Copy link
Contributor

adds supply current logging, standardizes on getValueAsDouble() instead of getValue(), makes sure to only use arrays where needed, and makes elevator properly log both motors.

Copy link
Contributor

@kevinclark kevinclark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing blocking, but I think the level of repetition (pulling out status signals, setting update timings) is enough that you should strongly consider making a proper class or record

Comment on lines 19 to 24
private final StatusSignal<Double> pivotVelocity = pivotMotor.getVelocity();
private final StatusSignal<Double> pivotVoltage = pivotMotor.getMotorVoltage();
private final StatusSignal<Double> pivotAmps = pivotMotor.getStatorCurrent();
private final StatusSignal<Double> pivotStatorCurrentAmps = pivotMotor.getStatorCurrent();
private final StatusSignal<Double> pivotSupplyCurrentAmps = pivotMotor.getSupplyCurrent();
private final StatusSignal<Double> pivotTempC = pivotMotor.getDeviceTemp();
private final StatusSignal<Double> pivotRotations = pivotMotor.getPosition();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is repeated enough you should really make it a class. A record with a custom constructor that takes the motor would really clean this up trivially.

Copy link
Contributor

@Awesomeplayer165 Awesomeplayer165 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing blocking too. Might be helpful to look into array usecases and see if they can be abstracted to an array if they aren't being used for special array use cases (iteration).

EDIT: talked to @Lewis-Seiden, gonna break into two variables then adopt @kevinclark suggestion.

Comment on lines 15 to 16
public double[] elevatorStatorCurrentAmps = new double[] {};
public double[] elevatorSupplyCurrentAmps = new double[] {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like Kevin's -- not blocking -- why are we using an array for this? In other languages, this is represented as a tuple, which is an indicator for abstracting to a class. (also see below relating comment).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

especially since this is not being used for iteration.

public Command runCurrentZeroing() {
return this.run(() -> io.setVoltage(-1.0))
.until(() -> inputs.elevatorCurrentAmps[0] > 40.0)
.until(() -> inputs.elevatorStatorCurrentAmps[0] > 40.0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this syntax is very scary for me. Not sure if this is the syntax or norm for Java, but readers can be unsure of the value difference between index 0, 1, ... (even how many there are? Abstracting to a class like mentioned above should clear up your intentions). I always repeat the phrase: write once, read 10 times.

Copy link
Contributor

@Awesomeplayer165 Awesomeplayer165 Feb 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also see this line being repeated in src/main/java/frc/robot/subsystems/shooter/ShooterSubystem.java :154, but with a different syntax of using the array. maybe clearing some of this stuff up might help clear confusion among fresh eyes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree. Seems like a good use for a record. Additionally, the value appears to be initialized to a 0 length array but then we do array access here that would be out of bounds if the value isn't set to something else. If the size of the array changes it strongly implies that maybe array isn't the right container.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the whole array use was a holdover from the akit examples, where they wanted you to use an array for all motor current and temperature since they consider motor count an implementation detail. i dont really agree w their view of it either, and will change it

inputs.elevatorVelocityMetersPerSec = physicsSim.getVelocityMetersPerSecond();
inputs.elevatorAppliedVolts = volts;
inputs.elevatorCurrentAmps = new double[] {physicsSim.getCurrentDrawAmps()};
inputs.elevatorStatorCurrentAmps = new double[] {physicsSim.getCurrentDrawAmps()};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sometimes using arrays can be confusing the total length. also since this length can be whole replaced by a new array (which looks like is what you are doing everytime -- constructing a new array instead of setting existing values).

@Lyssia-Seiden Lyssia-Seiden requested a review from kevinclark April 7, 2024 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants