%
% PURPOSE: Plot ahrs data.
%
% LOG:     30 June 2021 rsm.
%
lstr={};
lrDatPtr=[];
lrUsblPtr=[];
%global titleStr;
titleStr = [' Data Set: ', replace(DirName2,'_','-'), ' / ', replace(filepath,'_','-')];
if exist( 'position' ) ~= 1
  MonitorPositions = get(0,'MonitorPositions');
  position = MonitorPositions(end,:);
  npposition(1:2) = position(1:2) + round([position(3)*.02 position(4)*.04]);
  npposition(3:4) = round([position(3)*.95 position(4)*.90]);
  position = npposition;
end
if exist( 'lrAhrsFigPtr' ) ~= 1
  lrAhrsFigPtr= figure;
  set( lrAhrsFigPtr, 'Name', 'LR Ahrs', 'DeleteFcn', 'clear lrAhrsFigPtr' );
  set(gcf,'position',position)
  if(exist('fontsize1')) 
    lrNavFontsize=fontsize1;
  else
    lrNavFontsize=20;
  end
  lrNavFontweight='normal';
  set(gca,'fontsize',lrNavFontsize,'fontweigh',lrNavFontweight)
  set(gcf,'defaultaxesfontsize',lrNavFontsize,'defaulttextfontsize', ...
      lrNavFontsize)
  lrNavAxesPtr = gca;
else
 figure(lrAhrsFigPtr);
end

vehicleDataAvail = 0;
%
% Check to see if we've got vehicle data.  If so, plot it.
if( exist( 'data' ) && isfield( data, 'AHRS_M2') )
  vehicleDataAvail = 1;
  fprintf('Plotting vehicle data.\n');
  subplot(3,1,1)
  plot(data.AHRS_M2.platform_roll_angle.time, data.AHRS_M2.platform_roll_angle.value*180/pi)
  grid on
  ylabel('Roll, Degrees')
  dynamicDateTicks
  title(titleStr)
  

  subplot(3,1,2)
  plot(data.AHRS_M2.platform_pitch_angle.time, data.AHRS_M2.platform_pitch_angle.value*180/pi,'b');
  grid on
  ylabel('Pitch, Degrees')
  dynamicDateTicks
  
  subplot(3,1,3)
  plot(data.AHRS_M2.platform_orientation.time, data.AHRS_M2.platform_orientation.value*180/pi,'b');
  grid on
  ylabel('Yaw, Degrees')
  dynamicDateTicks
  
  linkaxes(get(gcf,'children'),'x')


else
  fprintf('No data found.  Assuming orignal vehicle data (not replay) is in struct ''data''.\n');
  return
end














