Institut de Robòtica i Informàtica Industrial
KRD Group

The CuikSuite Project

cuikanimate.c

Go to the documentation of this file.
00001 #include "world.h"
00002 #include "box_list.h"
00003 #include "error.h"
00004 
00044 int main(int argc, char **arg)
00045 {
00046   if (argc>5)
00047     {
00048       Tworld world;
00049       Tparameters parameters;
00050       Tfilename fsols;
00051       Tfilename fparam;
00052       Tfilename fcgl;
00053       Tfilename fworld;
00054       Tlist sol_box_list;
00055       double axesLength;
00056       double frameDelay;
00057       
00058       CreateFileName(NULL,arg[1],NULL,PARAM_EXT,&fparam);
00059       InitParametersFromFile(GetFileFullName(&fparam),&parameters);
00060 
00061       CreateFileName(NULL,arg[1],NULL,WORLD_EXT,&fworld);
00062       InitWorldFromFile(&parameters,&fworld,&world);
00063 
00064       CreateFileName(NULL,arg[2],NULL,SOL_EXT,&fsols);
00065       if (!ReadListOfBoxes(GetFileFullName(&fsols),&sol_box_list))
00066         Error("Solution file can not be opened");
00067       
00068       if (ListSize(&sol_box_list)==0)
00069         Error("Empty list of solutions");
00070 
00071       axesLength=atof(arg[3]);
00072 
00073       frameDelay=atof(arg[4]);
00074 
00075       CreateFileName(NULL,arg[5],NULL,PLOT3D_EXT,&fcgl);
00076 
00077       AnimateWorld(GetFileFullName(&fcgl),axesLength,frameDelay,&sol_box_list,&world);
00078 
00079       DeleteListOfBoxes(&sol_box_list);
00080 
00081       DeleteWorld(&world);
00082       DeleteParameters(&parameters);
00083 
00084       DeleteFileName(&fsols);      
00085       DeleteFileName(&fcgl);      
00086       DeleteFileName(&fworld);    
00087       DeleteFileName(&fparam);
00088     }
00089   else
00090     {
00091      
00092       fprintf(stdout,"  Wrong number of parameters.\n");
00093       fprintf(stdout,"  Use:\n");
00094       fprintf(stdout,"     cuikanimate <world>.world <solutions>.sol <axes> <delay> <animation>.cgl\n");
00095       fprintf(stdout,"  Where:\n");
00096       fprintf(stdout,"     <world>:  File describing the problem\n");
00097       fprintf(stdout,"     <solutions>:  Is the path of solutions to be animated\n");
00098       fprintf(stdout,"     <axes>: Length for the axes for each link. 0 not to display them.\n");
00099       fprintf(stdout,"     <delay>: Delay (in seconds) between frames.\n");
00100       fprintf(stdout,"              To be added to the default delay (0.1 seconds).\n");
00101       fprintf(stdout,"     <animation>:  Is the output file (can be seen with 'geomview')\n");
00102       fprintf(stdout,"  File extensions are not required\n");
00103     }
00104 
00105   return(EXIT_SUCCESS);
00106 }