Repository navigation
Update maxswerve example to REV's 2026 MAXSwerve template - #100
Merged
Merged
Conversation
Port REVrobotics/MAXSwerve-Java-Template (b614589, "Update for 2026") to the RobotPy 2027 API, replacing the old 2025-era port that no longer imported. - Drive feedforward is nominal voltage / free speed, as REVLib reads kV in volts per unit of velocity (the old 1 / free speed was ~12x too weak) - Add configs.py like the template's Configs, including the Through Bore Encoder V2 absolute encoder preset and rev.FeedbackSensor - Drop the slew rate limiting and swerveutils, which the template removed - REVLib 2027 has no encoder conversion factors, so the module converts between native units and meters/radians and the gains are scaled - WPILib 2027 has no SwerveControllerCommand or HolonomicDriveController, so add a minimal SwerveControllerCommand for the autonomous routine - Use Systemcore's OnboardIMU instead of the ADIS16470 - Test the feedforward, unit conversions, X formation binding and autonomous, and run the example in run_examples.py Refs #99 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The maxswerve example uses commands2, which the test environment didn't have. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #99.
Updates
examples/maxswerveto REV's current MAXSwerve Java template (REVrobotics/MAXSwerve-Java-Template @ b614589, "Update for 2026"), written for the 2027 API onmain. The old example didn't import under 2027 (wpimath.controlleris gone).It also takes
maxswerveoff the ignore list inexamples/run_examples.py, so CI now runs its tests like the other examples. Because the example uses commands2,tests/requirements.txtnow includesrobotpy-commands-v2>=2027.0.0a7,<2028. The 2027 version has to be named, or pip installs the stable 2026 release; the requirement will need updating along with the wpilib version.What follows the template
configs.py(new) mirrorsConfigs.java:nominalVoltage / free speed, i.e. kV in volts. The old1 / free speedis maxswerve example: crashes in robotInit on 2026.0.4, and its drive feedforward is 12x too weak under REVLib 2026 #99's 12x-too-weak feedforward;rev.FeedbackSensor.swerveutils.pyand the slew-rate limiting are gone, as they are in the template.Where it differs, because of 2027 API changes
No encoder conversion factors (removed from REVLib 2027). The SPARKs run in native units: RPM and rotations for the drive encoder, rotations for the absolute encoder. The module converts to meters and radians itself. The template's gains are kept in its own units and scaled when configured:
Position wrapping is enabled over one rotation.
No
SwerveControllerCommandorHolonomicDriveControllerin WPILib 2027.swervecontrollercommand.pyis a small equivalent with the same behaviour:DrivetrainSplineTrajectoryGenerator;Gyro: the ADIS16470 class is gone, so the example uses
wpilib.OnboardIMU(FLAT mounting).Buttons: 2027 renumbered the Xbox buttons. The template's set-X binding (raw button 6) is now
RIGHT_BUMPER.TimedRobot changes: initialization is in
__init__, and test mode is now utility mode. Usage reporting ishal.report_usage("RobotDrive", "MAXSwerve").Testing
All runs used RobotPy 2027.0.0a7 and robotpy-rev 2027.0.0a7.post1 on Linux.
robotpy test --builtininexamples/maxswervegives 11 passed and 1 skipped (test_opmode, which every example skips). The new tests cover:examples/run_examples.pypasses for all 12 examples, andexamples/check_header.pyandblack --checkare clean.SparkMaxSim.iteratewith a simple motor model (not included in this PR):Merging this won't fix the 2026.0.4 release that #99 was reported against. The fix for that release is in the issue.