Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
bw1129 committed Aug 27, 2019
1 parent 97dce95 commit 1261e1c
Show file tree
Hide file tree
Showing 18 changed files with 107 additions and 42 deletions.
24 changes: 13 additions & 11 deletions PIDtoolbox.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
% can do whatever you want with this stuff. If we meet some day, and you think
% this stuff is worth it, you can buy me a beer in return. -Brian White
% ----------------------------------------------------------------------------------


PtbVersion='v0.32';

executableDir = pwd;
addpath(executableDir)

try
if exist('logfileDir.txt') %if this exists, change directory accordingly
fid = fopen('logfileDir.txt');
logfileDir = fscanf(fid,'%s');
fclose(fid);
end
fid = fopen('logfileDir.txt');
logfileDir = fscanf(fid,'%s');
fclose(fid);
catch
logfileDir=[];
end

%%%% assign main figure handle and define some UI variables
Expand All @@ -40,8 +41,8 @@
epoch1_B=[];
epoch2_B=[];
updateSpec=0;
A_debugmode=6;%default to gyro_scaled
B_debugmode=6;
A_debugmode=0;%default to gyro_scaled
B_debugmode=0;
filepathA=[];
filepathB=[];
filenameA=[];
Expand All @@ -54,12 +55,13 @@
hexpand5=[];
hexpand6=[];

errmsg=[];

plotall_flag=-1;

colorA=[.93 .5 .3];
colorB=[.3 .65 .95];

PtbVersion='v0.30';
%use_phsCorrErr=0;
flightSpec=0;
screensz = get(0,'ScreenSize');
Expand Down Expand Up @@ -156,11 +158,11 @@
TooltipString_refresh=['Refreshes fonts and button sizes after change in window size'];
%%%
guiHandles.fileA = uicontrol(PTfig,'string','Select File [A]','fontsize',fontsz,'TooltipString', [TooltipString_files], 'units','normalized','outerposition',[posInfo.fileA],...
'callback','cd(logfileDir);[filenameA, filepathA] = uigetfile({''*.BBL;*.BFL'' }); if filepathA==0, filepathA=[]; filenameA=[]; end, filenameAtmp=[];');
'callback','try, if ~isempty(logfileDir), cd(logfileDir), end, catch, end; [filenameA, filepathA] = uigetfile({''*.BBL;*.BFL'' }); if filepathA==0, filepathA=[]; filenameA=[]; end, filenameAtmp=[];');
guiHandles.fileA.BackgroundColor=colorA;

guiHandles.fileB = uicontrol(PTfig,'string','Select File [B]','fontsize',fontsz,'TooltipString', [TooltipString_files],'units','normalized','outerposition',[posInfo.fileB],...
'callback','cd(logfileDir);[filenameB, filepathB] = uigetfile({''*.BBL;*.BFL'' }); if filepathB==0, filepathB=[]; filenameB=[]; end, filenameBtmp=[];');
'callback','try, if ~isempty(logfileDir), cd(logfileDir), end, catch, end;[filenameB, filepathB] = uigetfile({''*.BBL;*.BFL'' }); if filepathB==0, filepathB=[]; filenameB=[]; end, filenameBtmp=[];');
guiHandles.fileB.BackgroundColor=colorB;
guiHandles.runAll = uicontrol(PTfig,'string','Load+Run','fontsize',fontsz,'TooltipString', [TooltipString_loadRun],'units','normalized','outerposition',[posInfo.runAll],...
'callback','guiHandles.runAll.FontWeight=''bold'';PTload;PTprocess;PTviewerUIcontrol; PTplotLogViewer; guiHandles.runAll.FontWeight=''normal'';');
Expand Down
2 changes: 1 addition & 1 deletion PTcolormap.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
% this stuff is worth it, you can buy me a beer in return. -Brian White
% ----------------------------------------------------------------------------------


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a=colormap(parula);
viridis=[a(:,1) a(:,2) a(:,3)*.6];
Expand Down Expand Up @@ -317,3 +316,4 @@

end


2 changes: 2 additions & 0 deletions PTdispSetupInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
% can do whatever you want with this stuff. If we meet some day, and you think
% this stuff is worth it, you can buy me a beer in return. -Brian White
% ----------------------------------------------------------------------------------

if ~isempty(filenameA) || ~isempty(filenameB)

PTdisp=figure(5);
Expand Down Expand Up @@ -71,4 +72,5 @@
errordlg('Please select file(s) then click ''load+run''', 'Error, no data');
pause(2);
end


10 changes: 9 additions & 1 deletion PTerrUIcontrol.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
%% PTerrUIcontrol - ui controls for PID error analyses

% ----------------------------------------------------------------------------------
% "THE BEER-WARE LICENSE" (Revision 42):
% <brian.white@queensu.ca> wrote this file. As long as you retain this notice you
% can do whatever you want with this stuff. If we meet some day, and you think
% this stuff is worth it, you can buy me a beer in return. -Brian White
% ----------------------------------------------------------------------------------


