From 6877a4b1a342ad815df852d685924b217fca1855 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Fri, 14 Sep 2012 18:59:45 +0200 Subject: [PATCH] Minor tweaks to ROMFS scripts/ logging --- ROMFS/Makefile | 2 +- ROMFS/logging/logconv.m | 98 +++++++++++++++++++++++++++++ ROMFS/logging/sdcard_logconverter.m | 72 --------------------- 3 files changed, 99 insertions(+), 73 deletions(-) create mode 100644 ROMFS/logging/logconv.m delete mode 100755 ROMFS/logging/sdcard_logconverter.m diff --git a/ROMFS/Makefile b/ROMFS/Makefile index ba694b0552..56ae63d271 100644 --- a/ROMFS/Makefile +++ b/ROMFS/Makefile @@ -29,7 +29,7 @@ ROMFS_FSSPEC := $(SRCROOT)/scripts/rcS~init.d/rcS \ $(SRCROOT)/mixers/FMU_RET.mix~mixers/FMU_ERT.mix \ $(SRCROOT)/mixers/FMU_quad_x.mix~mixers/FMU_quad_x.mix \ $(SRCROOT)/mixers/FMU_quad_+.mix~mixers/FMU_quad_+.mix \ - $(SRCROOT)/logging/sdcard_logconverter.m~logging/sdcard_logconverter.m + $(SRCROOT)/logging/logconv.m~logging/logconv.m # # Add the PX4IO firmware to the spec if someone has dropped it into the diff --git a/ROMFS/logging/logconv.m b/ROMFS/logging/logconv.m new file mode 100644 index 0000000000..5a615228d6 --- /dev/null +++ b/ROMFS/logging/logconv.m @@ -0,0 +1,98 @@ +clear all +clc + +if exist('actuator_outputs0.bin', 'file') + % Read actuators file + myFile = java.io.File('actuator_outputs0.bin') + fileSize = length(myFile) + + fid = fopen('actuator_outputs0.bin', 'r'); + elements = int64(fileSize./(16*4+8)) + + for i=1:(elements-2) + % timestamp + actuators(i,1) = double(fread(fid, 1, '*uint64', 0, 'ieee-le.l64')); + % actuators 1-16 + % quadrotor: motor 1-4 on the first four positions + actuators(i, 2:17) = fread(fid, 16, 'float', 'ieee-le'); + end +end + +if exist('actuator_controls0.bin', 'file') + % Read actuators file + myFile = java.io.File('actuator_controls0.bin') + fileSize = length(myFile) + + fid = fopen('actuator_controls0.bin', 'r'); + elements = int64(fileSize./(8*4+8)) + + for i=1:elements + % timestamp + actuator_controls(i,1) = fread(fid, 1, 'uint64', 0, 'ieee-le.l64'); + % actuators 1-16 + % quadrotor: motor 1-4 on the first four positions + actuator_controls(i, 2:9) = fread(fid, 8, 'float', 'ieee-le'); + end +end + + +if exist('sensor_combined.bin', 'file') + % Read sensor combined file + % Type definition: Firmware/apps/uORB/topics/sensor_combined.h + % Struct: sensor_combined_s + fileInfo = dir('sensor_combined.bin'); + fileSize = fileInfo.bytes; + + fid = fopen('sensor_combined.bin', 'r'); + + for i=1:elements + % timestamp + sensors(i,1) = double(fread(fid, 1, '*uint64', 0, 'ieee-le.l64')); + % gyro raw + sensors(i,2:4) = fread(fid, 3, 'int16', 0, 'ieee-le'); + % gyro counter + sensors(i,5) = fread(fid, 1, 'uint16', 0, 'ieee-le'); + % gyro in rad/s + sensors(i,6:8) = fread(fid, 3, 'float', 0, 'ieee-le'); + + % accelerometer raw + sensors(i,9:11) = fread(fid, 3, 'int16', 0, 'ieee-le'); + % padding bytes + fread(fid, 1, 'int16', 0, 'ieee-le'); + % accelerometer counter + sensors(i,12) = fread(fid, 1, 'uint32', 0, 'ieee-le'); + % accel in m/s2 + sensors(i,13:15) = fread(fid, 3, 'float', 0, 'ieee-le'); + % accel mode + sensors(i,16) = fread(fid, 1, 'int32', 0, 'ieee-le'); + % accel range + sensors(i,17) = fread(fid, 1, 'float', 0, 'ieee-le'); + + % mag raw + sensors(i,18:20) = fread(fid, 3, 'int16', 0, 'ieee-le'); + % padding bytes + fread(fid, 1, 'int16', 0, 'ieee-le'); + % mag in Gauss + sensors(i,21:23) = fread(fid, 3, 'float', 0, 'ieee-le'); + % mag mode + sensors(i,24) = fread(fid, 1, 'int32', 0, 'ieee-le'); + % mag range + sensors(i,25) = fread(fid, 1, 'float', 0, 'ieee-le'); + % mag cuttoff freq + sensors(i,26) = fread(fid, 1, 'float', 0, 'ieee-le'); + % mag counter + sensors(i,27) = fread(fid, 1, 'int32', 0, 'ieee-le'); + + % baro pressure millibar + % baro alt meter + % baro temp celcius + % battery voltage + % adc voltage (3 channels) + sensors(i,28:34) = fread(fid, 7, 'float', 0, 'ieee-le'); + % baro counter and battery counter + sensors(i,35:36) = fread(fid, 2, 'uint32', 0, 'ieee-le'); + % battery voltage valid flag + sensors(i,37) = fread(fid, 1, 'uint32', 0, 'ieee-le'); + + end +end \ No newline at end of file diff --git a/ROMFS/logging/sdcard_logconverter.m b/ROMFS/logging/sdcard_logconverter.m deleted file mode 100755 index 09702494c3..0000000000 --- a/ROMFS/logging/sdcard_logconverter.m +++ /dev/null @@ -1,72 +0,0 @@ -clear all -clc - -% Read actuators file -fileInfo = dir('sensors_combined.bin'); -fileSize = fileInfo.bytes; - -fid = fopen('actuator_outputs0.bin', 'r'); -elements = int64(fileSize/16*4+8) - -for i=1:(elements-2) - actuators(i, 2:18) = fread(fid, inf, 'float'); -end - -% Read sensor combined file -% Type definition: Firmware/apps/uORB/topics/sensor_combined.h -% Struct: sensor_combined_s -fileInfo = dir('sensors_combined.bin'); -fileSize = fileInfo.bytes; - -fid = fopen('sensors_combined.bin', 'r'); - -for i=1:elements-2 - % timestamp - sensors(i,1) = double(fread(fid, 1, '*uint64', 0, 'ieee-le.l64')); - % gyro raw - sensors(i,2:4) = fread(fid, 3, 'int16', 0, 'ieee-le'); - % gyro counter - sensors(i,5) = fread(fid, 1, 'uint16', 0, 'ieee-le'); - % gyro in rad/s - sensors(i,6:8) = fread(fid, 3, 'float', 0, 'ieee-le'); - - % accelerometer raw - sensors(i,9:11) = fread(fid, 3, 'int16', 0, 'ieee-le'); - % padding bytes - fread(fid, 1, 'int16', 0, 'ieee-le'); - % accelerometer counter - sensors(i,12) = fread(fid, 1, 'uint32', 0, 'ieee-le'); - % accel in m/s2 - sensors(i,13:15) = fread(fid, 3, 'float', 0, 'ieee-le'); - % accel mode - sensors(i,16) = fread(fid, 1, 'int32', 0, 'ieee-le'); - % accel range - sensors(i,17) = fread(fid, 1, 'float', 0, 'ieee-le'); - - % mag raw - sensors(i,18:20) = fread(fid, 3, 'int16', 0, 'ieee-le'); - % padding bytes - fread(fid, 1, 'int16', 0, 'ieee-le'); - % mag in Gauss - sensors(i,21:23) = fread(fid, 3, 'float', 0, 'ieee-le'); - % mag mode - sensors(i,24) = fread(fid, 1, 'int32', 0, 'ieee-le'); - % mag range - sensors(i,25) = fread(fid, 1, 'float', 0, 'ieee-le'); - % mag cuttoff freq - sensors(i,26) = fread(fid, 1, 'float', 0, 'ieee-le'); - % mag counter - sensors(i,27) = fread(fid, 1, 'int32', 0, 'ieee-le'); - - % baro pressure millibar - % baro alt meter - % baro temp celcius - % battery voltage - % adc voltage (3 channels) - sensors(i,28:34) = fread(fid, 7, 'float', 0, 'ieee-le'); - % baro counter and battery counter - sensors(i,35:36) = fread(fid, 2, 'uint32', 0, 'ieee-le'); - % battery voltage valid flag - sensors(i,37) = fread(fid, 1, 'uint32', 0, 'ieee-le'); - -end \ No newline at end of file