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

View on GitHub
# Resolve Map Origin, Project Coordinates, Build Way Geometry

Run once, right after parsing. Every later step reads way geometry from `geomMap` — never re-project or modify it.

## Origin (GeoReference) — resolution order

| Priority | Source | Keys |
|---|---|---|
| 1 | `map_projector_info.yaml` next to the `.osm` | `MapOrigin: Latitude / Longitude` (TransverseMercator, LocalCartesianUTM) |
| 2 | `map_config.yaml` next to the `.osm` (Autoware) | `map_origin: latitude / longitude` |
| 3 | Centroid of all node `lat`/`lon` | — |

- Ignore an origin of `[0, 0]`; fall through to the next source.
- **Sanity check:** reject a file origin more than 10 km from the node centroid (warn and use the centroid). Autoware `map_config.yaml` origins can be unrelated to MGRS map data (e.g. sample-map-planning: 74 km away).
- `ProjectorType: MGRS` (Autoware) has no origin in `map_projector_info.yaml` — use priority 2 or 3.
- Match keys case-insensitively — Autoware writes `latitude`, Lanelet2 tooling writes `Latitude`.

## Coordinate mode

| Node data | Projector | Use |
|---|---|---|
| `local_x`/`local_y` tags | not MGRS (TransverseMercator, LocalCartesian, or no projector file) | Local tags directly — they are the metric source of truth |
| `local_x`/`local_y` tags | MGRS | **lat/lon → Transverse Mercator** — MGRS local coordinates are relative to the grid square, not to the GeoReference |
| `lat`/`lon` only | any | lat/lon → Transverse Mercator about the GeoReference |

Z is always the `ele` tag (default 0). Keep source elevation — do not flatten it.

## Implementation

```matlab
%% Origin
osmDir = fileparts(osmFile);
geoRef = [];
for cfgFile = ["map_projector_info.yaml", "map_config.yaml"]
    p = fullfile(osmDir, cfgFile);
    if isempty(geoRef) && isfile(p)
        txt = fileread(p);
        la = regexp(txt, '(?i)latitude:\s*([-\d.eE+]+)', 'tokens', 'once');
        lo = regexp(txt, '(?i)longitude:\s*([-\d.eE+]+)', 'tokens', 'once');
        if ~isempty(la) && ~isempty(lo)
            cand = [str2double(la{1}), str2double(lo{1})];
            if all(isfinite(cand)) && any(cand ~= 0), geoRef = cand; end
        end
    end
end
projType = "";
pf = fullfile(osmDir, "map_projector_info.yaml");
if isfile(pf)
    t = regexp(fileread(pf), '(?i)projector_?type:\s*(\S+)', 'tokens', 'once');
    if ~isempty(t), projType = string(t{1}); end
end

%% Node arrays
nodeKeys = nodes.keys;
nodeVals = nodes.values;
nodeArr = [nodeVals{:}];
lat = [nodeArr.lat]'; lon = [nodeArr.lon]'; ele = [nodeArr.ele]';
centroid = [mean(lat), mean(lon)];
if ~isempty(geoRef) && norm((geoRef - centroid) .* [111e3, 111e3*cosd(centroid(1))]) > 10e3
    warning('Origin from projector/config file is %.0f km from the map data — using node centroid.', ...
        norm((geoRef - centroid) .* [111, 111*cosd(centroid(1))]));
    geoRef = [];
end
if isempty(geoRef), geoRef = centroid; end
geoRef = double(geoRef);

% Region from the origin — selects sign sets (signs.md) and marking colours (extractSemantics.md)
if geoRef(1) >= 24 && geoRef(1) <= 46 && geoRef(2) >= 122 && geoRef(2) <= 154, region = "Japan";
elseif geoRef(1) >= 35 && geoRef(1) <= 72 && geoRef(2) >= -10 && geoRef(2) <= 25, region = "Germany";
else, region = "US"; end

hasLocal = all(~isnan([nodeArr.local_x]));
useLocal = hasLocal && projType ~= "MGRS";
if useLocal
    xyz = [[nodeArr.local_x]', [nodeArr.local_y]', ele];
else
    % WGS-84 Transverse Mercator centred on geoRef (k0 = 1) — the projection RoadRunner applies
    % about the GeoReference, so geometry stays consistent with it far from the origin
    a = 6378137.0; f = 1/298.257223563; e2 = 2*f - f^2; ep2 = e2/(1 - e2);
    meridArc = @(p) a*((1 - e2/4 - 3*e2^2/64 - 5*e2^3/256)*p - (3*e2/8 + 3*e2^2/32 + 45*e2^3/1024)*sin(2*p) ...
        + (15*e2^2/256 + 45*e2^3/1024)*sin(4*p) - (35*e2^3/3072)*sin(6*p));
    phi = deg2rad(lat); dLam = deg2rad(lon - geoRef(2));
    N = a ./ sqrt(1 - e2*sin(phi).^2); T = tan(phi).^2; C = ep2*cos(phi).^2; A = dLam .* cos(phi);
    xE = N .* (A + (1 - T + C).*A.^3/6 + (5 - 18*T + T.^2 + 72*C - 58*ep2).*A.^5/120);
    yN = meridArc(phi) - meridArc(deg2rad(geoRef(1))) + N .* tan(phi) .* (A.^2/2 ...
        + (5 - T + 9*C + 4*C.^2).*A.^4/24 + (61 - 58*T + T.^2 + 600*C - 330*ep2).*A.^6/720);
    xyz = [xE, yN, ele];
end
nodeIdx = containers.Map(nodeKeys, num2cell(1:numel(nodeKeys)));

%% Way geometry — wayID -> Nx3 (immutable from here on)
geomMap = containers.Map('KeyType', 'char', 'ValueType', 'any');
wayKeys = ways.keys;
for i = 1:numel(wayKeys)
    w = ways(wayKeys{i});
    idx = cellfun(@(k) nodeIdx(k), cellstr(w.nodeRefs));
    geomMap(wayKeys{i}) = xyz(idx, :);
end
fprintf('GeoReference [%.7f, %.7f] (%s) | coordinates: %s\n', geoRef(1), geoRef(2), ...
    projType, string(useLocal).replace(["true","false"], ["local_x/local_y","lat/lon -> TM"]));
```

Set `rrMap.GeoReference = geoRef` (1x2 `[lat, lon]`) before `write()`.

----

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