Conversation
Makes it easier to tune PIDs
Moving subsystem hardware to its own file in order to encourage separation of subsystem logic and hardware interaction Add loggable inputs
NOTE This commit fails build checks, do not use. I am merely committing to track progress
Complies with Anshul formatting
Also add supplementary comments
Forgot to remove CANCoder object before last commit
There was a problem hiding this comment.
Generally one should avoid checking in editor preferences/settings into code repos.
| // NOTE The configuration only needs to be applied to the leader-motor. The | ||
| // follower-motor MUST obey the configuration of the leader-motor. | ||
| public static final KrakenConfiguration kMotorConfiguration = | ||
| new KrakenConfiguration(true, true, 0.0, 0.0, NeutralModeValue.Brake, false, 0.0, 0.0); |
There was a problem hiding this comment.
When you have a lot of settings like this (and below with PivotGains) it is useful to line them up vertically, and place an end-of-line comment after each entry telling what the setting is.
| configureBindings(); | ||
| } | ||
|
|
||
| private void configureBindings() {} |
There was a problem hiding this comment.
In the trunk we'll want to put the code block brackets on their own lines so that the templates can insert their lines between the curly brackets.
| import frc.robot.subsystems.pivot.PivotKrakenHardware; | ||
|
|
||
| public class RobotContainer { | ||
| private final Pivot kPivot = |
There was a problem hiding this comment.
We wouldn't use the name "kPivot" because this isn't a constant. We can call it just "pivot", or perhaps "mPivot" if you like the m == instance variable naming scheme.
m - Instance (method) variable
k - Constant (Konstant :-) )
s - Static variable
g - Global variable
There was a problem hiding this comment.
This still needs to be addressed
| supplyCurrentAmps = List.of(kLeadMotor.getSupplyCurrent(), kFollowMotor.getSupplyCurrent()); | ||
| temperatureCelsius = List.of(kLeadMotor.getDeviceTemp(), kFollowMotor.getDeviceTemp()); | ||
|
|
||
| BaseStatusSignal.setUpdateFrequencyForAll( |
There was a problem hiding this comment.
I think I understand what this is doing, but it's a bit obtuse. We probably need a quick description of Status Signals above, or perhaps a link to the docs. This is also the only place in the code I've seen the use of an ellipsis method signature, and rookie coders will likely be thrown off by it.
| } | ||
|
|
||
| // Hardware is where we interact with the motors and sensors directly | ||
| private final PivotKrakenHardware kPivotHardware; |
There was a problem hiding this comment.
This would have an 'm' prefix, not 'k', since its state can change. Same with kPivotInputs.
So we'd have mPivotHardware, mPivotInputs, mCurrentPivotGoal, and mCurrentPivotGoalPosition.
| private PivotGoal currentPivotGoal = null; | ||
|
|
||
| @AutoLogOutput(key = "Pivot/CurrentGoalPosition") | ||
| private Rotation2d currentPivotGoalPosition = new Rotation2d(); |
There was a problem hiding this comment.
Would this variable be better named with Rotation instead of Position?
There was a problem hiding this comment.
Typically any set point for control over a "position" has the suffix "position" regardless of it being for linear or angular movement (or at least that should be a team standard).
| @@ -0,0 +1,123 @@ | |||
| // Copyright (c) 2024 FRC 6328 | |||
There was a problem hiding this comment.
When we pull a class in from another repo, we should include a link back to the original file. This will allow us to find the file in case there are bug fixes or we need to track down better documentation.
| @@ -0,0 +1,26 @@ | |||
| // Copyright (c) FIRST and other WPILib contributors. | |||
There was a problem hiding this comment.
Same here, we should give a link to the original file. I've added comments to Anshul's use of this file, and I've rolled it into the BaseCode, so I won't repeat those comments here.
| setPosition(currentPivotGoalPosition.getRadians()); | ||
| } | ||
|
|
||
| // Update feedback, feedforward, and motion magic gains if we change them from network tables |
There was a problem hiding this comment.
This is another place where an ellipsed method signature is used, so the role of this function isn't immediately evident to someone new to the code. A comment to guide readers would help.
| temperatureCelsius.get(1)); | ||
|
|
||
| // Optimize the CANBus utilization by explicitly telling all CAN signals we | ||
| // are not using to simply not be sent over the CANBus |
There was a problem hiding this comment.
You should describe why you are passing 0 and 1, or at least use comments to give an idea of what is being passed. I assume this is the call?
https://api.ctr-electronics.com/phoenix6/release/java/com/ctre/phoenix6/hardware/ParentDevice.html#optimizeBusUtilization()
There was a problem hiding this comment.
Since this code is meant to work with an arm design similar to Redux (where there are two motors working together to move a mass) some of the telemetry data will be the same. Status signals are how we get that telemetry data from a TalonFX motor controller - and it's more convenient to store them in objects that can be accessed throughout the class.
Knowing this, the internal position and velocity of the two motors must be the same (since they are mechanically linked to the arm) however the applied volts, supply current draw, and temperature would be different for the motors. So to log them more conveniently, I store them in a list where index 0 is the leader motor and index 1 is the follower motor. When setting the update frequency at which telemetry to be set, every status signal that I wish to modify must be passed into the method so I call both the leader's (0) and the follower's (1) status signals. I can add documentation if it's not clear in the code that this was just a way of conveniently storing the status signals.
| * @param v The new voltage gain | ||
| * @param a The new acceleration gain | ||
| * @param g The new gravity gain | ||
| */ |
There was a problem hiding this comment.
Eventually we'll need docs or links on how to solve for kS, kV, kA, and kG.
|
@barbute , have you looked over and addressed all the comments in this review yet? |
| import frc.robot.subsystems.pivot.PivotKrakenHardware; | ||
|
|
||
| public class RobotContainer { | ||
| private final Pivot kPivot = |
There was a problem hiding this comment.
This still needs to be addressed
Add custom setpoint Fully tuned arm Add soft limits for voltage control
Merge tuned pivot to pivot base
Pivot code to review