This section presents some useful example MATLAB scripts.
The start time and duration of a trajectory are encoded into a GGA file. For some applications, it may be useful to use the same trajectory, but with a different start time. For example, the original trajectory may be starting at 9 AM and it is desired to run the same trajectory at 9 PM. The Matlab script below can be used to create a new GGA file from an existing GGA file. The new file can have a different start time.
function change_GGA_start_time(inputFile, outputFile, startHrs, startMin, startSec)
% change_GGA_start_time - change the starting time of
% a GGA trajectory file.
change_GGA_start_time('input.gga', 'output.gga', 10, 25, 30);
Create a GGA file for input to the scenario generation process that starts at 10:25:30 using the input GGA file which may start at a different time of day.
In some cases, you may want to record the NMEA data stream from a GPS receiver and use it to create a scenario. If the GPS receiver is configured to output NMEA $GPGGA messages, then the recording can be used directly. However, if the receiver is only configured to output $GPRMC data, the file cannot be used for trajectory generation.
The $GPRMC message stream describes the movement of the receiver in terms of latitude and longitude, but it does not describe any altitude data.
This script will read a recorded NMEA data stream, and if it has $GPRMC messages, the output file will contain equivalent $GPGGA messages with the same trajectory. The altitude of the trajectory will be set to some constant value.
Note that recorded scenarios sometimes contain “noisy” latitude and longitude data. If you plot them, you may see that a straight line becomes not so straight – sort of a jerky, noisy, straight line.
If these “noisy” recordings are used to create a scenario, the created scenario will try to follow this noisy path – so be aware of this effect when using recordings to generate scenarios.
function ConvertRMC_to_GGA( inputFile, outputFile, altitudeInMeters )
% ConvertRMC_to_GGA
% Convert file of NMEA $GPRMC messages to a file of $GPGGA messages
% for input to a scenario generation process.
ConvertRMC_to_GGA('input.nmea', 'output.gga', 325);
Convert an input file (input.nmea) which contains NMEA $GPRMC messages into an input file (containing $GPGGA messages) for the scenario generator.
The altitude of the scenario will be set to the value of the third parameter, in the example, 325 meters.
MATLAB is a U.S. registered trademark of The Math Works, Inc.