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/extractJunctions.md

View on GitHub
# Detect Junctions from Overlapping Lane Footprints

Build junctions **after** lanes, boundaries, and topology exist (Step 9, after the left-gap filter) with [scripts/detectJunctions.m](../../scripts/detectJunctions.m). It works for every Lanelet2 dialect — `turn_direction`, `turning_dir`, or no turn tags at all.

```matlab
[junctions, jInfo] = detectJunctions(lanes, laneBoundaries);
fprintf('Junctions: %d (lanes per junction %s) | dropped: %d < 15 m^2\n', jInfo.nJunctions, ...
    mat2str(jInfo.laneCounts'), jInfo.nDroppedSmall);

% Strip markings from boundaries used only by junction lanes
isJ = ismember(arrayfun(@(l) string(l.ID), lanes(:)), jInfo.junctionLaneIDs);
useAll = strings(0, 1); useJ = strings(0, 1);
for i = 1:numel(lanes)
    b = [string(lanes(i).LeftLaneBoundary.Reference.ID), string(lanes(i).RightLaneBoundary.Reference.ID)];
    useAll = [useAll, b]; if isJ(i), useJ = [useJ, b]; end %#ok<AGROW>
end
onlyJ = setdiff(unique(useJ), unique(useAll(~ismember(useAll, useJ))));
for k = 1:numel(laneBoundaries)
    if ismember(string(laneBoundaries(k).ID), onlyJ)
        laneBoundaries(k).ParametricAttributes = roadrunner.hdmap.ParametricAttribution.empty;
    end
end
```

## How it works

| Rule | Why |
|---|---|
| Footprint = left boundary + reversed right boundary (respecting alignment) | Real lane area, not a point cloud |
| Two lanes link when their footprints overlap by > 0.01 m² | Turn and through lanes inside an intersection overlap; plain road does not. Small overlaps left unlinked become RoadRunner sliver junctions |
| Predecessor/successor pairs never link; boundary-sharing neighbours need ≥ 25% overlap | End-to-end and side-by-side contact is not a conflict — lane-add/drop tapers stay out |
| Junction = connected group of linked lanes, **including through-lanes** | Covers the whole conflict area (avoids RoadRunner sliver junctions) |
| Polygon = union of member footprints (largest region, holes removed) | Follows the actual road edges |
| Merge groups chained end to end (a member of one is the predecessor/successor of a member of the other) whose footprints are within 1 m (`MergeGap`) | Sources cut one diverge/merge/crossing into many short lanelets (a real urban map: 0.9–7.5 m segments over a 15 m split) — without this each segment pair becomes its own junction and RoadRunner fills the gaps with slivers |
| Merge groups lying side by side across the road: footprints run alongside each other (within 1 m) for ≥ 4 m (`SideBySideLength`), tested on the chain-merged groups | One intersection whose two carriageways overlap separately (real urban map, T-junction east of a roundabout: 154 + 95 m² halves → one 249 m² junction, ODR 339 m²) |
| No proximity merging otherwise | Separate intersections stay separate; roundabout entries touch only at corners and stay apart |
| Keep diverges/merges whose lanes overlap (`DropDivergeMerge=false`) | Dropping them makes RoadRunner build its own, larger junction there |
| Drop groups < 15 m² | Numerical slivers |
| Roundabouts | Only the entries/exits overlap the ring, so each becomes its own small junction; the ring stays normal road |

## Validation (real urban map vs RoadRunner's build of its OpenDRIVE, 16 junctions)

Authored = junctions written to the RRHD; built = junctions in the RoadRunner scene after Build (exported back with `exportScene`).

| Method | Authored | Built | Slivers < 5 m² in build | ODR junctions present in build | Roundabout |
|---|---|---|---|---|---|
| `turn_direction`/`turning_dir` BFS clustering (8 m) | 11 | — | — | — | 48-, 32-, 31-lane clumps; 12 of 19 ring lanes inside junctions |
| `detectJunctions`, strict (0.3 m², drop diverge/merge) | 24 | 41 | 15 | 16 / 16 | 7 entry/exit junctions, 38–59 m² (ODR 41–65 m²) |
| `detectJunctions` 0.01 m², keep diverge/merge, no chain merge | 28 | 36 | 10 | 16 / 16 | same |
| `detectJunctions` + chain merge (1 m) | 21 | 30 | 7 | 16 / 16 | same; split zone east of the roundabout is one 66 m² junction (was 20 + 40 m² plus 2 slivers) |
| `detectJunctions` defaults (+ side-by-side merge, 4 m) | 19 | not built yet | — | 14 / 16 authored within 15 m | same; T-junction east of the roundabout is one junction |

RoadRunner still adds junctions of its own during Build (30 built vs 21 authored with chain merge only). A likely contributor is the very short source lanelets (median 3.3 m); merging 1:1 lanelet chains before building is the next thing to try.

`turn_direction` tags are still useful as a diagnostic: a turn lane that ends up outside every junction usually means a missing or mis-aligned boundary.

## Explicit junctions

If the source carries explicit junction areas (`type=multipolygon`, `subtype=junction`), use their polygons and member lanes directly instead of `detectJunctions`.

## Traffic-light regulatory elements

RoadRunner ignores RRHD signals on import, so `regulatory_element/traffic_light` relations are reported, not built. Phase timing needs `custom:phase_*` tags (standard Lanelet2 has no signal phases).

----

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