if ~isempty(filenameA) || ~isempty(filenameB)

PTerrfig=figure(3);
Expand Down Expand Up @@ -54,4 +62,4 @@
else
errordlg('Please select file(s) then click ''load+run''', 'Error, no data');
pause(2);
end
end
8 changes: 8 additions & 0 deletions PTerrorMessages.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function [errorMessage] = PTerrorMessages(message_string, err)
%%
errorMessage = sprintf(['Error in ' message_string ' \n\n Message:\n%s'], err.message);
% Display pop up message and wait for user to click OK
uiwait(warndlg(errorMessage));
close
end

4 changes: 1 addition & 3 deletions PTimport.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
% this stuff is worth it, you can buy me a beer in return. -Brian White
% ----------------------------------------------------------------------------------


%%

waitbarFid = waitbar(0,'Please wait...');
pause(.5)

Expand Down Expand Up @@ -290,5 +290,3 @@
DAT=[];
end



35 changes: 29 additions & 6 deletions PTload.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
% https://github.com/betaflight/betaflight/wiki/Debug-Modes?fbclid=IwAR2bKepD_cNZNnRtlAxf7yf3CWjYm2-MbFuwoGn3tUm8wPefp9CCJQR7c9Y
GYRO_SCALED=6;
DSHOT_RPM_TELEMETRY=47;



try

if ~isempty(filenameA) || ~isempty(filenameB)


Expand Down Expand Up @@ -55,7 +56,11 @@
if isempty(filenameAtmp)
filenameAtmp=filenameA;
clear dataA dat_A
try
[dataA] = PTimport(filenameA);
catch ME
errmsg.PTimport=PTerrorMessages('PTimport', ME);
end
if ~isempty(dataA)
dataA.VarLabels(size(dataA.VarLabels,2)+1)={'axisDuf[0]'};% to be computed below
dataA.VarLabels(size(dataA.VarLabels,2)+1)={'axisDuf[1]'};
Expand Down Expand Up @@ -102,7 +107,11 @@
if isempty(filenameBtmp)
filenameBtmp=filenameB;
clear dataB dat_B
try
[dataB] = PTimport(filenameB);
catch ME
errmsg.PTimport=PTerrorMessages('PTimport', ME);
end
if ~isempty(dataB)
dataB.VarLabels(size(dataB.VarLabels,2)+1)={'axisDuf[0]'};% to be computed below
dataB.VarLabels(size(dataB.VarLabels,2)+1)={'axisDuf[1]'};
Expand Down Expand Up @@ -203,8 +212,13 @@
DATmainA.Iterm(2,:)=dataA.DataMain(:,find(strcmp(dataA.VarLabels, 'axisI[1]')));
DATmainA.Iterm(3,:)=dataA.DataMain(:,find(strcmp(dataA.VarLabels, 'axisI[2]')));

DATmainA.DtermFilt(1,:)=dataA.DataMain(:,find(strcmp(dataA.VarLabels, 'axisD[0]')));
DATmainA.DtermFilt(2,:)=dataA.DataMain(:,find(strcmp(dataA.VarLabels, 'axisD[1]')));
try %dterm is only PID term that if set to 0 will not generate axisD variable at all
DATmainA.DtermFilt(1,:)=dataA.DataMain(:,find(strcmp(dataA.VarLabels, 'axisD[0]')));
DATmainA.DtermFilt(2,:)=dataA.DataMain(:,find(strcmp(dataA.VarLabels, 'axisD[1]')));
catch
DATmainA.DtermFilt(1,:)=zeros(1,length(DATmainA.GyroFilt(1,:)));
DATmainA.DtermFilt(2,:)=zeros(1,length(DATmainA.GyroFilt(1,:)));
end

DATmainA.DtermRaw(1,:)=[-(diff(DATmainA.GyroFilt(1,:))) 0];
DATmainA.DtermRaw(2,:)=[-(diff(DATmainA.GyroFilt(2,:))) 0];
Expand Down Expand Up @@ -326,8 +340,14 @@
DATmainB.Iterm(2,:)=dataB.DataMain(:,find(strcmp(dataB.VarLabels, 'axisI[1]')));
DATmainB.Iterm(3,:)=dataB.DataMain(:,find(strcmp(dataB.VarLabels, 'axisI[2]')));

DATmainB.DtermFilt(1,:)=dataB.DataMain(:,find(strcmp(dataB.VarLabels, 'axisD[0]')));
DATmainB.DtermFilt(2,:)=dataB.DataMain(:,find(strcmp(dataB.VarLabels, 'axisD[1]')));
try %dterm is only PID term that if set to 0 will not generate axisD variable at all
DATmainB.DtermFilt(1,:)=dataB.DataMain(:,find(strcmp(dataB.VarLabels, 'axisD[0]')));
DATmainB.DtermFilt(2,:)=dataB.DataMain(:,find(strcmp(dataB.VarLabels, 'axisD[1]')));
catch
DATmainB.DtermFilt(1,:)=zeros(1,length(DATmainB.GyroFilt(1,:)));
DATmainB.DtermFilt(2,:)=zeros(1,length(DATmainB.GyroFilt(1,:)));
end


