REV Motor IO Layer#190
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request implements a REV motor IO layer to support REV Robotics motor controllers (SparkMax/SparkFlex) alongside the existing CTRE TalonFX implementation. The changes follow the hardware abstraction pattern established in the codebase and include an example rotary subsystem implementation with comprehensive testing.
Key Changes
- REV Motor IO Implementation: Added
MotorIORevandMotorIORevSimclasses to support REV motor controllers with real hardware and simulation - Interface Enhancements: Modified
MotorIOandMechanisminterfaces to throwNotImplementedExceptionfor unimplemented default methods and added simplifiedrunPosition/runVelocityoverloads - Example RevRotary Subsystem: Created a new example rotary subsystem using the REV IO layer with constants, commands, and comprehensive test coverage
Reviewed changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| vendordeps/REVLib.json | Added REV Robotics library dependency v2025.0.3 |
| vendordeps/photonlib.json | Updated PhotonVision library from v2025.3.1 to v2025.3.2 |
| vendordeps/libgrapplefrc2025.json | Updated Grapple library from 2025.0.8 to 2025.1.3 |
| src/main/java/frc/lib/io/motor/MotorIORev.java | New real hardware implementation for REV motor controllers |
| src/main/java/frc/lib/io/motor/MotorIORevSim.java | New simulation implementation for REV motor controllers |
| src/main/java/frc/lib/io/motor/MotorIO.java | Added simplified position/velocity methods and NotImplementedException to defaults |
| src/main/java/frc/lib/io/motor/MotorIOSim.java | Enhanced documentation for simulation interface methods |
| src/main/java/frc/lib/io/motor/MotorIOTalonFX.java | Added comprehensive documentation for existing TalonFX methods |
| src/main/java/frc/lib/mechanisms/Mechanism.java | Changed default methods to throw NotImplementedException |
| src/main/java/frc/lib/mechanisms/rotary/RotaryMechanism.java | Added position logging in periodic method |
| src/main/java/frc/lib/mechanisms/rotary/RotaryMechanismReal.java | Implemented new simplified position/velocity methods |
| src/main/java/frc/lib/mechanisms/rotary/RotaryMechanismSim.java | Implemented new simplified methods and close() |
| src/main/java/frc/robot/subsystems/revRotary/RevRotary.java | New example rotary subsystem using REV motors |
| src/main/java/frc/robot/subsystems/revRotary/RevRotaryConstants.java | Configuration and factory methods for RevRotary subsystem |
| src/main/java/frc/robot/subsystems/rotary/Rotary.java | Refactored enum pattern to use LoggedTunableNumber, removed close() |
| src/main/java/frc/robot/subsystems/rotary/RotaryConstants.java | Added comprehensive documentation |
| src/main/java/frc/robot/RobotContainer.java | Integrated RevRotary subsystem and added cleanup helper |
| src/main/java/frc/robot/Ports.java | Added CAN ID for REV rotary subsystem motor |
| src/main/java/frc/lib/util/LoggedTunableNumber.java | Modified initialization timing (with debug statements) |
| src/main/java/frc/lib/io/objectDetection/*.java | Package rename from objectdetection to objectDetection (casing fix) |
| src/test/java/frc/robot/subsystems/revRotary/RevRotaryTest.java | Comprehensive test suite for RevRotary subsystem |
| src/test/java/frc/robot/subsystems/rotary/RotaryTest.java | Added additional test cases |
| src/test/java/frc/robot/RobotContainerTest.java | Enhanced setup and added REV subsystem cleanup |
| .github/instructions/default.instructions.md | New AI assistant instructions documenting library architecture |
…s.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…s.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@copilot open a new pull request to apply changes based on the comments in this thread. Do not implement the following though:
|
|
@garrett928 I've opened a new pull request, #218, to work on those changes. Once the pull request is ready, I'll request review from you. |
…ng typo, and unused field Co-authored-by: garrett928 <22306616+garrett928@users.noreply.github.com>
Clean up review feedback from PR #190
|
This is my favorite PR ever |
|
Slopbot at its finest ✨ |
|
I think this is good to go, I can't approve since I opened the PR |
| return ""; | ||
| throw new NotImplementedException("This method has not been implemented"); |
There was a problem hiding this comment.
This method needs to be removed for replay support
| {} | ||
| { | ||
| throw new NotImplementedException("This method has not been implemented"); | ||
| } |
| {} | ||
| { | ||
| throw new NotImplementedException("This method has not been implemented"); | ||
| } |
| {} | ||
| { | ||
| throw new NotImplementedException("This method has not been implemented"); | ||
| } |
| { | ||
| throw new NotImplementedException("This method has not been implemented"); | ||
| } | ||
|
|
| new LoggedTunableNumber("Rotary RAISED", -90); | ||
|
|
||
| @RequiredArgsConstructor | ||
| @SuppressWarnings("Immutable") |
| RAISED(Degrees.of(RAISED_SETPOINT.get())); | ||
|
|
||
| private final Angle setpoint; | ||
| HOME(null), |
There was a problem hiding this comment.
HOME is not a setpoint, it shouldn't act as one. Also, for future reference, avoid setting anything to null unless it is a small, local variable.
|
|
||
| /** | ||
| * Helper method for unit testing. | ||
| * | ||
| * If we have any REV subsystems, close their resources here. IF we don't do this then we will | ||
| * get duplicate CAN ID errors when running multiple tests. | ||
| */ | ||
| public void closeREVSubsystems() | ||
| { | ||
| revRotary.close(); | ||
| } |
There was a problem hiding this comment.
Make RobotContainer implement AutoClosable and close all necessary subsystems.
| @BeforeEach | ||
| void setup() | ||
| { | ||
| assert HAL.initialize(500, 0); // initialize the HAL, crash if failed |
There was a problem hiding this comment.
this is what your tests do:
public class RotaryTest implements AutoCloseable {
Rotary rotary;
@BeforeEach // this method will run before each test
void setup()
{
assert HAL.initialize(500, 0); // initialize the HAL, crash if failed
rotary = RotaryConstants.get();
/* enable the robot */
DriverStationSim.setEnabled(true);
DriverStationSim.notifyNewData();
/* delay ~100ms so the devices can start up and enable */
Timer.delay(0.100);
}There was a problem hiding this comment.
Yes, it's wrong. I didn't write that. You can either
a. Change just yours
b. Change all of them
or
c. Do nothing
As to what you choose? I don't really care.
| public void close() | ||
| { | ||
| rotary.close(); | ||
| if (rotary != null) { |
There was a problem hiding this comment.
this was a left over from some debugging. i'll remove it
|
@CJendantix thanks for the review. Sorry for the delay, I've been busy with work and the holidays. I'm fine with not merging the PR until its feature parity with CTRE. I'll make the changes you suggested and add the rest of the sim support |
Pull request was converted to draft
@garrett928 is working on the rev io implementation
Changes
default.instructions.mdfor copilot usagemotorioandmechanism.javato throw anotimplementedexceptionerror.defaultyou dont have to implemented them. They have a default empty{}implementation. But this means you could call it in a subsytem and not know its empty. This change should allow the flexibility of some motors to have some but not all methods and still warn the user of an obvious error of using a non implemented function.Known issues
Bugs Found
waituntilgoalcommandbugI tried writing a test for this command and it fail for both rev and talonfx. below was the fixture
homeCommandI tried writing a test for the
homecommandin therotary.javabut it also failed