%
%    VPLANE - script to plot depth and pitch control parameters in
%    subplots of one large window.
%
%    MIT SeaGrant Lab
%
%    Copyright (C) 1995-1998
%    Massachussetts Institute of Technology
%    Sea Grant AUV Laboratory
%    $Id: vplane.m,v 1.2 2000/01/18 02:11:29 rob Exp $	

global run_name

if exist( 'h_dpt' ) ~= 1
    h_dpt = figure;
    winpos( position(1,:) );
else 
    figure( h_dpt ); 
end
    
set( h_dpt, 'name', 'DorOdyssey Depth Control', 'DeleteFcn', 'clear h_dpt' );

%
% I'm not sure what he's doing with this.  I replaced "rows" in
% subplot(2,1,1) with ":".
%
%rows = 1:length(data);
%if diff(dataDC(1:2,c_depth)) > .5
%    rows(1) = [];
%end

subplot( 2, 1, 1 )
cla
[xx,yy] = stairs( dataNav(:,m_present_time), dataNav(:,mDepth) );
[xx1,yy1] = stairs( dataDC(:,m_present_time), dataDC(:,cDepth) );
plot( xx, yy, xx1, yy1 );
if exist( 'tDepth' ) == 1
    colors = get( gca, 'ColorOrder' );
    [xx,yy] = stairs( dataDC(:,m_present_time), dataDC(:,tDepth) );
    line( xx, yy, 'Color', colors(3,:) );
end
set( gca, 'ydir', 'reverse' );
title( ['Commanded and Measured Depth: ' run_name] );
xlabel( 'elapsed time (s)' );
ylabel( 'depth (m)' );
legend('Meas. Depth', 'Cmded. Depth', 'Smooth Depth',0)
zoom on
grid on

subplot( 4, 1, 3 )
cla
[xx,yy] = stairs( dataDC(:,m_present_time), dataDC(:,cTheta)*180/pi );
plot( dataNav(:,m_present_time), dataNav(:,mTheta)*180/pi, xx, yy );
if exist( 'd_integral' ) == 1
    line( dataDC(:,1), dataDC(:,dIntegral)*180/pi, 'Color', colors(4,:) );
    title( 'Commanded & Measured Pitch, Depth Integral' )
else
    title( 'Commanded and Measured Pitch' );    
end

ylabel( 'pitch (deg)' );
zoom on
grid on
legend(' Meas.', 'Cmded.', 'Depth Int.',0)

subplot( 4, 1, 4 )
cla
pctrl
clear  xx yy colors