DATmainB.DtermRaw(1,:)=[-(diff(DATmainB.GyroFilt(1,:))) 0];
DATmainB.DtermRaw(2,:)=[-(diff(DATmainB.GyroFilt(2,:))) 0];
Expand Down Expand Up @@ -458,6 +478,9 @@

end

catch ME
errmsg.PTload=PTerrorMessages('PTload', ME);
end

%% some functions used within this script
function [throttlePercent] = PTthrPercent(X)
Expand Down
7 changes: 7 additions & 0 deletions PTplotLogViewer.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
% ----------------------------------------------------------------------------------

% tic

try

if ~isempty(filenameA) || ~isempty(filenameB)

set(PTfig, 'pointer', 'watch')
Expand Down Expand Up @@ -338,5 +341,9 @@
pause(2);
end

catch
close
end

%toc

12 changes: 8 additions & 4 deletions PTplotPIDerror.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
% this stuff is worth it, you can buy me a beer in return. -Brian White
% ----------------------------------------------------------------------------------

try

set(PTerrfig, 'pointer', 'watch')

if ~isempty(filenameA) || ~isempty(filenameB)
Expand Down Expand Up @@ -177,12 +179,14 @@
end


%



%
end

set(PTerrfig, 'pointer', 'arrow')


catch err
msgPTplotPIDerror=PTerrorMessages('PTplotPIDerror', err);
end


1 change: 0 additions & 1 deletion PTplotSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
% this stuff is worth it, you can buy me a beer in return. -Brian White
% ----------------------------------------------------------------------------------


if ~isempty(filenameA) || ~isempty(filenameB)

%% update fonts
Expand Down
4 changes: 1 addition & 3 deletions PTplotStats.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
% can do whatever you want with this stuff. If we meet some day, and you think
% this stuff is worth it, you can buy me a beer in return. -Brian White
% ----------------------------------------------------------------------------------



if ~isempty(filenameA) || ~isempty(filenameB)
%% update fonts

Expand Down Expand Up @@ -294,7 +293,6 @@
axis([1 99 0 .1])
end


end


9 changes: 6 additions & 3 deletions PTprocess.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
% this stuff is worth it, you can buy me a beer in return. -Brian White
% ----------------------------------------------------------------------------------


try

if ~isempty(filenameA) || ~isempty(filenameB)

downsampleMultiplier=5;% 5th of the resolution for faster plotting, display only

set(PTfig, 'pointer', 'watch')
Expand Down Expand Up @@ -116,4 +117,6 @@
set(PTfig, 'pointer', 'arrow')
end


catch ME
errmsg.PTprocess=PTerrorMessages('PTprocess', ME);
end
1 change: 0 additions & 1 deletion PTsaveFig.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
% this stuff is worth it, you can buy me a beer in return. -Brian White
% ----------------------------------------------------------------------------------

%%
%% create saveDirectory
if ~isempty(filenameA) && ~isempty(filenameB)
saveDirectory=[filenameA(1:end-4) '-' filenameB(1:end-4)];
Expand Down
3 changes: 1 addition & 2 deletions PTspecUIcontrol.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
% can do whatever you want with this stuff. If we meet some day, and you think
% this stuff is worth it, you can buy me a beer in return. -Brian White
% ----------------------------------------------------------------------------------

if ~isempty(filenameA) || ~isempty(filenameB)

%%% tooltips
Expand Down Expand Up @@ -250,7 +250,6 @@
pause(2);
end


% functions
function selection2(src,event)
val = c.Value;
Expand Down
3 changes: 2 additions & 1 deletion PTstatsUIcontrol.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
% can do whatever you want with this stuff. If we meet some day, and you think
% this stuff is worth it, you can buy me a beer in return. -Brian White
% ----------------------------------------------------------------------------------

if ~isempty(filenameA) || ~isempty(filenameB)

PTstatsfig=figure(6);
Expand Down Expand Up @@ -53,4 +54,4 @@
else
errordlg('Please select file(s) then click ''load+run''', 'Error, no data');
pause(2);
end
end
2 changes: 1 addition & 1 deletion PTtuneUIcontrol.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
% can do whatever you want with this stuff. If we meet some day, and you think
% this stuff is worth it, you can buy me a beer in return. -Brian White
% ----------------------------------------------------------------------------------

if ~isempty(filenameA) || ~isempty(filenameB)

PTtunefig=figure(4);
Expand Down
4 changes: 2 additions & 2 deletions PTtuningParams.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
% can do whatever you want with this stuff. If we meet some day, and you think
% this stuff is worth it, you can buy me a beer in return. -Brian White
% ----------------------------------------------------------------------------------



if ~isempty(filenameA) || ~isempty(filenameB)

PTtunefig=figure(4);
Expand Down Expand Up @@ -156,3 +155,4 @@
end



Loading

0 comments on commit 1261e1c

Please sign in to comment.