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  /*Read the world from file*/
77  InitWorldFromFile(&parameters,TRUE,arg[1],&world);
78 
79  if (argc>2)
80  CreateFileName(NULL,arg[2],NULL,SOL_EXT,&fpath);
81  else
82  CreateFileName(NULL,arg[1],"_path",SOL_EXT,&fpath);
83 
84  if (LoadSamples(&fpath,&nvs,&ns,&path))
85  {
86  fprintf(stderr,"Path control effort : %g\n",PathEffort(&parameters,nvs,ns,path,&world));
87  DeleteSamples(ns,path);
88  }
89  else
90  Error("Could not read the input path file");
91 
92  DeleteWorld(&world);
93  DeleteParameters(&parameters);
94 
95  DeleteFileName(&fparam);
96  DeleteFileName(&fpath);
97  }
98  else
99  {
100  fprintf(stderr," Wrong number of parameters.\n");
101  fprintf(stderr," Use:\n");
102  fprintf(stderr," cuikpatheffort <base filename> [<path file>]\n");
103  fprintf(stderr," where <base filename> is used for the parameters, world, and path files.\n");
104  fprintf(stderr," <path file> [optional] is the file with the path.\n");
105  }
106  return(EXIT_SUCCESS);
107 }
108 
int main(int argc, char **arg)
Main body of the cuikpatheffort application.
Data structure to hold the information about the name of a file.
Definition: filename.h:271
double PathEffort(Tparameters *p, unsigned int m, unsigned int np, double **point, Tworld *w)
Approximated control effort of a path.
Definition: samples.c:1708
Definition of the Tfilename type and the associated functions.
#define TRUE
TRUE.
Definition: boolean.h:21
void Error(const char *s)
General error function.
Definition: error.c:80
#define PARAM_EXT
File extension for parameter files.
Definition: filename.h:132
All the necessary information to generate equations for mechanisms.
Definition: world.h:229
Definition of the Tworld type and the associated functions.
void DeleteWorld(Tworld *w)
Destructor.
Definition: world.c:3952
Error and warning functions.
void DeleteFileName(Tfilename *fn)
Destructor.
Definition: filename.c:205
boolean LoadSamples(Tfilename *fname, unsigned int *nvs, unsigned int *ns, double ***path)
Reads a set of samples from file.
Definition: samples.c:2913
Definitions of constants and macros used in several parts of the cuik library.
A table of parameters.
void CreateFileName(char *path, char *name, char *suffix, char *ext, Tfilename *fn)
Constructor.
Definition: filename.c:22
void InitParametersFromFile(char *file, Tparameters *p)
Constructor from a file.
Definition: parameters.c:51
Definition of an atlas on a manifold.
char * GetFileFullName(Tfilename *fn)
Gets the file full name (paht+name+extension).
Definition: filename.c:151
#define SOL_EXT
File extension for solution files.
Definition: filename.h:138
boolean InitWorldFromFile(Tparameters *p, boolean error, char *fn, Tworld *w)
Constructor.
void DeleteParameters(Tparameters *p)
Destructor.
Definition: parameters.c:294
Auxiliary functions to deal with sets of samples.
Definition of basic randomization functions.
void DeleteSamples(unsigned int ns, double **path)
Deletes the space used by a set of samples.
Definition: samples.c:3159
Definition of the Tparameters type and the associated functions.