OpenDRIVE elevation round-trip: carry z on points, refit profiles on export - #96
Merged
Conversation
The parser used to collapse <elevationProfile> to a boolean and drop the records. Now it retains the <elevation> polynomials, the reference-line sampler pins elevation breakpoints as stations and evaluates z at each sample, and odrToShapes stamps the height onto every boundary point. z rides on the point (optional PointProps.z / ImportedPoint.z), so plain 2D editing preserves it without extra plumbing. Absent or all-zero z still means "no elevation".
Regenerated roads used to always emit an empty <elevationProfile/>. New odrElevationFit reconstructs centerline z(s) from boundary-point heights and least-squares fits piecewise cubics (0.05 m tolerance), and the exporter emits the fitted <elevation> records. Roads whose points carry no z keep emitting the empty profile, so existing 2D-only flows are unchanged. Includes unit tests (11 cases).
Inserting elevation breakpoints as stations perturbed the plan-view fit: CARLA exports carry dense all-zero <elevation> records, and the extra clustered samples rotated short junction roads enough to open contact- point gaps (ASAM QC lane_smoothness failure on Town01, caught by CI). Height is now evaluated at the unmodified 2D station set. The z interpolation error from skipping a breakpoint is bounded by the <= 5 m station spacing and realistic vertical-curve curvature — centimetres, the same order as the export refit tolerance. A regression test pins that elevation records leave stations (s, x, y, hdg) untouched, with breakpoints deliberately off the 5 m grid so dedup cannot mask it. Town01 round-trip output is byte-identical to the pre-elevation baseline again (header timestamp aside); ASAM QC is clean.
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.
Summary
OpenDRIVE elevation used to be dropped at import (collapsed to a boolean) and
regenerated roads always emitted an empty
<elevationProfile/>. This PR makeselevation survive a full import → edit → export round trip.
What changed
Import (
0ce7e22)<elevation>polynomial records instead of discarding them.zat every station. Elevationrecords deliberately do not alter the 2D station set (
5c26085) —inserting them perturbed the plan-view fit and opened ASAM QC
contact-point gaps on CARLA maps with dense all-zero records.
odrToShapesstamps the height onto each boundary point as an optionalz(world meters) onPointProps/ImportedPoint.Export (
19bfaa7)odrElevationFitreconstructs centerlinez(s)from boundary-pointheights and least-squares fits piecewise cubic
<elevation>records(0.05 m tolerance, matching the plan-view fitting error budget).
z.Design notes
zrides on the point, so plain 2D editing (dragging, nudges, rotationbake) preserves it without extra plumbing.
zstill emits the empty<elevationProfile/>, so existing 2D-only flows are byte-identical.<lateralProfile>) is out of scope and still droppedwith a warning.
Tests
__tests__/exporter/odrElevation.test.ts):z evaluation, fit accuracy against known polynomials, all-zero
fallback, editing-preservation invariants, and a regression pin that
elevation records leave the 2D stations untouched.
byte-identical to the pre-elevation baseline, header timestamp aside).