% This file executes the simulation of the equations in 'wrist_model.m'
% and creates a plot for severl different input steps of current.

% Set the initial conditions.
t_start = 0;
t_end = 4;
y_start = [0 .8 0.008 -.01];
tol = .00001;
trace = 1;

% Set the input current steps.
global im;
inputs = [0.28 0.36 0.40 0.44 0.48 0.52 0.56];

% Initialize the plot.
figure(1);
clg;
title('Wrist Harmonic Drive Simulation');
ylabel('WG Velocity (deg/sec)');
xlabel('Time(sec)');
axis([0 4 0 50000]);
grid;
hold on;

% Run the simulation for each of the inputs and save the wave-generator
% velocity.
for ii = 1:length(inputs),
  im = inputs(ii);
  disp(['Starting simulation number ' num2str(ii) ...
        ' with im = ' num2str(im)]);
  clear T Y;
  [T,Y]=ode45('wrist_model',t_start,t_end,y_start,tol,trace);
  plot(T,Y(:,2));
end
