iNavFlight / inav

INAV: Navigation-enabled flight control software
https://inavflight.github.io
GNU General Public License v3.0
3.18k stars 1.48k forks source link

Convert blackbox CSV readings to actual sensor readings #3690

Closed col85 closed 6 years ago

col85 commented 6 years ago

Hi all, I am trying convert the decoded blackbox CSV data into actual conventional sensor readings (e.g. instead of accSmooth values, how can I convert this to actual accelerometer readings?) that we are viewing on Blackbox explorer for my own analysis. Would like to ask if there are any guidelines on how I can do this?

Thanks in advance for the advice!

shellixyz commented 6 years ago

Apparently value in g = accSmooth / 2048

shellixyz commented 6 years ago

Looks like it depends on the accelerometer:

drivers/accgyro/accgyro_bma280.c:44:    acc->acc_1G = 512 * 8;
drivers/accgyro/accgyro_mpu6050.c:112:        acc->acc_1G = 512 * 4;
drivers/accgyro/accgyro_mpu6050.c:115:        acc->acc_1G = 256 * 4;
drivers/accgyro/accgyro_mma845x.c:98:    acc->acc_1G = 256;
drivers/accgyro/accgyro_mpu6500.c:46:    acc->acc_1G = 512 * 4;
drivers/accgyro/accgyro.h:63:    uint16_t acc_1G;
drivers/accgyro/accgyro_mpu9250.c:46:    acc->acc_1G = 512 * 4;
drivers/accgyro/accgyro_bmi160.c:211:    acc->acc_1G = 4096;
drivers/accgyro/accgyro_adxl345.c:68:    acc->acc_1G = 256; // 3.3V operation
drivers/accgyro/accgyro_mpu6000.c:136:    acc->acc_1G = 512 * 4;
drivers/accgyro/accgyro_lsm303dlhc.c:118:    acc->acc_1G = 512 * 8;
shellixyz commented 6 years ago

You can find the right value in the header of your log:

Example in a log coming from a FC using a MPU6000: H acc_1G:2048

col85 commented 6 years ago

@shellixyz I was also tracing the codes and realised that sysConfig.acc_1G is needed in the computation for actual acc in g or m/s^2. Thanks so much for also looking into this. I guess in this case gyroADC values conversion should be of similar approach.

shellixyz commented 6 years ago

For the gyro the values are directly in °/s

col85 commented 6 years ago

Was going through the functions in blackbox_decode.c, I think the default values for gyro are the raw values too. There is a function inside (flightlogGyroToRadiansPerSecond(log, fieldValue) * (180 / M_PI) to convert them to degrees/s. Is my understanding correct or have I mistaken them again?

shellixyz commented 6 years ago

Looks like they are the raw values in the log but the blackbox_decode tool converts the value to °/s too. Like the viewer does.

col85 commented 6 years ago

Sure, thanks so much for your help in this! Going to close this since its cleared up. Cheers!