Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advantagekit Rewrite #4

Merged
merged 32 commits into from
Sep 25, 2023
Merged

Advantagekit Rewrite #4

merged 32 commits into from
Sep 25, 2023

Conversation

Lewis-Seiden
Copy link
Collaborator

Opening pr, probably need to go over it one more time before merging

@Awesomeplayer165
Copy link
Contributor

Let's try to go over it today. Looks fine though

Copy link

@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.

More when I have time, but this should get you started.


import org.littletonrobotics.junction.AutoLog;

/** Add your docs here. */

Choose a reason for hiding this comment

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

Remove

leader.config_kF(0, 0);
follower = new HighlanderFalcon(Constants.ElevatorConstants.elevatorFollowerID);
follower.set(ControlMode.Follower, Constants.ElevatorConstants.elevatorMotorID);
follower.configSupplyCurrentLimit(new SupplyCurrentLimitConfiguration(true, 30.0, 30.0, 0.5));

Choose a reason for hiding this comment

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

Should current/voltage limits be constants?

public double[] currentAmps = new double[] {};
}

public abstract void updateInputs(ElevatorIOInputs inputs);

Choose a reason for hiding this comment

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

There's a few good reasons to avoid mutation methods and return a new object instead. First is that if you instead make this getInputs or something similar which returns a value, you can chain on that value vs needing to have a separate line for just updating the output variable. Second is that mutation can be a major pitfall when dealing with concurrent systems. Third is that if you want to unit test, mocking or stubbing out this result is much more complicated. Two of those three don't really apply in our codebase, but it's a useful habit to get into.

Honestly, the only good reason for mutation functions like this is if the object you're dealing with is particularly expensive to create. This doesn't look like that.

Strongly encourage you to replace this (and the analogous method in the other interfaces) to return a value instead.

elevatorFollower.configVoltageCompSaturation(10);
LoggingWrapper.shared.add("elevatorsim", mech2d);
zeroMotor();
io = Robot.isReal() ? new ElevatorIOFalcon() : new ElevatorIOSim();

Choose a reason for hiding this comment

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

nitpick: recommend using this. for member variables. Means I don't go looking for where it's defined.

Choose a reason for hiding this comment

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

Also, it's going to be worth considering as you add more Sim versions (assuming you do that) whether that check (Robot.isReal) should be hoisted up a level and you have a Sim subsystem vs each subsystem having to know which parts are sim'd out.

@Lewis-Seiden
Copy link
Collaborator Author

we've basically been using this as new main anyways so merge time

@Lewis-Seiden Lewis-Seiden merged commit 89f29ea into main Sep 25, 2023
1 check passed
@Lewis-Seiden Lewis-Seiden deleted the advantagekit branch September 25, 2023 03:08
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.

None yet

3 participants