Repository navigation
feat(core): a route model and writer for OpenSCENARIO (p8-s3) (#247) - #541
Merged
Merged
Conversation
The first of four PRs for lane-anchored routes: the model and the writer. The reader, the resolver and the editor tool follow. <RoutingAction> gains its AssignRouteAction arm, carrying an inline <Route> of <Waypoint>s. Waypoints hold the same osc::Position variant a teleport does, so a route RoadMaker authors names lanes rather than points in space — which is what makes it follow the roads beneath it (GW-6 step 7) instead of staying behind where it was drawn. ★ The struct is RouteWaypoint, never Waypoint. roadmaker::Waypoint is the road-authoring node type, and an unqualified Waypoint declared inside roadmaker::osc would shadow it in exactly the translation unit that needs both — the resolver, which walks a route across a network whose roads are shaped by authoring waypoints. Third name this header's surrounding tree has already taken, after `signals` (a Qt macro) and RoadNetwork; the rule those established is that the element keeps its schema name and the struct gets an unambiguous one. The inline route is an OPTIONAL arm. An <AssignRouteAction> whose content is a <CatalogReference> keeps it on the preserved tier, and no empty <Route> is invented — that would replace a legal document with an invalid one. Refusals mirror the schema: fewer than two waypoints, a nameless route, a duplicate route name (uniqueness is document-wide, since routes are siblings once flattened and a simulator resolves one by name), a waypoint with no routeStrategy. Waypoint positions go through the SAME check_road_relative_position an init teleport does, so a route cannot smuggle past it a reference the placement layer would have refused. A <WorldPosition> waypoint warns, citing routing.ambiguous_route_waypoints, and does not block the write. It is legal; it merely fails to say which lane the route takes where several meet. routing.route_waypoints_locations is deliberately NOT declared yet. Whether a road belongs to a junction is a fact about the .xodr, and a Scenario holds only the roadId string — so it belongs with the network-aware checker in the next PR. Declaring it early would make it the decoration rules.hpp's own header rules out, which EveryRuleConstantIsCitedBySomeFinding enforces. Twelve new writer tests, all six sabotages caught. One of them was incoherent first: the routing arm's own-element test built three separate PrivateActions, which produce three elements no matter what the writer does with the arms. Rebuilt around ONE action carrying all three, it fails as it should. Refs #247.
JArmandoAnaya
force-pushed
the
feat/p8-s3-route-model
branch
from
August 1, 2026 01:07
2afc9c7 to
75b676d
Compare
This was referenced Aug 1, 2026
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.
First of four PRs for #247 (lane-anchored routes): the model and the writer. The reader, the resolver + edit factories, and the editor Route tool follow.
What lands
<RoutingAction>gains itsAssignRouteActionarm, carrying an inline<Route>of<Waypoint>s. Waypoints hold the sameosc::Positionvariant a teleport does, so a route RoadMaker authors names lanes rather than points in space — which is what makes it follow the roads beneath it (GW-6 step 7) instead of staying behind where it was drawn.Spec basis: OpenSCENARIO XML 1.4.0 §7.7 —
Route(@nameand@closedbothuse="required",ParameterDeclarations?thenWaypoint{2,}),Waypoint(@routeStrategyrequired,Position1..1),AssignRouteAction(RouteXORCatalogReference),RoutingAction(five-way choice).★ The struct is
RouteWaypoint, neverWaypointroadmaker::Waypointis the road-authoring node type (road/authoring.hpp). An unqualifiedWaypointdeclared insideroadmaker::oscwould shadow it in exactly the translation unit that needs both — the resolver in PR 3, which walks a route across a network whose roads are shaped by authoring waypoints.That is the third name this header's surrounding tree has already taken, after
signals(a Qt macro, which stops the struct declaration parsing in any editor TU) andRoadNetwork(the kernel's most central type). The rule those two established: the element keeps its schema name, the struct gets an unambiguous one.Design calls
The inline route is an optional arm. An
<AssignRouteAction>whose content is a<CatalogReference>keeps it on the preserved tier and no empty<Route>is invented — that would replace a legal document with an invalid one.Waypoint positions go through the same
check_road_relative_positionan init teleport does. A route cannot smuggle past it a reference the placement layer would have refused. Shared, not re-implemented.Route names are unique document-wide, not per entity: they are siblings once flattened, and a simulator resolves a route by name.
A
<WorldPosition>waypoint warns and does not block, citingasam.net:xosc:1.0.0:routing.ambiguous_route_waypoints. It is legal; it merely fails to say which lane the route takes where several meet, so the same file routes differently in two simulators. RoadMaker never authors one — this fires on foreign input.routing.route_waypoints_locationsis deliberately NOT declared yet. "Route waypoints should not be located in junctions" is not reachable fromvalidate_scenarioat all: whether a road belongs to a junction is a fact about the.xodr, and aScenarioholds only the roadId string (ADR-0014 §5). It arrives with the network-aware checker in PR 3. Declaring it early would make it exactly the decorationrules.hpp's own header rules out — andXoscRules.EveryRuleConstantIsCitedBySomeFindingwould have failed on it.Verification
cmake --build --preset ci-macosclean; 3107/3107ctest --preset ci-macospass.RoutingAction>AssignRouteAction>Route>Waypoint>Position>LanePosition, each sliced inside the last.<ParameterDeclarations>after the waypoints, always emitting the wrapper, always emitting a<Route>, dropping the two-waypoint minimum, skipping the shared position check, and nesting the routing arm inside the teleport's<PrivateAction>.PrivateActions, which produce three elements no matter what the writer does with the arms. Rebuilt around ONE action carrying all three (a shape unreachable from parsing, so this writer test is its only guard), it fails as it should.find("<Waypoint ", 1)re-finds the first waypoint, so the ordering check would have passed on a document holding only one. Fixed to search from the first waypoint's close tag.git ls-files '*.cpp' '*.hpp' | xargs clang-format --dry-run --Werrorclean.Refs #247.