-
Notifications
You must be signed in to change notification settings - Fork 240
Unify Spark motor & encoder classes #322
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
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The can frames need updated when you use setAbsoluteEncoder or else telemetry will fail. I need some more information on what was removed bc it was type specific. This includes spark specific can frames BECAUSE we do not want to flood the CANBUS any more than we have too
| if (encoder == null) | ||
| { | ||
| this.absoluteEncoder = Optional.empty(); | ||
| cfg.closedLoop.feedbackSensor(FeedbackSensor.kPrimaryEncoder); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incomplete, needs can frame optimizations and enabling here.
| burnFlash(); | ||
| } else if (encoder instanceof SparkAnalogEncoderSwerve || encoder instanceof SparkEncoderSwerve) | ||
| { | ||
| cfg.closedLoop.feedbackSensor(encoder instanceof SparkAnalogEncoderSwerve |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incomplete, needs can frame optimizations and enabling here.
|
I am conflicted on this bc it breaks the pattern we have setup and would require following the same pattern for the TalonFX at the same time. At the same time i do love deduplicating the code. Could you do the same with the TalonFX and TalonFXS? |
I'm not sure what you mean here. The If there are outstanding problems with the CAN bus utilization, perhaps we can address that as a followup issue. |
I hear you. Originally, I dove into this because of what I mentioned before (lacking support for using an external analog encoder with a Spark Flex), but realized there's nothing but abstraction stopping the use of the existing
Sure, I'll take a look! |
|
Re: TalonFX/TalonFXS Phoenix6 doesn't offer useful abstraction around the motor controller & configuration classes (short of the |
Hello,
REV significantly refactored REVLib for their 2025 release. To make use of their abstractions, and to help keep the code DRY, this PR unifies the SparkMax/SparkFlex swerve motor & encoder classes under shared parent classes.
swervelib.motorsSparkSwervewas implemented to use the abstractcom.revrobotics.spark.SparkBaseandcom.revrobotics.spark.config.SparkBaseConfig.SparkMaxSwerveandSparkFlexSwerveare now simple helper subclasses that facilitate construction.SparkMaxBrushedMotorSwervewas not refactored and remains a direct subclass ofSwerveAbsoluteEncoder.swervelib.encodersSparkEncoderSwervereplaces the mostly-duplicateSparkMaxEncoderSwerveandSparkFlexEncoderSwerveclasses.SparkAnalogEncoderSwervereplacesSparkMaxAnalogEncoderSwerveto work with a genericSparkSwerve. This enables having a Spark Flex with an absolute encoder attached to the analog pin, which is so far unsupported in YAGSL.swervelib.json.DeviceJsonSparkEncoderSwerve:integratedattachedcanandmagcanandcodersparkflex_integratedsparkflex_attachedsparkflex_canandmagsparkflex_canandcoderSparkAnalogEncoderSwervewith 3.3V:sparkmax_analogsparkflex_analogspark_analogSparkAnalogEncoderSwervewith 5V:sparkmax_analog5vsparkflex_analog5vspark_analog5vFeel free to use any or all of this. These changes still need testing, which Team 5171 will be doing in the coming days.
Migrated from BroncBotz3481/YAGSL-Lib#14