Skip to content

matlab/matlab-agentic-toolkit / skills-catalog/automotive/roadrunner-build-rrhd-map

roadrunner-build-rrhd-map

Verified

Build, convert, and import RoadRunner HD Maps (.rrhd) in MATLAB. Author lanes, lane boundaries, markings, junctions, signs, barriers, and speed limits with roadrunnerHDMap; convert Lanelet2 (.osm, Autoware) maps to RRHD; resolve RoadRunner road asset paths for markings, crosswalks, signs, signals, and barriers; and import or build .rrhd or OpenDRIVE (.xodr) files into a RoadRunner scene. Use when creating road networks for driving simulation, converting Lanelet2 or other HD map sources to RRHD, looking up road asset paths, or loading and verifying a map in RoadRunner or RoadRunner Scene Builder. Not for building scenes from recorded sensor data, running simulations, or recreating OpenSCENARIO (.xosc) scenarios.

FileKindSize
SKILL.mdskill md15.5 KB
manifest.yamlconfig557 B
references/assets/assetCatalog.mdmarkdown7.4 KB
references/assets/barriers.mdmarkdown3.6 KB
references/assets/laneMarkings.mdmarkdown5.8 KB
references/assets/laneTypes.mdmarkdown2.2 KB
references/assets/signs.mdmarkdown5.0 KB
references/assets/staticObjects.mdmarkdown5.1 KB
references/authoring/alignmentRules.mdmarkdown10.3 KB
references/authoring/apiReference.mdmarkdown9.0 KB
references/authoring/authoringWorkflow.mdmarkdown20.4 KB
references/authoring/deduplicateBoundaries.mdmarkdown4.9 KB
references/authoring/junctionPolygon.mdmarkdown6.8 KB
references/authoring/leftGapFilter.mdmarkdown6.5 KB
references/authoring/orthogonalSplit.mdmarkdown7.7 KB
references/authoring/resolveHeights.mdmarkdown2.4 KB
references/authoring/snapEndpoints.mdmarkdown4.0 KB
references/authoring/splitClosedGeometry.mdmarkdown3.8 KB
references/authoring/synthesizeCenterLine.mdmarkdown4.6 KB
references/authoring/validateMap.mdmarkdown1.1 KB
references/import/buildOptions.mdmarkdown4.0 KB
references/import/importScene.mdmarkdown12.9 KB
references/lanelet2/buildRRHD.mdmarkdown14.2 KB
references/lanelet2/conversionPipeline.mdmarkdown13.3 KB
references/lanelet2/coordinates.mdmarkdown4.9 KB
references/lanelet2/discoverRelations.mdmarkdown2.4 KB
references/lanelet2/enforcementGate.mdmarkdown3.3 KB
references/lanelet2/extractGeometry.mdmarkdown3.4 KB
references/lanelet2/extractJunctions.mdmarkdown5.0 KB
references/lanelet2/extractLanelets.mdmarkdown2.6 KB
references/lanelet2/extractNonLaneElements.mdmarkdown14.4 KB
references/lanelet2/extractSemantics.mdmarkdown4.4 KB
references/lanelet2/extractTopology.mdmarkdown5.4 KB
references/lanelet2/placedObjects.mdmarkdown4.4 KB
references/lanelet2/readOSM.mdmarkdown4.0 KB
references/lanelet2/splitClosedRoads.mdmarkdown3.0 KB
scripts/detectAlignment.mother3.3 KB
scripts/detectClosedLoop.mother5.8 KB
scripts/detectJunctions.mother12.4 KB
scripts/discoverWayTypes.mother4.8 KB
scripts/parseOSM.mother4.0 KB
scripts/resolveHeightConflicts.mother6.8 KB
scripts/resolveSignAsset.mother7.2 KB
scripts/snapConnectedEndpoints.mother4.0 KB
scripts/validateRRHD.mother6.3 KB

references/lanelet2/extractTopology.md

View on GitHub
# Extract Topology

Determines predecessor/successor relationships between lanelets using boundary endpoint node matching.

## Primary Method: Boundary Endpoint Node Matching

Two lanelets are sequential if their boundary ways share endpoint nodes. This captures ~96% of lane connectivity including intersection connections that proximity methods miss.

**Critical: Account for opposing boundary directions.** Left and right boundaries of a lanelet may run in opposite directions (common in bidirectional roads where a center boundary is shared between opposing lanes). The "last node" of a reversed boundary is at the lane START, not end.

### Detecting Backward-Right Boundaries

Use the dot product of left and right boundary directions with a threshold of -0.3 (not 0):

