Repository navigation
Simulate tank drive motor position and velocity - #51
Merged
Merged
Conversation
The sim only moved the robot's pose; the drive motors never reported a velocity, and their position was off by a factor of 2 because the rotations-to-meters scaling (0.5 m per rotation) wasn't applied. EduSimulator now writes each side's position and velocity back into the mock motors, so they show up in AdvantageScope like on a real robot: - Turning is split across the sides using a 0.6 m track width, so the left and right motors spin opposite ways when turning in place. - The robot stops when disabled, matching the swerve sim. Before, the last motor power kept it driving. LinearEngine and RotationEngine still decide how the robot moves, so the challenge tests (which drive those engines directly) are unaffected. DriveToPositionCommandTest still ends at 5.002332505667951. Adds EduSimulatorTest covering forward driving, turning in place and the disabled lockout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Makes the tank drive motors in the simulator report position and velocity, so you can graph them in AdvantageScope like on a real robot. This also would let us do things like changing the drive to position test to read from the motor encoders instead of using our weird fake distance sensor.
Before
PoseSubsystem(and the tests'setPosition) treat 1 rotation as 0.5 m. Odometry and the pose were consistent with each other, so it didn't show on the field, but the motor readings andpose.getPosition()were wrong.Changes (
EduSimulator)pose.scalingFactorFromRotationsToMeters.LinearEnginedistance, sopose.getPosition()and odometry match the engine.forceDriverStationEnabledForUnitTestsflag.LinearEngineandRotationEnginestill decide how the robot moves. The challenge tests drive those engines directly, so keeping them means a PID tuned against the tests behaves the same in the sim.Voltage was already logged (the SCL mock reports power × 12), at
AdvantageKit/FrontLeft/CANMotorController/Voltage.Not included
MockCANMotorControllerhas no way to set it and reports the power value as its current. That needs an SCL change first.Verification
EduSimulatorTest: forward driving (voltage, matching left/right velocity, encoder position equals the engine distance), turning in place (opposite velocities, no forward travel) and the disabled lockout. All pass.maintest for test: the same 4 pass and the same 16 student-exercise tests fail as designed.DriveToPositionCommandTeststill ends at5.002332505667951.gradlew checkstylepasses.🤖 Generated with Claude Code