A pure-Julia reader for ASAM OpenCRG
.crg files: high-resolution road surface elevation on a curved reference line,
addressed in a road-aligned (u, v) frame (u along the line, v across it).
using Pkg
Pkg.add("OpenCRG")The quick start below also needs Pkg.add("DataInterpolationsND").
read_crg(path) parses a file and returns a CRGData holding all data from
that file.
road_surface_grid(data) turns that into a grid (u, v, X, Y, Z). Here, u
and v are vectors of along-track and across-track distance, respectively.
X, Y, Z are matrices of size (length(u), length(v)) that together define
Cartesian positions of the surface of the road.
Positive v points left and negative v right, looking in the direction of
increasing u. Undefined cells are NaN.
Load a fixture and interpolate its surface directly with DataInterpolationsND.jl. OpenCRG.jl provides the grid; interpolation packages such as Interpolations.jl or DataInterpolationsND.jl evaluate it between nodes.
using OpenCRG, DataInterpolationsND
data = read_crg(joinpath(pkgdir(OpenCRG), "test", "data", "handmade_curved_banked_sloped.crg"))
u, v, X, Y, Z = road_surface_grid(data)
dimensions = (LinearInterpolationDimension(u), LinearInterpolationDimension(v))
surface = NDInterpolation(cat(X, Y, Z; dims = 3), dimensions)
surface(10.5, 0.5) # Cartesian [x, y, z] at along-track 10.5 m, across-track 0.5 mlib/LibOpenCRG.jl is a separate package that wraps the
upstream C library and adds point evaluation (uv2xy, xy2z, ...), which
OpenCRG.jl does not provide.
See the OpenCRG.jl documentation for the supported modifiers, known limitations and out-of-domain behaviour.
The code is MIT-licensed. The sample files in test/data from the upstream
asam-ev/OpenCRG project are Apache-2.0
(see test/data/LICENSE-APACHE-2.0 and test/data/NOTICE).
This package was written with the help of generative AI.