Browse Source

Fixed automatic log conversion / plotting script

sbg
Lorenz Meier 12 years ago
parent
commit
5f01688490
  1. 16
      ROMFS/logging/logconv.m
  2. 10
      apps/sdlog/sdlog.c

16
ROMFS/logging/logconv.m

@ -1,5 +1,5 @@
clear all clear all
clc close all
%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%
% SYSTEM VECTOR % SYSTEM VECTOR
@ -51,9 +51,21 @@ if exist('sysvector.bin', 'file')
gps = sysvector(:,33:35); gps = sysvector(:,33:35);
gps(~any(gps,2), :) = []; gps(~any(gps,2), :) = [];
plot3(gps(:,1), gps(:,2), gps(:,3)); all_data = figure('Name', 'GPS RAW');
gps_position = plot3(gps(:,1), gps(:,2), gps(:,3));
all_data = figure('Name', 'Complete Log Data (exc. GPS)');
plot(sysvector(:,1), sysvector(:,2:32)); plot(sysvector(:,1), sysvector(:,2:32));
actuator_inputs = figure('Name', 'Attitude controller outputs');
plot(sysvector(:,1), sysvector(:,14:17));
legend('roll motor setpoint', 'pitch motor setpoint', 'yaw motor setpoint', 'throttle motor setpoint');
actuator_outputs = figure('Name', 'Actuator outputs');
plot(sysvector(:,1), sysvector(:,18:25));
legend('actuator 0', 'actuator 1', 'actuator 2', 'actuator 3', 'actuator 4', 'actuator 5', 'actuator 6', 'actuator 7');
end end
if exist('actuator_outputs0.bin', 'file') if exist('actuator_outputs0.bin', 'file')

10
apps/sdlog/sdlog.c

@ -567,6 +567,7 @@ int file_copy(const char* file_old, const char* file_new)
{ {
FILE *source, *target; FILE *source, *target;
source = fopen(file_old, "r"); source = fopen(file_old, "r");
int ret = 0;
if( source == NULL ) if( source == NULL )
{ {
@ -580,21 +581,24 @@ int file_copy(const char* file_old, const char* file_new)
{ {
fclose(source); fclose(source);
warnx("failed to open output file to copy"); warnx("failed to open output file to copy");
return 1;
} }
char buf[128]; char buf[128];
int nread; int nread;
while ((nread = fread(buf, sizeof(buf), 1, source)) > 0) { while ((nread = fread(buf, 1, sizeof(buf), source)) > 0) {
int ret = fwrite(buf, sizeof(buf), 1, target); int ret = fwrite(buf, 1, nread, target);
if (ret <= 0) { if (ret <= 0) {
warnx("error writing file"); warnx("error writing file");
ret = 1;
break; break;
} }
} }
fsync(fileno(target));
fclose(source); fclose(source);
fclose(target); fclose(target);
return 0; return ret;
} }

Loading…
Cancel
Save