How to calculate groundspeed

Hello
I use bluerov and am a beginner
I checked that the groundspeed can be seen in the qgc ui, how is the value calculated? I looked at the code for ardusub, but I couldn’t figure it out with my ability.
Thank you for answering my question

Hi @drone_begginer, welcome to the forum :slight_smile:

The vehicle dynamics are calculated by an Extended Kalman Filter, which combines the data from each relevant sensor and tries to maximise the consistency/trustworthiness of the output.

Assuming no external velocity/positioning sensors, a fundamental calculation of groundspeed can be performed by using the internal gyroscope and/or accelerometer to determine the angle of the vehicle relative to the direction of gravity, and then integrate accelerometer readings to get a velocity, which is then projected onto the horizontal direction to get speed. In its simplest form consider just a single rotation angle:

From a known side and angle of a right angled triangle, it’s possible to calculate the remaining two side lengths with basic trigonometry :slight_smile:

When you say “integrate accelerometer data,” I assume it’s filtered in the process. For my masters thesis, I need to know what the cutoff frequency is of that filter. I’m having a hard time finding it.

Its less important, but if you know the sampling rate of the filter, I’d appreciate that too.

Hi @autery,

I’m thinking it may be variable by flight controller board, and possibly even dynamically varied over time depending on the other sensors being fused into the EKF, but I don’t really know and it’s not obviously stated in the EKF and InertialNAV docs I could find.

I asked about it internally and was told

You may have more luck if you ask on the general ArduPilot forum, since the EKF is shared across firmwares, and its development has been predominantly by others in the ArduPilot group.

The core EKF3 file may be worth a look if you want to do your own digging (it may help to search for ‘filter’ and other similar terms). ArduSub >= 4.1 uses EKF3, whereas ArduSub 4.0 used EKF2. Note that a decent portion of the EKF calculations code is auto-generated.