path="SCI/demos/wheel2";
mode(-1);
getf(path+'/show.sci','c');
xbasc();
flag1=x_choose(['Reading a precomputed trajectory';
 'Simulation with ode (needs f77 and link. may fail, see help link)'],...
'Simulation or Visualisation ? (click below)');

select flag1,
 case 2 then host("cd $"+path+"; make ");
mode(0);
	if ~c_link('wheel') then link('/tmp/wheel.o ','wheel');end
	if ~c_link('wheelg') then link('/tmp/wheelg.o ','wheelg');end
	wheelg=wheelgf;
	tmin=0.0;tmax=15;nn=300;
	times=(0:(nn-1));
	times=tmax*times/(nn-1) +tmin*((nn-1)*ones(times)-times);
	//               INITIAL CONDITIONS
	x0=[0;                 	//theta
  		%pi/2+0.1;   	//phi
    		0;              //psi
    		5.0;        	//Dtheta
    		0.0;          	//Dphi
   		4.0;         	//Dpsi
    		0;           	//x
    		0];           	//y

	//               SIMULATION
	x=ode(x0,tmin,times,'wheel');
	xselect();
	xbasc();
	show(x)
	ystr=[ 'phi';'theta';'psi';'Dpsi';'Dtheta';'Dpsi';'x';'y'];
        flag=2;
	while flag=2, [n1,n2]=size(x);
  		flag=x_choose(['Stop';'Go on'],'Choose');
                if flag=2,x0=evstr(x_mdialog(['Initial conditions'],...
                      ystr,string(x(:,n2))));
  		x=ode(x0,tmin,times,'wheel');
  		xbasc();show(x);
		end;
	end
 case 1 then // A precomputed value for 
	     //x0=[0;%pi/2+0.1;0;5.0;0.0;4.0;0;0];
	x=read(path+'/x.wrt',8,301);
	wheelg=wheelgs;
	show(x);
end


