7 Setting up the OpenCRG tools
7.1 Downloading the software package
The latest stable version of OpenCRG is available on the ASAM website. The software package contains:
-
Sample OpenCRG files.
-
Source code of the C-API, including test programs and samples.
-
MATLAB tools, including test scripts and samples.
-
OpenCRG documentation.
Steps
-
Navigate to the Download area.
-
Follow the instructions to download the software package.
-
Download the ZIP archive.
-
Unpack the archive into a local directory.
What to do next
-
Compile the C source code.
-
Initialize the MATLAB tools.
Related topics
7.2 Setting up the C-API
7.2.1 Contents of the C-API
The C-API is located in open-crg/c-api/ and comprises the following:
baselib/-
Base library for working with OpenCRG files in C.
demo/-
Sample programs demonstrating the use of the C-API.
test/-
Programs for testing the C-API.
7.2.2 Header files of the C-API
The header files of the C-API are stored in open-crg/c-api/baselib/inc/ and comprise
the following:
crgBaseLib.h-
Provides the interface to the OpenCRG methods. Include this header file when writing your own applications.
crgBaseLibPrivate.h-
Used internally by the library’s components. Includes
crgBaseLib.h.
7.2.3 Source files of the C-API
The source files of the C-API are stored in open-crg/c-api/baselib/src/ and comprise
the following:
crgContactPoint.c-
Contact point management.
crgEvalpk.c-
Routines for evaluating heading and curvature.
crgEvaluv2xy.c-
Routines for evaluating x/y-coordinates from u/v-coordinates.
crgEvalxy2uv.c-
Routines for evaluating u/v-coordinates from x/y-coordinates.
crgEvalz.c-
Routines for evaluating z-values.
crgLoader.c-
Routines for decoding files and loading data.
crgMgr.c-
Overall data management.
crgMsg.c-
Message and log handling.
crgOptionMgmt.c-
Management of options and modifiers.
crgPortability.c-
Routines which might be subject to portability issues.
crgStatistics.c-
Routines for calculating data set statistics.
7.2.4 Compiling the C-API using Makefiles
Using the provided Makefiles is the most convenient way of compiling the C-API.
7.2.4.1 Prerequisites
-
You downloaded and unpacked the OpenCRG software package.
-
You have installed the C-compiler gcc on your computer.
-
You have set up a standard make environment on your computer.
-
The following directories exist:
open-crg/c-api/test/bin/,open-crg/c-api/demo/bin/.
7.2.4.3 Result
-
A library containing all object files of the basic library is generated in
c-api/baselib/lib/. -
Executable test files are generated in
open-crg/c-api/test/bin/. -
Executable demo files are generated in
open-crg/c-api/demo/bin/.
7.2.5 Compiling the C-API using a shell script
Using a shell script for compiling is appropriate, if you cannot compile the software package using the provided make files.
In contrast to using the Makefiles, no library containing the object files of the basic library is generated.
7.2.5.1 Prerequisites
-
You downloaded and unpacked the OpenCRG software package.
-
Your computer provides an environment for executing shell scripts.
-
You have installed a C-compiler on your computer.
7.2.5.2 Steps
-
Open the shell script
c-api/compileScript.shin a text editor. -
Find the variable
COMPand set it to the name of your compiler. -
Save your changes to the script.
-
Execute the script.
7.2.5.3 Result
-
Executable test files are generated in
c-api/test/bin/. -
Executable demo files are generated in
c-api/demo/bin/.
7.2.6 Compiling the C-API using the command line
The C-API can be compiled manually, for example, to compile only selected sample programs.
7.2.6.1 Prerequisites
-
You downloaded and unpacked the OpenCRG software package.
-
A C-compiler is installed on your computer.
7.2.6.2 Steps
The procedure depends on the C-compiler. When compiling, observe the following hints:
-
Set your include file search path to
baselib/inc. -
Always compile in combination with all .c-files in
baselib/src.
7.2.7 Testing the C-API
The software package provides programs for testing various aspects of the C-API. Successfully running these test programs ensures that the C-API is set up correctly. These tests are also used for acceptance tests of the C-API.
7.2.7.1 Prerequisites
-
You have compiled the C-API.
-
Your computer provides an environment for executing shell scripts.
-
You have installed gnuplot on your computer for creating images.
7.2.7.2 Steps
-
To run all tests for evaluation options, execute the script
c-api/test/bin/testOptions.sh. -
To run all tests for data set modifiers, execute the script
c-api/test/bin/testModifiers.sh.
7.2.7.3 Results
-
The C-API is set up successfully.
-
Images illustrating the various options and modifiers are created.
7.2.8 Source code of test programs
The source code of the test programs for the C-API is stored in open-crg/c-api/test/ and comprises the following:
Dump/-
Read an OpenCRG file and write all values (x, y, z, u, v) into a text file
crgDump.txt. MemTest/-
Test allocating and releasing OpenCRG data sets.
MultiCp/-
Test multiple contact points.
MultiRead/-
Read multiple data files and evaluate the last file.
PerfTest/-
Tool for evaluating the performance of the library.
Scan/-
Perform an x/y-scan of an OpenCRG data set.
Verify/-
Reads an OpenCRG file and a reference text file containing x/y/z data or x/y/z/u/v data. Calculates the z-values at the given x/y locations from the OpenCRG file and compares the result with the z-values from the reference text file.
7.2.9 Running the sample programs
The software package contains several sample programs illustrating the use of the C-API:
crgSimple-
Perform a series of z-data queries using x/y-coordinates.
crgReader-
Read an OpenCRG file and print debug information.
crgEvalxyuv-
Perform a series of conversions between x/y-coordinates and u/v- coordinates and check the results for consistency.
crgEvalZ-
Perform a series of advanced z-data queries from given x/y- coordinates and u/v-coordinates.
crgEvalOpts-
Collection of tests involving data set modifiers and evaluation options.
7.2.9.2 Steps
-
Open a command line interpreter.
-
Switch to the directory containing the executable of the sample program. The executables are stored in
open-crg/c-api/demo/bin/. -
Run
[program] -helpto display information about the available options. -
Run
[program] [options] <OpenCRG file>to run the program with the set options for the selected OpenCRG file.
7.2.10 Source code of sample programs
The source code of the sample programs for the C-API is stored in open-crg/c-api/demo/ and comprises the following:
EvalOptions/src/-
Source code for
crgEvalOpts. EvalXYnUV/src/-
Source code for
crgEvalxyuv. EvalZ/src/-
Source code for
crgEvalZ. Reader/src/-
Source code for
crgReader. Simple/src/-
Source code for
crgSimple.
7.3 Setting up the MATLAB tools
7.3.1 Contents of the MATLAB tools
The MATLAB tools are stored in open-crg/matlab/ and comprise the following:
demo/-
Scripts demonstrating the use of the base library.
lib/-
Base library for working with OpenCRG files in MATLAB.
test/-
Scripts for testing the MATLAB tools.
crg_init.m-
Script for initializing the MATLAB tools.
crg_intro.m-
Script for displaying an introduction to the MATLAB implementation of OpenCRG.
7.3.2 Library files of the MATLAB tools
The library files of the MATLAB tools are stored in open-crg/matlab/lib/ and comprise the following:
| Filename | Description |
|---|---|
|
Transform points in e/n/h to x/y/z. |
|
Transform points in llh to x/y/z. |
|
Evaluate curvature at reference line positions. |
|
Evaluate heading angles at reference line positions. |
|
Evaluate index positions of grid positions. |
|
Evaluate local coordinates of grid positions. |
|
Evaluate z at grid position. |
|
Transform points in x/y to u/v. |
|
Evaluate z at x/y-position. |
|
Transform point in x/y/z to e/n/h. |
|
Transform point in x/y/z to l/l/h. |
| Filename | Description |
|---|---|
|
Copy current axes object to new figure. |
|
Set up OpenCRG figure. |
|
Compare two OpenCRG data sets. |
|
Detect peaks in a OpenCRG data. |
|
Plot z-values over latitudinal cuts. |
|
Plot the outer grid limits. |
|
Plot z-values over longitudinal cuts. |
|
Plot z-values as uncurved orthographic image. |
|
Plot z-values as curved three-dimensional image. |
|
Plot curvature along the reference line. |
|
Plot the z-values along the reference line. |
|
Plot heading angle along the reference line. |
|
Plot slope and banking along the reference line. |
|
Plot reference line in x/y/z-coordinates. |
|
Plot reference line including curvature. |
|
Plot reference line in x/y-coordinates. |
|
Plot distance of reference points to reference line. |
|
Plot road surface over a given uncurved grid. |
|
Plot road surface over a given curved grid. |
|
Plot road surface as uncurved orthographic image. |
|
Plot road surface as curved three-dimensional image. |
|
Visualize CRG data. |
|
Visualize the cuts and limits of the CRG |
|
Visualize z-values. |
|
Display information about the CRG. |
|
Visualize the result of comparing two OpenCRG files. |
|
Visualize peaks. |
|
Visualize elevation along the reference line. |
|
Visualize the reference line. |
|
Visualize reference points and reference line. |
|
Visualize the road surface. |
|
Visualize the road surface on a given grid. |
|
Plot a three-dimensional surface. |
| Filename | Description |
|---|---|
|
Read OpenCRG file. |
|
Convert OpenCRG road data to type single. |
|
Wrap heading angles to +/- pi range. |
|
Write OpenCRG file. |
|
IPLOS write/read demonstration. |
|
Read IPLOS file. |
|
Write IPLOS file. |
|
Add block to struct data file. |
|
Cut block from struct data file. |
|
Convert number to string of given length. |
| Filename | Description |
|---|---|
|
Run all OpenCRG data checks. |
|
Check OpenCRG curvature data. |
|
Check, fix, and complement OpenCRG data. |
|
Check OpenCRG road parameters data. |
|
Check modifier data. |
|
Check OpenCRG map projection data. |
|
Check OpenCRG options data. |
|
Check core OpenCRG data for type single. |
|
Check OpenCRG WGS 84 data. |
| Filename | Description |
|---|---|
|
Append a second compatible OpenCRG to a first OpenCRG. |
|
Apply banking to OpenCRG data. |
|
Cut out a part of a OpenCRG road. |
|
Extract banking from OpenCRG data. |
|
Extract slope from OpenCRG data. |
|
Apply filter to OpenCRG data. |
|
Flip OpenCRG data. |
|
Limits z-values in OpenCRG data. |
|
Map z-values from one grid to another. |
|
Map z-values from one local coordinate system to another. |
|
Apply modifiers to data. |
|
Re-render OpenCRG data for a new u/v-grid. |
|
Apply slope to OpenCRG data. |
|
Separate slope and banking. |
|
Smooth input signals with symmetric FIR filter. |
| Filename | Description |
|---|---|
|
Check uv_descript and create a v-profile. |
|
Generate synthetic OpenCRG data. |
|
Generate reference line heading from polynomial. |
|
Generates smooth polynomial from reference points. |
|
Generate synthetical surface. |
| Filename | Description |
|---|---|
|
Generate HTML file to visualize OpenCRG data in a map. |
|
Evaluate distance and bearing between WGS 84 positions. |
|
Calculate WGS 84 positions by distance and bearing. |
|
Set WGS 84 end coordinate. |
|
Generate URL to show WGS 84 information on Google Maps |
|
Transform points in x/y-coordinates to WGS 84 coordinates using two references. |
|
Transform points in x/y-coordinates to WGS 84 coordinates. |
|
Check and update DAT struct. |
|
Check and update ellipsoid struct. |
|
Check and update map projection struct. |
|
Check and update datum transformation struct. |
|
Datum transformation in ECEF system. |
|
Convert points from ECEF system to geodetic system. |
|
Convert points from geodetic system to ECEF system. |
|
Forward map projection. |
|
Forward transverse Mercator projection. |
|
Forward projection: global to projected local. |
|
MAP routines introduction |
|
Backward projection: projected local to global. |
|
Backward projection: transverse Mercator. |
|
Transverse Mercator utility function. |
|
Transverse Mercator utility function: meridional arc. |
|
Generate HTML file to visualize WGS 84 data in a map. |
7.3.3 Initializing the MATLAB tools
Initializing the MATLAB tools adds them to the MATLAB search path. This allows MATLAB to find functions by their name.
Additionally, a new directory for holding temporary data is needed. Such a directory is required when running the demo scripts or tests.
7.3.3.2 Steps
-
In MATLAB, switch to the Command Window.
-
Run
run path-to-opencrg/matlab/crg_initto add the MATLAB tools to the MATLAB search path. -
Run
mkdir path-to-opencrg/matlab/tempto create a directory for temporary data. -
Run
cd path-to-opencrg/matlab/tempto change the current directory to the location of the directory for temporary data.
7.3.3.3 Result
The MATLAB tools are added to the search path. MATLAB’s current directory points to the newly created directory for temporary data.
7.3.4 Getting help
The OpenCRG MATLAB files contain comments formatted for help display. The help comments contain the following information:
-
Short description of the function
-
Input parameters and return values
-
Usage examples
-
Related functions
7.3.4.2 Steps
-
In MATLAB, switch to the Command Window.
-
To get an overview of the MATLAB implementation, run
crg_intro. -
To get help for a specific function, run
help function.
7.3.5 Testing the MATLAB tools
Testing the MATLAB tools makes sure that they are set up correctly. The OpenCRG software package provides several scripts that you can use for testing. These scripts are stored in /matlab/demo/ and /matlab/test/
Before running the actual tests, the required OpenCRG data structures must be created and written to file. You can use the command crg_demo to create the required files.
All test files and demo files may further be used as examples on how to use the MATLAB tools.
7.3.5.1 Prerequisites
-
You have initialized the MATLAB tools.
-
MATLAB’s current directory is set to the directory for temporary files.
7.3.5.2 Steps
-
Run
crg_demoto create the required OpenCRG data structures and write them to file. -
Run
crg_demo_demoname, to run the demo of the respective name. -
Run
crg_test_testname, to run the test of the respective name.
7.3.6 Test scripts
The test scripts for the MATLAB tools are stored in open-crg/matlab/test/ and comprise the following:
crg_test_append.m-
Test concatenating two OpenCRG files.
crg_test_continuesTrack.m-
Test the reference line continuation option.
crg_test_curvature.m-
Test global and local curvature as well as reading and writing flags.
crg_test_eval_uv2iuiv.m-
Test the transformation of u/v-coordinates to index positions.
crg_test_ext_sb.m-
Extract slope and banking from an OpenCRG file.
crg_test_filter.m-
Test the application of various filters on OpenCRG data.
crg_test_gen_csb2crg0.m-
Generate synthetic road with curvature, banking, and slope
crg_test_gen_road.m-
Generate synthetic road and write it to an OpenCRG file.
crg_test_isequal.m-
Test whether the results of various invariant modifications to an OpenCRG file are equal to the unmodified file.
crg_test_limiter.m-
Test limiting z-values to a specific range.
crg_test_map_pro.m-
Test functions related to map projection.
crg_test_map_uv2uvAxy2xy.m-
Test mapping z-values from one OpenCRG file to another.
crg_test_options.m-
Display results of various options settings.
crg_test_peakfinder.m-
Test whether the MATLAB tools find artificially created peaks.
crg_test_rerender.m-
Test whether OpenCRG files can be re-rendered with different u/v-spacings.
7.3.7 Demo scripts
The demo scripts for the MATLAB tools are located in open-crg/matlab/demo/ and comprise the following:
crg_demo.m-
Create a set of demo files.
crg_demo_belgian_block.m-
Load and visualize
../crg-bin/belgian_block.crg. crg_demo_convert2bin.m-
Convert
../crg-txt/handmade_curved.crgto binary representation. crg_demo_convert2txt.m-
Convert
../crg-bin/belgian_block.crgto text representation. crg_demo_country_road.m-
Load and visualize
../crg-bin/country_road.crg. crg_demo_gen_refline.m-
Generate an OpenCRG file with a smooth reference line.
crg_demo_gen_sl_mue.m-
Generate a synthetic OpenCRG file with friction coefficients.
crg_demo_gen_sl_road.m-
Generate a synthetic OpenCRG file representing a complete road.
crg_demo_gen_sl_surf.m-
Generate a synthetic OpenCRG file representing a straight road.
crg_demo_gen_surface.m-
Generate a OpenCRG file for a given reference line from measurement data.
crg_demo_gen_syntheticStraight.m-
Generate a synthetic OpenCRG file representing a straight road.
crg_demo_gen_target.m-
Generate a surface OpenCRG file.
crg_demo_map_transformation.m-
Perform geodetic transformations (e.g UTM → WGS 84).
crg_demo_scale_data.m-
Scale OpenCRG data.