Repository navigation
Conversation
Robot code that compensates for the battery reads hardwareMap.voltageSensor.iterator().next(). A real robot's map always answers (its hubs' voltage sensors); an empty FakeHardwareMap threw NoSuchElementException at INIT. The runner now registers a 12 V FakeVoltageSensor named "Control Hub" when the map has none, and leaves a map with its own sensor alone.
This branch has not been deployed
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.
What
When a run starts and the
FakeHardwareMaphas no voltage sensor,OpModeRunnerregisters a 12 VFakeVoltageSensorunder"Control Hub"(the name a Control Hub's own sensor has in a real configuration). A mapthat already has a voltage sensor is left alone. Adds
OpModeRunner.DEFAULT_VOLTAGE_SENSOR_NAME.Why
Robot code that compensates for the battery (feedforward scaled by
12 / volts, which is common for flywheels anddrivetrains) reads
hardwareMap.voltageSensor.iterator().next(). A real robot's map always answers that: every hubhas a voltage sensor. An empty fake map throws
NoSuchElementExceptionat INIT, so the team's unchanged OpModecrashes before it starts, and the stack trace points into their subsystem constructor, not at the sim. We hit this
when a teammate added voltage compensation to our launcher: every OpMode test failed at once.
FakeVoltageSensoralready existed; this just means a team doesn't have to know to register one. It's in therunner rather than the
FakeHardwareMapconstructor so a new map stays empty (size(),getAlland the existingfidelity tests are unchanged), and a test that wants another voltage registers its own sensor and gets no default.
How I tested it
New
opmode/DefaultBatteryTest: an OpMode readingvoltageSensor.iterator().next()ininit()gets 12.0 V from abare map, under
"Control Hub"; with the test's own 11.2 V sensor registered, it gets that one and the runner addsnone. With the runner's call commented out, the first test fails with the
NoSuchElementException../gradlew :SimLoop:testDebugUnitTest --rerun: 1253 tests, 0 failed.:examples:testDebugUnitTestand:SimLoop:desktop:testpass.bash tools/leak-gate/leak-gate.shpasses../gradlew testpasses on my machineNew or changed behaviour has a test
If I touched docs or public javadoc:
./gradlew :SimLoop:docsSitepasses (toucheddocs/packages/opmode.mdand added a public constant with javadoc; docsSite not run here, it needs the mkdocs toolchain)
Checklist