% This file executes the simulation of the equations in 'wrist_model.m'

%	T.D. Tuttle 5-17-95
%	Copyright (c) 1995 by Timothy D. Tuttle and
%	Massachusetts Institute of Technology

t_start = 0;
t_end = 4;
% y_start = [0 .0008 .008 -.00001];
% y_start = [0 0 0 0];
y_start = [0 .8 0.008 -.01];
tol = .00001;
trace = 1;

% Set the input current step.
global im;
im = 0.44;

% Run the simulation.
[T,Y]=ode45('wrist_model',t_start,t_end,y_start,tol,trace);

% Plot the results.
figure(1);
clg;
title('Wrist Harmonic Drive Simulation');
subplot(411);
plot(T,Y(:,1));
grid;
ylabel('WG Position (deg)');

subplot(412);
plot(T,Y(:,2));
grid;
ylabel('WG Velocity (deg/sec)');

subplot(413);
plot(T,Y(:,3));
grid;
ylabel('FS Position (deg)');

subplot(414);
plot(T,Y(:,4));
grid;
ylabel('FS Velocity (deg/sec)');
xlabel('Time(sec)');

figure(2);
clg;
title('Wrist Harmonic Drive Simulation');
plot(T,Y(:,2));
axis([0 4 0 50000]);
grid;
ylabel('WG Velocity (deg/sec)');
xlabel('Time(sec)');

