cuiksample.c
Go to the documentation of this file.
1 #include "box.h"
2 #include "random.h"
3 #include "defines.h"
4 #include "filename.h"
5 #include "cuiksystem.h"
6 
7 #include <stdlib.h>
8 
48 int main(int argc, char **arg)
49 {
50  if (argc>2)
51  {
52  Tparameters parameters;
53  TCuikSystem cuiksystem;
54 
55  Tfilename fcuik;
56  Tfilename fparam;
57 
58  unsigned int ndof,nsamples;
59 
60  randomReset();
61 
62  /*Init parameters*/
63  CreateFileName(NULL,arg[1],NULL,PARAM_EXT,&fparam);
64  InitParametersFromFile(GetFileFullName(&fparam),&parameters);
65 
66  /* Read the problem file */
67  CreateFileName(NULL,arg[1],NULL,CUIK_EXT,&fcuik);
68  InitCuikSystemFromFile(&parameters,GetFileFullName(&fcuik),&cuiksystem);
69 
70  ndof=(unsigned int)GetParameter(CT_N_DOF,&parameters);
71  if (ndof==0)
72  ndof=NO_UINT;
73 
74  nsamples=atoi(arg[2]);
75 
76  /* SampleCuikSystem(&parameters,arg[1],NULL,nsamples,NO_UINT,ndof,&cuiksystem);*/
77 
78  {
79  unsigned int k;
80  boolean *fv;
81 
82  NEW(fv,382,boolean);
83  for(k=0;k<382;k++)
84  fv[k]=FALSE;
85 
86  fv[156]=TRUE; // object rotation u_x u_y v_x
87  fv[157]=TRUE;
88  fv[159]=TRUE;
89 
90  fv[341]=TRUE; // Spherical joints at the end of the fingers
91  fv[352]=TRUE;
92  fv[363]=TRUE;
93  fv[374]=TRUE;
94 /*
95  fv[342]=TRUE; //In patch joints
96  fv[343]=TRUE;
97 
98  fv[353]=TRUE;
99  fv[354]=TRUE;
100 
101  fv[364]=TRUE;
102  fv[365]=TRUE;
103 
104  fv[375]=TRUE;
105  fv[376]=TRUE;
106 */
107  // finger 2 dof
108  fv[64]=TRUE; //fv[256]=TRUE;
109  fv[258]=TRUE;//fv[257]=TRUE;
110  fv[264]=TRUE;
111  fv[271]=TRUE;
112 
113  // finger 3 dof
114  fv[284]=TRUE;
115  fv[286]=TRUE;//fv[285]=TRUE;
116  fv[292]=TRUE;
117  fv[299]=TRUE;
118 
119  // finger 4 dof
120  fv[306]=TRUE;
121  fv[319]=TRUE;
122  fv[320]=TRUE;
123  fv[327]=TRUE;
124  fv[334]=TRUE;
125 
126  IncrementalSampleCuikSystem(&parameters,arg[1],NULL,fv,nsamples,NO_UINT,ndof,&cuiksystem);
127 
128  free(fv);
129  }
130 
131 
132  DeleteCuikSystem(&cuiksystem);
133  DeleteParameters(&parameters);
134 
135  DeleteFileName(&fcuik);
136  DeleteFileName(&fparam);
137  }
138  else
139  {
140  fprintf(stderr," Wrong number of parameters.\n");
141  fprintf(stderr," Use:\n");
142  fprintf(stderr," cuiksample <problem filename>.cuik <num samples>\n");
143  fprintf(stderr," where <problem filename> contains the kinematic equations\n");
144  fprintf(stderr," <num samples> the number of samples to generate\n");
145  fprintf(stderr," (the '.cuik' extension is not required)\n");
146  }
147 
148  return(EXIT_SUCCESS);
149 }
#define FALSE
FALSE.
Definition: boolean.h:30
#define NEW(_var, _n, _type)
Allocates memory space.
Definition: defines.h:385
Data structure to hold the information about the name of a file.
Definition: filename.h:248
boolean IncrementalSampleCuikSystem(Tparameters *p, char *fname, Tlist *sb, boolean *fixVars, unsigned int nsamples, unsigned int ntries, unsigned int ndof, TCuikSystem *cs)
Generates samples for a cuiksystem.
Definition: cuiksystem.c:3218
void randomReset()
Resets the random seed.
Definition: random.c:18
void DeleteCuikSystem(TCuikSystem *cs)
Destructor.
Definition: cuiksystem.c:5113
int main(int argc, char **arg)
Main body of the cuiksample application.
Definition: cuiksample.c:48
Definition of the Tfilename type and the associated functions.
#define TRUE
TRUE.
Definition: boolean.h:21
#define PARAM_EXT
File extension for parameter files.
Definition: filename.h:131
#define CUIK_EXT
File extension for equation files.
Definition: filename.h:70
void DeleteFileName(Tfilename *fn)
Destructor.
Definition: filename.c:205
Definition of the Tbox type and the associated functions.
Definitions of constants and macros used in several parts of the cuik library.
void InitCuikSystemFromFile(Tparameters *p, char *filename, TCuikSystem *cs)
Constructor from a file.
A table of parameters.
Definition of the TCuikSystem type and the associated functions.
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
A cuiksystem, i.e., a set of variables and equations defining a position analysis problem...
Definition: cuiksystem.h:181
#define NO_UINT
Used to denote an identifier that has not been initialized.
Definition: defines.h:435
void DeleteParameters(Tparameters *p)
Destructor.
Definition: parameters.c:295
double GetParameter(unsigned int n, Tparameters *p)
Gets the value for a particular parameter.
Definition: parameters.c:93
#define CT_N_DOF
Dimensionality of the solution space for the mechanism at hand.
Definition: parameters.h:318
Definition of basic randomization functions.