```matlab
lPts = geomMap(ll.leftWayID);
rPts = geomMap(ll.rightWayID);
lDir = lPts(end,:) - lPts(1,:);
rDir = rPts(end,:) - rPts(1,:);
dp = dot(lDir(1:2)/(norm(lDir(1:2))+1e-10), rDir(1:2)/(norm(rDir(1:2))+1e-10));
isRightBackward = (dp < -0.3);
% Inverted lanelets (dp >= -0.3 but left way geometrically on the right) have BOTH boundaries
% Backward: their effective start nodes are the last nodes of both ways. Derive start/end nodes
% from the per-lane alignment (conversionPipeline.md, Invariant 3) rather than from dp alone.
```

When `dp >= -0.3`, boundaries go in the same direction (normal case). When `dp < -0.3`, use **proximity** to determine which direction the right boundary travels relative to the lane:

```matlab
if dp >= -0.3
    % Normal case: right boundary goes in travel direction
    rightStartNode = rightWay.nodeRefs{1};
    rightEndNode = rightWay.nodeRefs{end};
else
    % Opposing boundaries: check proximity to determine travel direction
    d_ls_re = norm(lPts(1,1:2) - rPts(end,1:2));  % left start to right end
    d_ls_rs = norm(lPts(1,1:2) - rPts(1,1:2));    % left start to right start
    if d_ls_re < d_ls_rs
        % Right boundary is BACKWARD: effective start = last node, end = first
        rightStartNode = rightWay.nodeRefs{end};
        rightEndNode = rightWay.nodeRefs{1};
    else
        rightStartNode = rightWay.nodeRefs{1};
        rightEndNode = rightWay.nodeRefs{end};
    end
end
```

### Building Endpoint Maps

Build `endToLanelet` and `startToLanelet` maps using effective right boundary endpoints:

```matlab
endToLanelet = containers.Map('KeyType','char','ValueType','any');
startToLanelet = containers.Map('KeyType','char','ValueType','any');
% For each lanelet: add to endToLanelet(rightEndNode) and startToLanelet(rightStartNode)
```

### Opposing-Direction Filter (MANDATORY)

After connecting lanes via shared endpoint nodes, filter out false connections between opposing-direction lanes. Use **EFFECTIVE travel direction** (not raw right boundary direction):

```matlab
% Compute effective travel direction for predecessor
predDpLR = dot(predLDir(1:2)/norm(...), predRDir(1:2)/norm(...));
if predDpLR >= -0.3
    predTravelDir = predRDir(1:2);      % normal: right = travel
else
    predTravelDir = -predRDir(1:2);     % backward right: reverse
end

% Same for successor...
dpTravel = dot(predTravelDir/norm(...), succTravelDir/norm(...));
if dpTravel < -0.3
    continue;  % Skip opposing-direction connection
end
```

**Why effective direction?** For backward-right lanes, the raw right boundary direction is OPPOSITE to travel. Using it directly in the filter would incorrectly flag valid same-direction connections as "opposing."

### Left-Gap Filtering (MANDATORY — removes false successors)

After building pred/succ connections, apply the left-gap topology filter to remove false connections caused by shared boundary endpoint nodes. See [references/leftGapFilter.md](../authoring/leftGapFilter.md) for the full algorithm and code.

**Summary:** For each lane with multiple successors/predecessors, compute left boundary gap. If any connection has gap < 3m and others > 3m, remove the far ones. Applies bidirectionally. Typically removes ~34 false connections on the reference 184-lane map.

### Why Not Simple Node Matching?

Simple `wayLastNode == wayFirstNode` without flip detection creates false connections for opposing-boundary lanes:
- Lane_124's right boundary ends at node X (which is at lane START due to reversal)
- Lane_56's right boundary starts at node X (which is at lane START)
- Simple matching says "Lane_124 → Lane_56" but actually both STARTs are at node X
- Results in 71m+ gaps between "connected" lanes

With flip detection, effective end/start are correct and all gaps are either ~0m (direct) or ~3m (intersection crossings).

## Fallback: Center Line Proximity

For unmatched pairs after node matching, use geometry proximity:

```matlab
THRESH = 1.0; % meters
d = norm(endPts(i,:) - startPts(j,:));
if d < THRESH
    topo(i).successors(end+1) = lanelets(j).id;
    topo(j).predecessors(end+1) = lanelets(i).id;
end
```

## Endpoint Gaps After Topology

Connected lanes will have two types of gaps:
- **~0m**: Directly adjacent lanes sharing a boundary
- **~2-4m**: Intersection crossings (lane center to next lane center across junction)

Do NOT snap intersection-crossing gaps. Only snap gaps < 1.5m. The ~3m gaps are real physical distances — RoadRunner uses topology references for routing, not geometric coincidence.

## Performance Note

The O(n²) comparison is acceptable for maps with < 1000 lanelets. For larger maps, build a node-to-lanelet index for O(n) lookup.

----

Copyright 2026 The MathWorks, Inc.

----
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall