Fix: calibrated scales keep their size, and snap in the unit they were written in - #31
Merged
Merged
Conversation
…e written in Two defects in the reference calibrator, and a real-data check it lacked. Scales were rounded to six decimal places. A field in 1e-7 degrees, a common GPS encoding, came back with scale 0.0, and the DBC layer reads a zero scale as 1. Scales and offsets now keep seven significant figures. Snapping only knew round numbers in the reference's own unit. A GPS logger reports m/s; a car's DBC says 0.01 km/h per bit, which is 0.0027778 m/s and no round number at all, so it never snapped. Given the reference unit, the snapper now also tries km/h, mph and knots (and degrees for radians, psi and bar for kPa), under the same bias gate, and the DBC signal is written in the unit the manufacturer used. The lag search had only been tested on the shipped sample. A new phase in acceptance_new_sources.py runs the calibrator on comma.ai's comma2k19 segment (MIT): a real Toyota RAV4's CAN bus, a u-blox receiver, and openpilot's DBC as the answer key. From the GNSS speed alone it finds 0x0B4 bytes 5-6 (vehicle speed) and the four 0x0AA wheel words, R2 0.998; the wheel scale comes back as 0.01 km/h with an offset of -67.1 against openpilot's -67.67; a UTC-stamped reference lands within 0.17 s of the true clock offset, which is the receiver's own latency (0.16 s by an independent cross-correlation that does not use CanLab); and the signal it writes decodes the car within 0.9% of openpilot's decode.
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.
Defects
snap_calibrationnow also tries km/h, mph and knots (degrees for radians, psi and bar for kPa), under the same bias gate, andcandidate_to_signal_defwrites the signal in the unit the manufacturer used, noting the reference unit in its description.A real-data check the calibrator lacked
phase_referenceinacceptance_new_sources.pyfetches comma.ai's comma2k19 example segment (MIT, about 6 MB): one minute of a Toyota RAV4's CAN bus with a u-blox receiver, and openpilot's DBC as the answer key. From the GNSS speed alone:The vehicle-speed field does not snap to 0.01 km/h, correctly: this car's speed signal reads about 0.8% above GPS, and forcing the round scale would move the decode past the 1% bias budget.
pytest -q: 726 passed.phase_reference: 4/4. ruff clean.