Quick Play: Using Grafana For Motorsport Telemetry Dashboards

In passing, I came across the Grafana dashboarding platform, which is also available as an open source, self-hosted app.

Grabbing the Docker container and installing the Grafana SQLite datasource plugin, I had a quick go at visualising some motorsport telemetry, in this case WRC rally telemetry.

The way I’m using the dashboard is to run queries against the SQLite datasource, which contains some preprocessed telemetry data. The data source includes time into stage, lat/lon co-ordinates, distance into stage (-ish!), and various telemetry channels, such as speed, throttle, brake, etc.

Here’s a quick view of a simple dashboard:

At the top of the dashboard are controls for selecting particular fields. These are defined using dashboard variables and can be used to set parameter values used by other queries in the dashboard.

Changing one of the selector fields updates all queries that call on the variable.

Variables can also be used in the definition of other variables, which means that selector fields will up date responsively to changes in other fields.

In the dataset I am using, telemetry is not available on all stages for all drivers, so we can limit which stages can be selected for each driver based on the selected driver.

The timeseries chart display panels are also defined against a query. A time field is required. In the ata I am using, the time is just a delta, starting at zero and then counting in seconds (and milliseconds). This time seems to be parsed as a timedelta from from Unix basetime, which is okay, although it does mean you have to be careful selecting the period you want to display the chart for…

SELECT displacementTime as time, throttle, brk FROM full_telem2 WHERE driver="${driver}" AND stage="${stage}"

One thing I didn’t explore was dual axis charts, but these do appear to be available.

I appreciate that grafana is intended for displaying real time streaming data, but for analysing this sort of historical data it would be so much easier if you could not only specify the input time as a delta, but also set the display window to automatically display the full width of the data to fit the display window.

If you have multiple time series charts, clicking and dragging over a horizontal region of one of the time series charts allows you to zoom in on that chart and automatically zoom the other time series chart displays. This is great for zooming in, but I didn’t find a way to reset the zoom level other than by trying to use the browser back button. This really sucks.

The map display uses another plugin, pr0ps-trackmap-panel. Shift-clicking and dragging to select a particualr area of the map also zooms the other displays, which means you can check the telemetry for a particular part of the stage (it helps if you can remember which way it flows! It would be hand to be able to put additional specific coloured marker points onto the map, for example to indicate the start and end of the route with different coloured markers.

The map definition is a bit odd: you have specify to separate queries:

SELECT displacementTime as time, lat from full_telem2 where driver="${driver}" and stage="${stage}";

SELECT displacementTime as time, lon from full_telem2 where driver="${driver}" and stage="${stage}";

You also need to disable the autozoom in to prevent the view zooming back to show the whole route after shift-click-dragging to zoom to a particular area of it. (That said, disabling autozoom seems to break the display of the map for me when you open the dashboard?)

SELECT DISTINCT(stage) FROM full_telem2 WHERE driver="$driver" ORDER BY stage

The final chart on my demo dashboard tries to capture the stage time for a particular distance into the stage. The time series chart requires a time for the x-coordinate, so I pretend that my stage distance is a time delta, then map the time into stage at that distance onto the y-axis.

This isn’t ideal because the x-axis units are converted to times (minutes and seconds) and I could see how to force the display of raw “time” in seconds to better indicate the actual value (of distance in meters). The y-axis is a simple seconds count, but that would be handy if it were given as a time!

What would be useful would be the ability to at least transpose the x and y-axis of the time series chart, although a more general chart where you can plot what you like on the x-and y-axes would be even nicer.

Which makes me think… is there a plugin for that? Or perhaps a scatter plot plugin with a line facility?

At first sense, a scatter plot may not seem that useful for this dataset. But a couple of the telemetry traces capture the lateral and longitudinal accelerations… So let’s see how they look using the michaeldmoore-scatter-panel.

This is okay insofar as it goes, but it doesn’t appear to be responsive to selection of particular areas of the other charts, nor does it appear to let you click and drag to highlight areas and then automatically set a similar time scope in the other charts. It would also be handy if you could set colour thresholds. Taking a hint from the map plugin, which required mutliple queires, I did try using multiple queries to give me positive and negative accelerations that I thought I could then colour separately, but only ata from the first query appeared to be displayed.

The scatter plot also gives us a route to a time versus distance chart, but again there’s no zooming or linking.

It’s possible to create you extensions, so maybe at some point I could have a look at creating my own extensions.

For some of my other recent rally telemetry doodles, see Visualising WRC Telemetry With R.

PS I did also wonder whether there would be a route to using pyodide (WASM powered Python) in a grafana extensions, which would then potentially give you access to a full scipy stack when creating widgets…

Author: Tony Hirst

I'm a Senior Lecturer at The Open University, with an interest in #opendata policy and practice, as well as general web tinkering...

%d bloggers like this: