racer home

Racer Log to Matlab converter

 

Home Using Matlab for Racer car behavior analysis. racer alfa


Dolphinity Organiser - free planning, project management and organizing software for all your action lists

 

INTRODUCTION

Log2Mat can convert Racer-generated log files (normally saved in data/dump/) to Matlab (v5+) files. Matlab is a commercial tool which is often used in the engineer field to solve technical problems in a mathematical environment, and can be put to use when analyzing Racer car behavior.

DOWNLOAD

Download the Log2Mat tool by clicking on this line. (840Kb, 1-Mar-2007)

Note the zip file contains 2 tools; a converter from Racer Log to Matlab, and a converter from Matlab to Racer Log. See also the page on Mat2Log.

USAGE

The steps in using this tool are as follows:

The steps are explained in more detail below.

LOG FILE GENERATION

The racer.ini file in your installation directory contains a 'log' section. Here you can select which groups of information you want to save (log.groups.*) and the filename that is used when saving (the file will end up in data/dump). You can enable it from the start with log.enable=1, but you can also do this on the fly while driving by pressing F3 (note that Shift-F3 turns loggin off again). For more detailed information on how to log, see the logging reference.

CONVERTING TO MATLAB

Open a command prompt, go to the directory where the .log file is stored (often c:\sims\racer\data\dump), then enter:

log2mat mylogfile.log mylogfile.mat

Where you change 'mylogfile.log' with the log file that you want converted and 'mylogfile.mat' with the name of the Matlab file you want to generate. Make sure the log2mat.exe file can be found; either put it directly into the data/dump directory of your Racer installation, or put it in a directory in your path (i.e. c:\windows).

LOADING & ANALYZING IN MATLAB

Double-click on the generated .mat file. This should run Matlab and load the file. Alternatively, just start Matlab and type 'load('c:\sims\racer\data\dump\test.mat')' (supply the right path to the .mat file).

After this, type 'whos' in Matlab to look at the stored arrays. One of them is always 'time', which contains the race time in milliseconds. Often you'll want to use time/1000 to work in seconds; type 'time=time/1000' in Matlab if you want to convert this array permanently. The rest of the arrays are named exactly as they appear in the ASCII log file.

Now that you have the variables in your Matlab workspace, you can analyze them. Here is an example .m file which plots the acceleration over time. On the right you can see the result.

load('c:\sims\racer\data\dump\mylogfile.mat);

% Plot 3 linear acc
figure;
subplot(3,1,1);
plot(time/1000,ax);
title('AX');
xlabel('time');
ylabel('m/s^2')

subplot(3,1,2);
plot(time/1000,ay);
title('AY');
xlabel('time');
ylabel('m/s^2')

subplot(3,1,3);
plot(time/1000,az);
title('AZ');
xlabel('time');
ylabel('m/s^2')

matlab racer plot

 

SEE ALSO

The inverse operation is also possible; converting Matlab files into Racer log files (this is more a generic Matlab to ASCII conversion tool). See Mat2Log on how to convert Matlab .mat files into Racer Log files.


Dolphinity Organiser - free planning, project management and organizing software for all your action lists

(last updated November 13, 2012 )