AdrianEddy / telemetry-parser

A tool to parse real-time metadata embedded in video files or telemetry from other sources like Betaflight blackbox. Supported formats: Sony, GoPro GPMF, Insta360, Betaflight blackbox (csv and binary)
Apache License 2.0
145 stars 15 forks source link

Question: Units for `TimeVector3` #26

Closed senden9 closed 1 year ago

senden9 commented 1 year ago

Hi!

Background

I am currently implementing a parser for VideoIMUCapture-Android. For the start I planed to just use accelerometer and gyro data from the rich data format provided.

Problem

Gyroflow compiled against my custom version of telemetry-parser can open my data-file but complains that has a data-rate of 0 Hz. The data rate should in fact be 100Hz. I have a 21 second long test-video and gyro2bb detects 2154 samples.

Question

I assume that the time-scale is somehow screwed up. What is the time scale that TimeVector3 expects for its t value? Because it is float and not noted future I assumed seconds.

More Background / rubber duck programming attempt

I know, the next part could be a bit confusing without the code but maybe there are some useful details in in.

Here is the CSV that gets created when I call gyro2bb over on my sample file.

"Product","Blackbox flight data recorder by Nicholas Sherlock"
"loopIteration","time","gyroADC[0]","gyroADC[1]","gyroADC[2]","accSmooth[0]","accSmooth[1]","accSmooth[2]"
0,0,2.029940332177429,-2.0124407471936214,-7.647275308911268,-17946.859375,8310.0244140625,-4732.0458984375
1,9793,2.029940332177429,-2.0124407471936214,-7.647275308911268,-17946.859375,8310.0244140625,-4732.0458984375
2,19586,2.029940332177429,-2.0124407471936214,-7.647275308911268,-17946.859375,8310.0244140625,-4732.0458984375
3,29381,2.029940332177429,-2.0124407471936214,-7.647275308911268,-17946.859375,8310.0244140625,-4732.0458984375
4,39174,2.029940332177429,-2.0124407471936214,-7.647275308911268,-17946.859375,8310.0244140625,-4732.0458984375
5,48967,2.029940332177429,-2.0124407471936214,-7.647275308911268,-17946.859375,8310.0244140625,-4732.0458984375
6,58760,2.029940332177429,-2.0124407471936214,-7.647275308911268,-17946.859375,8310.0244140625,-4732.0458984375
7,68555,2.029940332177429,-2.0124407471936214,-7.647275308911268,-17946.859375,8310.0244140625,-4732.0458984375

I have no idea what the time column here should be but because it jumps from 0 to 9793 to 19586 it looks currently it is the time in nano seconds since the beginning of the recording.

If I take a look at the first 3 samples that get into my SampleInfo I see 144346.848063549, 144346.857856309 and 144346.867649903 as first 3 time stamps. That is a between the first and the second timestamp I see a 0.00979276 seconds difference, between the second and the third timestamp the difference is 0.009793594 seconds. This gives 102Hz

[/home/stefano/git/private/telemetry-parser/src/phone_apps/video_imu_capture/mod.rs:80] (first_timestamp_ms, last_timestamp_ms, gyro.len(), accl.len(), magn.len()) = (
    144346848.063549,
    144367933.73032,
    2154,
    2154,
    2154,
)
[/home/stefano/git/private/telemetry-parser/src/phone_apps/video_imu_capture/mod.rs:82] (&gyro[i], &accl[i]) = (
    TimeVector3 {
        t: 144346.848063549,
        x: -0.13347013294696808,
        y: -0.03512371703982353,
        z: -0.03542914241552353,
    },
    TimeVector3 {
        t: 144346.848063549,
        x: -2.3105692863464355,
        y: 4.057629108428955,
        z: 8.763114929199219,
    },
)
[/home/stefano/git/private/telemetry-parser/src/phone_apps/video_imu_capture/mod.rs:82] (&gyro[i], &accl[i]) = (
    TimeVector3 {
        t: 144346.857856309,
        x: -0.13347013294696808,
        y: -0.03512371703982353,
        z: -0.03542914241552353,
    },
    TimeVector3 {
        t: 144346.857856309,
        x: -2.3105692863464355,
        y: 4.057629108428955,
        z: 8.763114929199219,
    },
)
[/home/stefano/git/private/telemetry-parser/src/phone_apps/video_imu_capture/mod.rs:82] (&gyro[i], &accl[i]) = (
    TimeVector3 {
        t: 144346.867649903,
        x: -0.13347013294696808,
        y: -0.03512371703982353,
        z: -0.03542914241552353,
    },
    TimeVector3 {
        t: 144346.867649903,
        x: -2.3105692863464355,
        y: 4.057629108428955,
        z: 8.763114929199219,
    },
)

This is why I assume my time units are maybe screwed up when gyroscope calculates a data rate of 0 Hz from a file with 2154 samples in about 21 seconds.

AdrianEddy commented 1 year ago

The unit in TimeVector3 should be seconds, so it should be fine Not sure why it calculates 0 Hz, the calculation is here https://github.com/gyroflow/gyroflow/blob/master/src/core/gyro_source.rs#L802-L805 so I would add debug prints here to see which values it uses

senden9 commented 1 year ago

Thanks for answering my question and the hint to the frequency calculation!