cuikTWS.c
Go to the documentation of this file.
1 #include "parameters.h"
2 #include "defines.h"
3 #include "world.h"
4 #include "error.h"
5 #include "filename.h"
6 
7 #include <stdlib.h>
8 #include <string.h>
9 #include <unistd.h>
10 
79 int main(int argc, char **arg)
80 {
81  Tparameters parameters; /* Parameters */
82  Tworld world; /* Environemtn and mechanisms */
83  TCuikSystem cs; /* The cuiksystem to generate*/
84 
85  Tfilename fparam;
86  Tfilename fcuik;
87 
88  FILE *f;
89 
90  if (argc>2)
91  {
92  /*Init parameters*/
93  CreateFileName(NULL,arg[1],NULL,PARAM_EXT,&fparam);
94  #if (_DEBUG>0)
95  printf("Reading parameter file : %s\n",GetFileFullName(&fparam));
96  #endif
97  InitParametersFromFile(GetFileFullName(&fparam),&parameters);
98 
99  /*keep equations in the original form*/
100  ChangeParameter(CT_DUMMIFY,0,&parameters);
101 
102  /*Read the world file*/
103  InitWorldFromFile(&parameters,TRUE,arg[1],&world);
104 
105  /*Add TWS equations*/
106  GenerateWorldTWSEquations(&parameters,arg[2],&cs,&world);
107 
108  /*Print resulting extended cuiksystem*/
109  CreateFileName(NULL,arg[1],"_TWS",CUIK_EXT,&fcuik);
110 
111  f=fopen(GetFileFullName(&fcuik),"w");
112  if (!f)
113  Error("Could not open output file in cuiksingequations");
114  #if (_DEBUG>0)
115  printf("Generating the _TWS.cuik file : %s\n",GetFileFullName(&fcuik));
116  #endif
117  PrintCuikSystemWithSimplification(&parameters,f,&cs);
118  fclose(f);
119 
120  /* link the parameter/joints/links files */
121  LinkFileNameWithExtension(arg[1],PARAM_EXT ,&fcuik);
122  LinkFileNameWithExtension(arg[1],JOINTS_EXT,&fcuik);
123  LinkFileNameWithExtension(arg[1],LINKS_EXT ,&fcuik);
124 
125  /* Delete the data structures */
126  DeleteCuikSystem(&cs);
127  DeleteParameters(&parameters);
128 
129  /* Delete the file names */
130  DeleteFileName(&fparam);
131  DeleteFileName(&fcuik);
132  }
133  else
134  {
135  fprintf(stderr," Wrong number of parameters.\n");
136  fprintf(stderr," Use:\n");
137  fprintf(stderr," cuikTWS <Sing> <problem name>\n");
138  fprintf(stderr," where \n");
139  fprintf(stderr," <problem name> is the world file from which to generate the equations\n");
140  fprintf(stderr," <Sing> It must be the name of the link to focus\n");
141  }
142 
143  return(EXIT_SUCCESS);
144 }
145 
int main(int argc, char **arg)
Main body of the cuikTWS application.
Definition: cuikTWS.c:79
void PrintCuikSystemWithSimplification(Tparameters *p, FILE *f, TCuikSystem *cs)
Prints the simplified cuiksystem.
Definition: cuiksystem.c:5384
Data structure to hold the information about the name of a file.
Definition: filename.h:271
void DeleteCuikSystem(TCuikSystem *cs)
Destructor.
Definition: cuiksystem.c:5450
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
#define CUIK_EXT
File extension for equation files.
Definition: filename.h:71
Definition of the Tworld type and the associated functions.
Error and warning functions.
void DeleteFileName(Tfilename *fn)
Destructor.
Definition: filename.c:205
void LinkFileNameWithExtension(char *fn1, char *ext, Tfilename *fn2)
Creates a link to a given filename.
Definition: filename.c:177
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
char * GetFileFullName(Tfilename *fn)
Gets the file full name (paht+name+extension).
Definition: filename.c:151
#define CT_DUMMIFY
Dummification level.
Definition: parameters.h:339
boolean InitWorldFromFile(Tparameters *p, boolean error, char *fn, Tworld *w)
Constructor.
void GenerateWorldTWSEquations(Tparameters *p, char *ln, TCuikSystem *cs, Tworld *w)
Adds variables/equations to detect translational workspace boundaries.
Definition: world.c:3104
#define JOINTS_EXT
File extension for files with samples represented by the joint values.
Definition: filename.h:188
A cuiksystem, i.e., a set of variables and equations defining a position analysis problem...
Definition: cuiksystem.h:181
void DeleteParameters(Tparameters *p)
Destructor.
Definition: parameters.c:294
Definition of the Tparameters type and the associated functions.
void ChangeParameter(unsigned int n, double v, Tparameters *p)
Sets the value for a particular parameter.
Definition: parameters.c:164
#define LINKS_EXT
File extension for files with samples represented by the link poses.
Definition: filename.h:181