Using the Replay tool to run EKF with external IMU and GNSS data files

Hi,

I’m interested in running the AP EKF filter with custom IMU and GNSS data stored in text format in order to check if it will improve the GNSS position.
I found the Replay tool which purpose is to tune the EKF filter and run it with any parameter.

First I wanted to make a dry run of Replay but I’m already stuck with a bug, whatever the parameter I give. I have a clean repo clone here and just built according to the page

~/ardupilot$ ./waf configure --board=linux
~/ardupilot$ ./waf build --target=tools/Replay
~/ardupilot$ build/linux/tools/Replay --help
Too many inertial sensors

Any idea what is going wrong here ?

My next question is whether I should produce a binary dataflash log or if there is a text format that could be fed to the tool ?
My data was not produced using Ardupilot so this is the tricky part here.

Many thanks for your help,
Mi

Hi!
I think you might be looking for this:

They have instructions to use px4 and also ardupilot logfiles.

Hi,

Thanks for you input.
From what I understand, ecl is a library for PX4 that has its own simplistic implementation of EKF.

What I’m trying to do here is to specifically use the implementation of EKF from AP, though.
The advantage would also to be able to feed it with data from the odometer of the rover (not currently available but it is planed).

I haves 2 issues for now :

  1. Where do I report a bug ? Replay is always returning “Too many inertial sensors”, whatever the input args
  2. I don’t have a proper “dataflash log” to use with Replay. How can I generate a “fake” dataflash log with my own inertial & GNSS data ? Or is there a way to feed Replay with data from an ASCII (txt) file ?

Maybe the best way for me would be to write new code to feed Replay with ASCII input ?

Many thanks,
Mi

Hi!
PX4 and Ardupilot actually share the EKF library (the developer is the same, but there might be some implementation differences). There are instructions for “3a) If replaying APM data:”
and “3b) If replaying PX4 data:”


This is all in Matlab, but if I remember correctly there is a python/C++ implementation somewhere.

  1. Where do I report a bug ? Replay is always returning “Too many inertial sensors”, whatever the input args

I’d suggest starting with

  1. I don’t have a proper “dataflash log” to use with Replay. How can I generate a “fake” dataflash log with my own inertial & GNSS data ?

The format is relatively straight forward - but there are no tools for
doing what you want to do there, so you will probably need to write
something to do what you need to do. Maybe start with one of the
AP_Logger examples.

Mi

Peter

It is interesting indeed to be able to play with the EKF in Matlab and get access to all variables.

The issue I see for my use case would be for the next step, when I will include the odometry (wheel counter) of the rover. That feature is not implemented in PX4/ecl because its purpose is exclusively for flying drones.

Nice to know there is ongoing interest around Replay :slight_smile:

~/$ git clone https://github.com/peterbarker/ardupilot.git
~/$ cd ardupilot
~/ardupilot$ ./waf configure --board=linux 
~/ardupilot$ ./waf build --target=tools/Replay 
~/ardupilot$ build/linux/tools/Replay --help 
Too many inertial sensors

I still get the same error message whatever the args, even for basic help. Am I doing something wrong ?

Mi

Sorry for my lack of experience with git, I figured how to clone the branch with

git clone https://github.com/peterbarker/ardupilot.git -b pr/replay-at-least-runs 

Indeed, at least Replay runs :slight_smile:

@peterbarker AP_Logger_test example seems promising to my needs but it doesn’t write any log (only a touch to the file but no content).

This is the output I get :
~/ardupilot$ build/sitl/examples/AP_Logger_test -M rover -C
Starting sketch ‘UNKNOWN’
Starting SITL input
validate_structures:461: Validating structures
Logger Log Test 1.0
AP_Logger_File: buffer size=51200
Using log number 1
Writing to flash… wait…
Average write time 0.0 usec/byte
Testing Write
Testing WriteCritical
Test complete.
~/ardupilot$ ls -lh logs/
total 4,0K
-rw-r–r-- 1 mi mi 0 Jun 13 16:52 00000001.BIN
-rw-r–r-- 1 mi mi 3 Jun 13 16:52 LASTLOG.TXT

I found a thread with similar issue but no answer : Library Example AP_Logger_test.cpp is not working, no log file generated

Any leads to solve this issue ?

Ok, I finally got the log right with AP_logger_test example.

The issue was due to the use of branch pr/replay-at-least-runs.

I will work on two separate branches now :

  • Main : AP_logger_test
  • pr/replay-at-least-runs : Replay

This solves my issues for now :slight_smile:

Adding a new sensor is actually not that hard. You have to write the equations for that using symbolic variables, derive the Jacobian and plug those back into the ekf replay script.