cuikpatheffort.c
Go to the documentation of this file.
1 #include "world.h"
2 #include "parameters.h"
3 
4 #include "defines.h"
5 #include "error.h"
6 #include "filename.h"
7 #include "atlas.h"
8 #include "samples.h"
9 #include "random.h"
10 
11 #include <stdlib.h>
12 
57 int main(int argc, char **arg)
58 {
59  Tworld world; /* The set of mechanism and obstacles. */
60  Tparameters parameters; /* Parameters used in the Cuik process. */
61 
62  Tfilename fparam;
63  Tfilename fpath;
64 
65  /* input path */
66  unsigned int nvs,ns;
67  double **path;
68 
69  if (argc>=2)
70  {
71  /*Init parameters*/
72  CreateFileName(NULL,arg[1],NULL,PARAM_EXT,&fparam);
73  InitParametersFromFile(GetFileFullName(&fparam),&parameters);
74  fprintf(stderr,"Reading parameters from : %s\n",GetFileFullName(&fparam));
75 
76  if (GetParameter(CT_DYNAMICS,&parameters)>0)
77  Error("cuikpatheffort do not work for problems with dynamics");
78 
79  /*Read the world from file*/
80  InitWorldFromFile(&parameters,FALSE,TRUE,arg[1],&world);
81 
82  if (argc>2)
83  CreateFileName(NULL,arg[2],NULL,SOL_EXT,&fpath);
84  else
85  CreateFileName(NULL,arg[1],"_path",SOL_EXT,&fpath);
86 
87  if (LoadSamples(&fpath,&nvs,&ns,&path))
88  {
89  fprintf(stderr,"Path control effort : %g\n",PathEffort(&parameters,nvs,ns,path,&world));
90  DeleteSamples(ns,path);
91  }
92  else
93  Error("Could not read the input path file");
94 
95  DeleteWorld(&world);
96  DeleteParameters(&parameters);
97 
98  DeleteFileName(&fparam);
99  DeleteFileName(&fpath);
100  }
101  else
102  {
103  fprintf(stderr," Wrong number of parameters.\n");
104  fprintf(stderr," Use:\n");
105  fprintf(stderr," cuikpatheffort <base filename> [<path file>]\n");
106  fprintf(stderr," where <base filename> is used for the parameters, world, and path files.\n");
107  fprintf(stderr," <path file> [optional] is the file with the path.\n");
108  }
109  return(EXIT_SUCCESS);
110 }
111