readworld.y
Go to the documentation of this file.
1 %{
3 #include "world.h"
4 
5 #include "boolean.h"
6 #include "error.h"
7 #include "error_world.h"
8 #include "constants.h"
9 #include "defines.h"
10 #include "color.h"
11 #include "htransform.h"
12 #include "vector.h"
13 
14 #include <stdlib.h>
15 #include <stdio.h>
16 #include <string.h>
17 #include <math.h>
18 
19 /*
20 * Definition of the function that initilizes a kinematic equations from a file.
21 * This is a method of the equations object.
22 */
23 
24  /*Lex and Yacc variables*/
25  extern FILE *ReadWorldin;
26 
27  /* first link/object in the file currently bein parsed */
28  extern unsigned int firstLink; /* first link in the current object */
29  extern unsigned int firstObject; /* first object in the current file */
30 
31  /*Lex and Yacc functions*/
32  int ReadWorldlex(void);
33  void Switch2File(char *ln,unsigned int nl,unsigned int no,char *path,char *file);
34 
35  /*Our own variables*/
36  extern unsigned int RWline; /* line number currently processed
37  (incremented by the LEX processor)*/
38 
39  /*Auxiliary variables used along readwordl*/
40  unsigned int rw_lID,rw_lID1,rw_lID2; /*link identifier*/
41  Tlink rw_link;
42  Tjoint rw_joint;
43  boolean rw_visible;
44 
45  /* Global pointer to allow the different parts of the parser to acces the
46  equations being initialized*/
47  Tworld *rw_world;
48 
49  /* Global pointer to the paramters */
50  Tparameters *rw_parameters;
51 
52  THTransform rw_transform;
53 
54  unsigned int rw_r;
55 
56  double **rw_point;
57  unsigned int rw_i,rw_max;
58  double *rw_X,*rw_Y,*rw_Z;
59  double rw_angle;
60  Tinterval rw_range,rw_range0;
61  boolean rw_has_limits;
62  double **rw_range_point;
63  double **rw_in_patch_point;
64  Tcolor rw_color_default,rw_color_body;
65  Tfilename *rw_filename;
66  Tpolyhedron rw_cbody;
67  boolean rw_endEffector;
68 
69  Tconstants rw_constants;
70 
71  boolean rw_avoidLimits;
72  double rw_avoidLimitsWeight;
73 
74  boolean rw_prevolute;
75 %}
76 
77 %union
78 {
79  char *id;
80  char *string;
81  int int_number;
82  double real_number;
83  Tcolor color;
84 }
85 
86 %start world
87 
88 %token _CONSTANTS _ASSIGN _EQUAL _NOT_EQUAL _LESS_EQUAL _GREATER_EQUAL _LESS _GREATER _PI _EXP _COS _SIN _TAN _COT _ACOS _ASIN _ATAN _ATAN2 _SQRT _ABS _PARAMETER _PRINT _LINKS _JOINTS _OBSTACLES _COLLISIONS _CHECK _NO _ALL _CONNECTED _BODY _GRANULARITY _FIX _ID _TX _TY _TZ _TXYZ _RX _RY _RZ _PRISMATIC _REVOLUTE _CREVOLUTE _SPHERICAL _UNIVERSAL _SPH_SPH _SPH_PRS_SPH _IN_PATCH _BOX _PRISM _SPHERE _CYLINDER _LINE _SEGMENTS _LENGTH _RADIUS _SELFCOLLISIONS _RANGE _COLOR _RED _GREEN _BLUE _PURPLE _CYAN _YELLOW _WHITE _BLACK _GREY _DECORATION _HIDDEN _AVOID _LIMITS _INCLUDE
89 
90 %token <id> _IDENTIFIER
91 %token <id> _EXT_IDENTIFIER
92 %token <int_number> _INTEGER
93 %token <real_number> _REAL
94 %token <string> _STRING
95 
96 %type <int_number> granularity
97 %type <int_number> shape_status
98 %type <real_number> expr
99 %type <color> color
100 %type <id> any_id
101 
102 %left _EQUAL _NOT_EQUAL _LESS_EQUAL _GREATER_EQUAL _LESS _GREATER
103 %left '+' '-'
104 %left '*' '/'
105 %left '^'
106 %right _MAX_PRECEDENCE
107 %%
108 
109 world : world def_block
110  |
111  ;
112 
113 def_block : constant_defs
114  | link_defs
115  | joint_defs
116  | obstacle_defs
117  | collision_defs
118  | included_defs
119  ;
120 
121 constant_defs: _CONSTANTS constant_list
122  ;
123 
124 constant_list : constant_definition constant_list
125  |
126  ;
127 
128 constant_definition : _IDENTIFIER _ASSIGN expr
129  {
130  if (GetConstantWithName($1,&rw_constants)!=NO_UINT)
131  {
132  char s[200];
133 
134  sprintf(s,"Duplicated constant %.100s",$1);
135  ReadWorlderror(s);
136  }
137 
138  AddConstant($1,$3,&rw_constants);
139  free($1);
140  }
141  | _PRINT _IDENTIFIER
142  {
143  unsigned int nc;
144 
145  nc=GetConstantWithName($2,&rw_constants);
146  if (nc==NO_UINT)
147  {
148  char ms[200];
149 
150  sprintf(ms,"Undefined constant: %.100s",$2);
151  ReadWorlderror(ms);
152  }
153  fprintf(stderr," %s = %.12f\n",$2,GetConstantValue(nc,&rw_constants));
154  free($2);
155  }
156  ;
157 
158 any_id : _IDENTIFIER
159  {
160  $$=$1; /* do not free $1, we will free $$ */
161  }
162  | _EXT_IDENTIFIER
163  {
164  $$=$1; /* do not free $1, we will free $$ */
165  }
166  ;
167 
168 expr : '+' expr %prec _MAX_PRECEDENCE
169  {
170  $$=$2;
171  }
172  | '-' expr %prec _MAX_PRECEDENCE
173  {
174  $$=-$2;
175  }
176  | expr '+' expr
177  {
178  $$=$1+$3;
179  }
180  | expr '-' expr
181  {
182  $$=$1-$3;
183  }
184  | expr '*' expr
185  {
186  $$=$1*$3;
187  }
188  | expr '^' expr
189  {
190  $$=pow($1,$3);
191  }
192  | expr '/' expr
193  {
194  $$=$1/$3;
195  }
196  | '(' expr ')'
197  {
198  $$=$2;
199  }
200  | '(' expr '?' expr ':' expr ')'
201  {
202  if ($2)
203  $$=$4;
204  else
205  $$=$6;
206  }
207  | expr _EQUAL expr
208  {
209  $$=($1==$3);
210  }
211  | expr _NOT_EQUAL expr
212  {
213  $$=($1!=$3);
214  }
215  | expr _LESS_EQUAL expr
216  {
217  $$=($1<=$3);
218  }
219  | expr _GREATER_EQUAL expr
220  {
221  $$=($1>=$3);
222  }
223  | expr _LESS expr
224  {
225  $$=($1<$3);
226  }
227  | expr _GREATER expr
228  {
229  $$=($1>$3);
230  }
231  | _PI
232  {
233  $$=M_PI;
234  }
235  | _SIN '(' expr ')'
236  {
237  $$=sin($3);
238  }
239  | _COS '(' expr ')'
240  {
241  $$=cos($3);
242  }
243  | _TAN '(' expr ')'
244  {
245  $$=tan($3);
246  }
247  | _COT '(' expr ')'
248  {
249  $$=tan(M_PI_2-$3);
250  }
251  | _ASIN '(' expr ')'
252  {
253  $$=asin($3);
254  }
255  | _ACOS '(' expr ')'
256  {
257  $$=acos($3);
258  }
259  | _ATAN '(' expr ')'
260  {
261  $$=atan($3);
262  }
263  | _ATAN2 '(' expr ',' expr ')'
264  {
265  $$=atan2($3,$5);
266  }
267  | _EXP '(' expr ')'
268  {
269  $$=exp($3);
270  }
271  | _SQRT '(' expr ')'
272  {
273  $$=sqrt($3);
274  }
275  | _ABS '(' expr ')'
276  {
277  $$=fabs($3);
278  }
279  | _PARAMETER '(' _IDENTIFIER ')'
280  {
281  unsigned int n;
282 
283  n=GetParameterID($3,rw_parameters);
284  if (n==NO_UINT)
285  {
286  char ms[200];
287 
288  sprintf(ms,"Undefined parameter: %.100s",$3);
289  ReadWorlderror(ms);
290  }
291  $$=GetParameter(n,rw_parameters);
292  }
293  | any_id
294  {
295  unsigned int nc;
296 
297  nc=GetConstantWithName($1,&rw_constants);
298 
299  if (nc!=NO_UINT)
300  $$=GetConstantValue(nc,&rw_constants);
301  else
302  {
303  char ms[200];
304 
305  sprintf(ms,"Undefined constant: %.100s",$1);
306  ReadWorlderror(ms);
307  }
308  free($1);
309  }
310  | _INTEGER
311  {
312  $$=(double)$1;
313  }
314  | _REAL
315  {
316  $$=$1;
317  }
318  ;
319 
320 link_defs : _LINKS link_list
321  ;
322 
323 link_list : link_definition link_list
324  |
325  ;
326 
327 link_definition: _IDENTIFIER
328  {
329  if (GetConstantWithName($1,&rw_constants)!=NO_UINT)
330  ReadWorlderror("Link with the name of a constant");
331 
332  if (GetWorldLinkID($1,rw_world)!=NO_UINT)
333  ReadWorlderror("Duplicated link");
334 
335  /*adds an empty link to the world*/
336  InitLink($1,&rw_link);
337 
338  free($1);
339  }
340  opt_link_definition
341  {
342  AddLink2World(&rw_link,rw_endEffector,rw_world);
343  DeleteLink(&rw_link);
344  }
345  ;
346 
347 
348 opt_link_definition : link_separator link_color link_shapes
349  |
350  ;
351 
352 link_separator : ':'
353  {
354  rw_endEffector=FALSE;
355  }
356  | '-'
357  {
358  rw_endEffector=TRUE;
359  }
360  ;
361 
362 link_shapes : shape
363  {
364  AddBody2Link(&rw_cbody,&rw_link);
365  DeletePolyhedron(&rw_cbody);
366  }
367  link_shapes
368  | shape
369  {
370  AddBody2Link(&rw_cbody,&rw_link);
371  DeletePolyhedron(&rw_cbody);
372  }
373  ;
374 
375 shape: _BODY _STRING body_color granularity shape_status
376  {
377  Tfilename fb;
378 
379  CreateFileName(GetFilePath(rw_filename),$2,NULL,NULL,&fb);
380 
381  InitPolyhedronFromFile(&fb,&rw_color_body,
382  $4,$5,&rw_cbody);
383 
384  DeleteFileName(&fb);
385  free($2);
386  }
387  | _BOX
388  {
389  rw_i=0;
390  rw_lID=NO_UINT;
391  }
392  point pointp body_color shape_status
393  {
394  NewBox(rw_point[0][0],rw_point[0][1],rw_point[0][2],
395  rw_point[1][0],rw_point[1][1],rw_point[1][2],
396  &rw_color_body,$6,&rw_cbody);
397  }
398  | _PRISM
399  {
400  rw_i=0;
401  }
402  point point point expr body_color shape_status
403  {
404 
405  NewTriangularPrism(rw_point[0],rw_point[1],rw_point[2],
406  $6,
407  &rw_color_body,$8,&rw_cbody);
408  }
409  | _SPHERE expr
410  {
411  rw_i=0;
412  rw_lID=NO_UINT;
413  }
414  point body_color granularity shape_status
415  {
416  NewSphere($2,rw_point[0],&rw_color_body,$6,$7,&rw_cbody);
417  }
418  | _CYLINDER expr
419  {
420  rw_i=0;
421  rw_lID=NO_UINT;
422  }
423  point pointp body_color granularity shape_status
424  {
425  NewCylinder($2,rw_point[0],rw_point[1],&rw_color_body,2*$7,$8,&rw_cbody);
426  }
427  | _LINE
428  {
429  rw_i=0;
430  rw_lID=NO_UINT;
431  }
432  point pointp body_color shape_status
433  {
434  NewLine(rw_point[0],rw_point[1],&rw_color_body,$6,&rw_cbody);
435  }
436  | _SEGMENTS
437  {
438  rw_i=0;
439  rw_max=100;
440  NEW(rw_X,rw_max,double);
441  NEW(rw_Y,rw_max,double);
442  NEW(rw_Z,rw_max,double);
443  rw_lID=NO_UINT;
444  }
445  point_list body_color
446  {
447  NewSegments(rw_i,rw_X,rw_Y,rw_Z,&rw_color_body,&rw_cbody);
448  free(rw_X);
449  free(rw_Y);
450  free(rw_Z);
451  }
452  ;
453 
454 granularity : _GRANULARITY _INTEGER
455  {
456  $$=$2;
457  }
458  |
459  {
460  $$=5;
461  }
462 
463  ;
464 
465 shape_status : _HIDDEN
466  {
467  $$=HIDDEN_SHAPE;
468  }
469  | _DECORATION
470  {
471  $$=DECOR_SHAPE;
472  }
473  |
474  {
475  $$=NORMAL_SHAPE;
476  }
477  ;
478 
479 color : _COLOR '(' expr ',' expr ',' expr ')'
480  {
481  NewColor($3,$5,$7,&($$));
482  }
483  | _RED
484  {
485  NewColorWithID(RED,&($$));
486  }
487  | _GREEN
488  {
489  NewColorWithID(GREEN,&($$));
490  }
491  | _BLUE
492  {
493  NewColorWithID(BLUE,&($$));
494  }
495  | _BLACK
496  {
497  NewColorWithID(BLACK,&($$));
498  }
499  | _GREY
500  {
501  NewColorWithID(GREY,&($$));
502  }
503  | _WHITE
504  {
505  NewColorWithID(WHITE,&($$));
506  }
507  | _YELLOW
508  {
509  NewColorWithID(YELLOW,&($$));
510  }
511  | _PURPLE
512  {
513  NewColorWithID(PURPLE,&($$));
514  }
515  | _CYAN
516  {
517  NewColorWithID(CYAN,&($$));
518  }
519  | _INTEGER '*' color
520  {
521  CopyColor(&($$),&($3));
522  ScaleColor((double)$1,&($$));
523  }
524  | _REAL '*' color
525  {
526  CopyColor(&($$),&($3));
527  ScaleColor($1,&($$));
528  }
529  | color '+' color
530  {
531  CopyColor(&($$),&($3));
532  AccumulateColor(&($1),&($$));
533  }
534  ;
535 
536 link_color: color
537  {
538  CopyColor(&rw_color_default,&($1));
539  }
540  |
541  {
542  NewColor(DLC_R,DLC_G,DLC_B,&rw_color_default);
543  }
544  ;
545 
546 body_color: color
547  {
548  CopyColor(&rw_color_body,&($1));
549  }
550  |
551  {
552  CopyColor(&rw_color_body,&rw_color_default);
553  }
554  ;
555 
556 joint_defs : _JOINTS joint_list
557  ;
558 
559 joint_list : joint_definition joint_list
560  |
561  ;
562 
563 joint_definition: fix_joint
564  | prismatic_joint
565  | revolute_joint
566  | crevolute_joint
567  | spherical_joint
568  | universal_joint
569  | sph_sph_joint
570  | sph_prs_sph_joint
571  | in_patch_joint
572  ;
573 
574 fix_joint : _FIX ':' any_id any_id
575  {
576  HTransformIdentity(&rw_transform);
577  }
578  transforms
579  {
580  unsigned int id1,id2;
581 
582  id1=GetWorldLinkID($3,rw_world);
583  if (id1==NO_UINT)
584  ReadWorlderror("Unkown link (1st id) when defining a fix joint");
585 
586  id2=GetWorldLinkID($4,rw_world);
587  if (id2==NO_UINT)
588  ReadWorlderror("Unkown link (2st id) when allowing a fix joint");
589 
590  NewFixJoint(GetWorldNJoints(rw_world),
591  id1,GetWorldLink(id1,rw_world),
592  id2,GetWorldLink(id2,rw_world),
593  &rw_transform,&rw_joint);
594 
595  AddJoint2World(&rw_joint,rw_world);
596 
597  DeleteJoint(&rw_joint);
598  free($3);
599  free($4);
600 
601  HTransformDelete(&rw_transform);
602 
603  rw_prevolute=FALSE;
604  }
605  ;
606 
607 transforms: transform '*' transforms
608  | transform
609  ;
610 
611 transform : _ID
612  {
613  /* Nothing need to be done */
614  }
615  |
616  _TX '(' expr ')'
617  {
618  THTransform t;
619 
620  HTransformTx($3,&t);
621 
622  HTransformProduct(&rw_transform,&t,&rw_transform);
623  }
624  | _TY '(' expr ')'
625  {
626  THTransform t;
627 
628  HTransformTy($3,&t);
629 
630  HTransformProduct(&rw_transform,&t,&rw_transform);
631  }
632  | _TZ '(' expr ')'
633  {
634  THTransform t;
635 
636  HTransformTz($3,&t);
637 
638  HTransformProduct(&rw_transform,&t,&rw_transform);
639  }
640  | _TXYZ '(' expr ',' expr ',' expr')'
641  {
642  THTransform t;
643 
644  HTransformTxyz($3,$5,$7,&t);
645 
646  HTransformProduct(&rw_transform,&t,&rw_transform);
647  }
648  | _RX '(' expr ')'
649  {
650  THTransform t;
651 
652  HTransformRx($3,&t);
653 
654  HTransformProduct(&rw_transform,&t,&rw_transform);
655  }
656  | _RY '(' expr ')'
657  {
658  THTransform t;
659 
660  HTransformRy($3,&t);
661 
662  HTransformProduct(&rw_transform,&t,&rw_transform);
663  }
664  | _RZ '(' expr ')'
665  {
666  THTransform t;
667 
668  HTransformRz($3,&t);
669 
670  HTransformProduct(&rw_transform,&t,&rw_transform);
671  }
672  ;
673 
674 prismatic_joint: _PRISMATIC ':'
675  any_id
676  {
677  rw_lID1=rw_lID=GetWorldLinkID($3,rw_world);
678  if (rw_lID1==NO_UINT)
679  ReadWorlderror("Unkown link (1st id) when defining a prismatic joint");
680 
681  rw_i=0;
682  }
683  point pointp
684  any_id
685  {
686  rw_lID2=rw_lID=GetWorldLinkID($7,rw_world);
687  if (rw_lID2==NO_UINT)
688  ReadWorlderror("Unkown link (2st id) when allowing a prismatic joint");
689  }
690  point pointp
691  _RANGE range
692  avoid_limits
693  {
695  rw_lID1,GetWorldLink(rw_lID1,rw_world),
696  rw_lID2,GetWorldLink(rw_lID2,rw_world),
697  rw_point,&rw_range,
698  rw_avoidLimits,rw_avoidLimitsWeight,
699  &rw_joint);
700 
701  AddJoint2World(&rw_joint,rw_world);
702 
703  DeleteJoint(&rw_joint);
704  free($3);
705  free($7);
706 
707  rw_prevolute=FALSE;
708  }
709  ;
710 
711 point : '(' expr ',' expr ',' expr ')'
712  {
713  rw_point[rw_i][0]=$2;
714  rw_point[rw_i][1]=$4;
715  rw_point[rw_i][2]=$6;
716  rw_i++;
717  }
718  | _INTEGER
719  {
720  Tpolyhedron *b;
721 
722  if (rw_lID==NO_UINT)
723  ReadWorlderror("Reference to body points can only be used inside joint definition");
724  b=GetLinkBody(0,GetWorldLink(rw_lID,rw_world));
725  GetPolyhedronDefiningPoint($1,rw_point[rw_i],b);
726  rw_i++;
727  }
728  | _INTEGER ':' _INTEGER
729  {
730  Tpolyhedron *b;
731 
732  if (rw_lID==NO_UINT)
733  ReadWorlderror("Reference to body points can only be used inside joint definition");
734  b=GetLinkBody($1,GetWorldLink(rw_lID,rw_world));
735  GetPolyhedronDefiningPoint($3,rw_point[rw_i],b);
736  rw_i++;
737  }
738  ;
739 
740 pointp : point
741  | '+''(' expr ',' expr ',' expr ')'
742  {
743  if (rw_i==0)
744  Error("Incremental vector in a wrong position??");
745 
746  rw_point[rw_i][0]=rw_point[rw_i-1][0]+$3;
747  rw_point[rw_i][1]=rw_point[rw_i-1][1]+$5;
748  rw_point[rw_i][2]=rw_point[rw_i-1][2]+$7;
749  rw_i++;
750  }
751  ;
752 
753 point_list : '(' coordinates3D ')'
754  ;
755 
756 coordinates3D : xyz ';' coordinates3D
757  | xyz
758  ;
759 
760 xyz : expr ',' expr ',' expr
761  {
762  if (rw_i==rw_max)
763  {
764  MEM_DUP(rw_X,rw_max,double);
765  MEM_EXPAND(rw_Y,rw_max,double);
766  MEM_EXPAND(rw_Z,rw_max,double);
767  }
768  rw_X[rw_i]=$1;
769  rw_Y[rw_i]=$3;
770  rw_Z[rw_i]=$5;
771  rw_i++;
772  }
773 
774 
775 range : '[' expr ',' expr ']'
776  {
777  NewInterval($2,$4,&rw_range);
778  if (EmptyInterval(&rw_range))
779  ReadWorlderror("Empty range");
780  }
781  ;
782 
783 revolute_joint: _REVOLUTE ':'
784  any_id
785  {
786  rw_lID1=rw_lID=GetWorldLinkID($3,rw_world);
787  if (rw_lID1==NO_UINT)
788  ReadWorlderror("Unkown link (1st id) when defining a revolute joint");
789 
790  rw_i=0;
791  }
792  point pointp
793  any_id
794  {
795  rw_lID2=rw_lID=GetWorldLinkID($7,rw_world);
796  if (rw_lID2==NO_UINT)
797  ReadWorlderror("Unkown link (2st id) when allowing a revolute joint");
798  }
799  point pointp
800  opt_revolute_range
801  {
802  NewRevoluteJoint(GetWorldNJoints(rw_world),rw_r,
803  rw_lID1,GetWorldLink(rw_lID1,rw_world),
804  rw_lID2,GetWorldLink(rw_lID2,rw_world),
805  rw_point,
806  rw_has_limits,&rw_range,rw_range_point,
807  rw_avoidLimits,rw_avoidLimitsWeight,NULL,
808  &rw_joint);
809 
810  AddJoint2World(&rw_joint,rw_world);
811 
812  DeleteJoint(&rw_joint);
813  free($3);
814  free($7);
815 
816  rw_prevolute=TRUE;
817  }
818  ;
819 
820 crevolute_joint: _CREVOLUTE ':'
821  any_id
822  {
823  rw_lID1=rw_lID=GetWorldLinkID($3,rw_world);
824  if (rw_lID1==NO_UINT)
825  ReadWorlderror("Unkown link (1st id) when defining a revolute joint");
826 
827  rw_i=0;
828  }
829  point pointp
830  any_id
831  {
832  rw_lID2=rw_lID=GetWorldLinkID($7,rw_world);
833  if (rw_lID2==NO_UINT)
834  ReadWorlderror("Unkown link (2st id) when allowing a revolute joint");
835  }
836  point pointp
837  opt_revolute_range
838  {
839  unsigned int id,k;
840  Tjoint *jp;
841 
842  id=GetWorldNJoints(rw_world);
843 
844  if ((!rw_prevolute)||(id<1))
845  ReadWorlderror("Coupled revolute joints need a previous revolute joint");
846 
847  id=GetWorldNJoints(rw_world);
848  k=id;
849  /* take into account that we can have a chain of coupled joints: determine the
850  original non-coupled joints (only revolute joints can be coupled) */
851  do {
852  k--;
853  jp=GetWorldJoint(k,rw_world);
854  } while ((k>0)&&(GetJointType(jp)==REV_JOINT)&&(CoupledWith(jp)!=NO_UINT));
855  if ((GetJointType(jp)!=REV_JOINT)||(CoupledWith(jp)!=NO_UINT))
856  Error("Error defining a chain of coupled revolute joints");
857 
858  NewRevoluteJoint(id,rw_r,
859  rw_lID1,GetWorldLink(rw_lID1,rw_world),
860  rw_lID2,GetWorldLink(rw_lID2,rw_world),
861  rw_point,
862  rw_has_limits,&rw_range,rw_range_point,
863  rw_avoidLimits,rw_avoidLimitsWeight,jp,
864  &rw_joint);
865 
866  AddJoint2World(&rw_joint,rw_world);
867 
868  DeleteJoint(&rw_joint);
869  free($3);
870  free($7);
871 
872  rw_prevolute=TRUE;
873  }
874  ;
875 
876 spherical_joint : _SPHERICAL ':'
877  any_id
878  {
879  rw_lID1=rw_lID=GetWorldLinkID($3,rw_world);
880  if (rw_lID1==NO_UINT)
881  ReadWorlderror("Unkown link (1st id) when defining a spherical joint");
882 
883  rw_i=0;
884  }
885  point
886  any_id
887  {
888  rw_lID2=rw_lID=GetWorldLinkID($6,rw_world);
889  if (rw_lID2==NO_UINT)
890  ReadWorlderror("Unkown link (2st id) when allowing a spherical joint");
891  /* skip rw_i==1 (the opt_spherical_range is defined over rw_point[0] and rw_point[2])
892  This is implemented in this way for compatibility with the range definiton of the
893  revolute joint which uses 2 points on each link and not just one. */
894  rw_i++;
895  }
896  point
897  opt_spherical_range
898  {
899  unsigned int i;
900  /* move point[2] to point[1] since NewSphericalJoint only uses two points */
901  for(i=0;i<3;i++)
902  rw_point[1][i]=rw_point[2][i];
904  rw_lID1,GetWorldLink(rw_lID1,rw_world),
905  rw_lID2,GetWorldLink(rw_lID2,rw_world),
906  rw_point,
907  rw_has_limits,rw_angle,rw_range_point,
908  rw_avoidLimits,rw_avoidLimitsWeight,
909  &rw_joint);
910 
911  AddJoint2World(&rw_joint,rw_world);
912 
913  DeleteJoint(&rw_joint);
914  free($3);
915  free($6);
916 
917  rw_prevolute=FALSE;
918  }
919  ;
920 
921 universal_joint : _UNIVERSAL ':'
922  any_id
923  {
924  rw_lID1=rw_lID=GetWorldLinkID($3,rw_world);
925  if (rw_lID1==NO_UINT)
926  ReadWorlderror("Unkown link (1st id) when defining a universal joint");
927 
928  rw_i=0;
929  }
930  point pointp
931  any_id
932  {
933  rw_lID2=rw_lID=GetWorldLinkID($7,rw_world);
934 
935  if (rw_lID2==NO_UINT)
936  ReadWorlderror("Unkown link (2nd id) when defining a universal joint");
937  }
938  point pointp
939  opt_universal_range
940  {
941  NewUniversalJoint(GetWorldNJoints(rw_world),rw_r,
942  rw_lID1,GetWorldLink(rw_lID1,rw_world),
943  rw_lID2,GetWorldLink(rw_lID2,rw_world),
944  rw_point,
945  rw_has_limits,&rw_range0,&rw_range,rw_range_point,
946  rw_avoidLimits,rw_avoidLimitsWeight,
947  &rw_joint);
948 
949  AddJoint2World(&rw_joint,rw_world);
950 
951  DeleteJoint(&rw_joint);
952  free($3);
953  free($7);
954 
955  rw_prevolute=FALSE;
956  }
957  ;
958 
959 sph_sph_joint: _SPH_SPH _IDENTIFIER ':'
960  any_id
961  {
962  rw_lID1=rw_lID=GetWorldLinkID($4,rw_world);
963  if (rw_lID1==NO_UINT)
964  ReadWorlderror("Unkown link (1st id) when defining a spherical-spherical joint");
965 
966  rw_i=0;
967  }
968  point
969  any_id
970  {
971  rw_lID2=rw_lID=GetWorldLinkID($7,rw_world);
972  if (rw_lID2==NO_UINT)
973  ReadWorlderror("Unkown link (2st id) when defining a spherical-spherical joint");
974  }
975  point
976  _LENGTH expr
977  _RADIUS expr
978  granularity link_color shape_status
979  {
980  Tinterval zero,length;
981 
982  NewInterval($11,$11,&length);
983  NewInterval(0.0,0.0,&zero);
984 
985  AddLeg2World($2, /* link name */
986  FALSE, /* non-planar */
987  LEG, /* a normal leg */
988  rw_lID1,rw_lID2, /* connected links */
989  rw_point, /* connection points on links */
990  &length, /* length */
991  0.0, /* stiffness */
992  &zero, /* rest */
993  &zero, /* force range */
994  $13, /* radius */
995  $14, /* granularity */
996  &rw_color_default,/* color */
997  $16, /* shape_status */
998  rw_world);
999 
1000  DeleteInterval(&length);
1001  DeleteInterval(&zero);
1002  if ($2!=NULL)
1003  free($2);
1004  free($4);
1005  free($7);
1006 
1007  rw_prevolute=FALSE;
1008  }
1009  ;
1010 
1011 sph_prs_sph_joint: _SPH_PRS_SPH _IDENTIFIER ':'
1012  any_id
1013  {
1014  rw_lID1=rw_lID=GetWorldLinkID($4,rw_world);
1015  if (rw_lID1==NO_UINT)
1016  ReadWorlderror("Unkown link (1st id) when defining a spherical-spherical joint");
1017 
1018  rw_i=0;
1019  }
1020  point
1021  any_id
1022  {
1023  rw_lID2=rw_lID=GetWorldLinkID($7,rw_world);
1024  if (rw_lID2==NO_UINT)
1025  ReadWorlderror("Unkown link (2st id) when defining a spherical-spherical joint");
1026  }
1027  point
1028  _RANGE range
1029  _RADIUS expr
1030  granularity link_color shape_status
1031  {
1032  Tinterval zero;
1033 
1034  NewInterval(0.0,0.0,&zero);
1035 
1036  AddLeg2World($2, /* link name */
1037  FALSE, /* non-planar */
1038  PRISMATIC_LEG, /* a prismatic leg */
1039  rw_lID1,rw_lID2, /* connected links */
1040  rw_point, /* connection points on links */
1041  &rw_range, /* length */
1042  0.0, /* stiffness */
1043  &zero, /* rest */
1044  &zero, /* force range */
1045  $13, /* radius */
1046  $14, /* granularity */
1047  &rw_color_default, /* color */
1048  $16, /* shape_status */
1049  rw_world);
1050 
1051  DeleteInterval(&zero);
1052  if ($2!=NULL)
1053  free($2);
1054  free($4);
1055  free($7);
1056 
1057  rw_prevolute=FALSE;
1058  }
1059  ;
1060 
1061 in_patch_joint : _IN_PATCH ':'
1062  any_id
1063  {
1064  rw_lID1=rw_lID=GetWorldLinkID($3,rw_world);
1065  if (rw_lID1==NO_UINT)
1066  ReadWorlderror("Unkown link (1st id) when defining a in_patch joint");
1067 
1068  rw_i=0;
1069  }
1070  point pointp
1071  {
1072  /*save the points in a different location*/
1073  unsigned int i,j;
1074 
1075  for(i=0;i<2;i++)
1076  {
1077  for(j=0;j<3;j++)
1078  rw_in_patch_point[i][j]=rw_point[i][j];
1079  }
1080 
1081  rw_i=0;
1082  }
1083  any_id
1084  {
1085  rw_lID2=rw_lID=GetWorldLinkID($8,rw_world);
1086  if (rw_lID2==NO_UINT)
1087  ReadWorlderror("Unkown link (2st id) when defining a in_patch joint");
1088  }
1089  point point point point
1090  avoid_limits
1091  {
1092  NewInPatchJoint(GetWorldNJoints(rw_world),
1093  rw_lID1,GetWorldLink(rw_lID1,rw_world),
1094  rw_lID2,GetWorldLink(rw_lID2,rw_world),
1095  rw_in_patch_point,rw_point,
1096  rw_avoidLimits,rw_avoidLimitsWeight,
1097  &rw_joint);
1098 
1099  AddJoint2World(&rw_joint,rw_world);
1100 
1101  DeleteJoint(&rw_joint);
1102  free($3);
1103  free($8);
1104 
1105  rw_prevolute=FALSE;
1106  }
1107  ;
1108 
1109 rpointp : '(' expr ',' expr ',' expr ')'
1110  {
1111  rw_range_point[rw_i][0]=$2;
1112  rw_range_point[rw_i][1]=$4;
1113  rw_range_point[rw_i][2]=$6;
1114  rw_i++;
1115  }
1116  | '+' '(' expr ',' expr ',' expr ')'
1117  {
1118  rw_range_point[rw_i][0]=rw_point[2*rw_i][0]+$3;
1119  rw_range_point[rw_i][1]=rw_point[2*rw_i][1]+$5;
1120  rw_range_point[rw_i][2]=rw_point[2*rw_i][2]+$7;
1121  rw_i++;
1122  }
1123  ;
1124 
1125 opt_revolute_range: _RANGE
1126  {
1127  rw_i=0;
1128  rw_has_limits=TRUE;
1129  }
1130  range
1131  rpointp rpointp
1132  avoid_limits
1133  |
1134  {
1135  rw_has_limits=FALSE;
1136  }
1137  ;
1138 
1139 opt_spherical_range : _RANGE
1140  {
1141  rw_i=0;
1142  rw_has_limits=TRUE;
1143  }
1144  '[' expr ']'
1145  {
1146  rw_angle=$4;
1147  }
1148  rpointp rpointp
1149  avoid_limits
1150  |
1151  {
1152  rw_has_limits=FALSE;
1153  }
1154  ;
1155 
1156 opt_universal_range : _RANGE
1157  {
1158  rw_i=0;
1159  rw_has_limits=TRUE;
1160  }
1161  range
1162  {
1163  CopyInterval(&rw_range0,&rw_range);
1164  }
1165  rpointp
1166  range rpointp
1167  avoid_limits
1168  |
1169  {
1170  rw_has_limits=FALSE;
1171  }
1172  ;
1173 
1174 obstacle_defs : _OBSTACLES obstacle_list
1175  ;
1176 
1177 obstacle_list : obstacle_definition obstacle_list
1178  |
1179  ;
1180 
1181 obstacle_definition: _IDENTIFIER ':' shape
1182  {
1183  if (GetConstantWithName($1,&rw_constants)!=NO_UINT)
1184  ReadWorlderror("Obstacle with the name of a constant");
1185 
1186  if (GetWorldLinkID($1,rw_world)!=NO_UINT)
1187  ReadWorlderror("Obstacle with the name of a link");
1188 
1189  if (GetWorldObstacleID($1,rw_world)!=NO_UINT)
1190  ReadWorlderror("Duplicated obstacle");
1191 
1192  AddObstacle2World($1,&rw_cbody,rw_world);
1193 
1194  DeletePolyhedron(&rw_cbody);
1195 
1196  free($1);
1197  }
1198 
1199 collision_defs : _COLLISIONS collision_list
1200  ;
1201 
1202 collision_list : collision_definition collision_list
1203  |
1204  ;
1205 
1206 collision_definition: _CHECK ':' _ALL
1207  {
1208  CheckAllCollisions(firstLink,firstObject,rw_world);
1209  }
1210  | _NO _CHECK ':' _ALL
1211  {
1212  NoCheckAllCollisions(firstLink,firstObject,rw_world);
1213  }
1214  | _CHECK ':' _SELFCOLLISIONS
1215  {
1216  CheckSelfCollisions(firstLink,rw_world);
1217  }
1218  | _NO _CHECK ':' _SELFCOLLISIONS
1219  {
1220  NoCheckSelfCollisions(firstLink,rw_world);
1221  }
1222  | _NO _CHECK ':' _CONNECTED
1223  {
1224  NoCheckConnectedCollisions(firstLink,rw_world);
1225  }
1226  | _CHECK ':' any_id
1227  {
1228  unsigned int id;
1229 
1230  id=GetWorldObstacleID($3,rw_world);
1231  if (id==NO_UINT)
1232  ReadWorlderror("Unkown obstacle when activating a collision check");
1233 
1234  CheckObstacleCollision(firstLink,id,rw_world);
1235 
1236  free($3);
1237  }
1238  | _NO _CHECK ':' any_id
1239  {
1240  unsigned int id;
1241 
1242  id=GetWorldObstacleID($4,rw_world);
1243  if (id==NO_UINT)
1244  ReadWorlderror("Unkown obstacle when disabling a collision check");
1245 
1246  NoCheckObstacleCollision(firstLink,id,rw_world);
1247 
1248  free($4);
1249  }
1250  | _CHECK ':' any_id ',' any_id
1251  {
1252  unsigned int id1,id2;
1253 
1254  id1=GetWorldLinkID($3,rw_world);
1255  if (id1==NO_UINT)
1256  ReadWorlderror("Unkown link (1st id) when activating a collision check");
1257 
1258  id2=GetWorldLinkID($5,rw_world);
1259  if (id2==NO_UINT)
1260  {
1261  id2=GetWorldObstacleID($5,rw_world);
1262  if (id2==NO_UINT)
1263  ReadWorlderror("Unkown link/obstacle (2st id) when activating a collision check");
1264 
1265  CheckLinkObstacleCollision(id1,id2,rw_world);
1266  }
1267  else
1268  CheckLinkLinkCollision(id1,id2,rw_world);
1269 
1270  free($3);
1271  free($5);
1272  }
1273  | _NO _CHECK ':' any_id ',' any_id
1274  {
1275  unsigned int id1,id2;
1276 
1277  id1=GetWorldLinkID($4,rw_world);
1278  if (id1==NO_UINT)
1279  ReadWorlderror("Unkown link (1st id) when disabling a collision check");
1280 
1281  id2=GetWorldLinkID($6,rw_world);
1282  if (id2==NO_UINT)
1283  {
1284  id2=GetWorldObstacleID($6,rw_world);
1285  if (id2==NO_UINT)
1286  ReadWorlderror("Unkown link/obstacle (2st id) when disabling a collision check");
1287 
1288  NoCheckLinkObstacleCollision(id1,id2,rw_world);
1289  }
1290  else
1291  NoCheckLinkLinkCollision(id1,id2,rw_world);
1292 
1293  free($4);
1294  free($6);
1295  }
1296  ;
1297 
1298 avoid_limits : _AVOID _LIMITS opt_weight
1299  {
1300  rw_avoidLimits=TRUE;
1301 
1302  }
1303  |
1304  {
1305  rw_avoidLimits=FALSE;
1306  }
1307  ;
1308 
1309 opt_weight : expr
1310  {
1311  rw_avoidLimitsWeight=$1;
1312  }
1313  |
1314  {
1315  rw_avoidLimitsWeight=1.0;
1316  }
1317  ;
1318 
1319 
1320 included_defs : _INCLUDE include_list
1321  ;
1322 
1323 include_list : include_file include_list
1324  |
1325  ;
1326 
1327 include_file : _IDENTIFIER ':' _STRING
1328  {
1329  Switch2File($1,rw_world->nl,rw_world->no,GetFilePath(rw_filename),$3);
1330  free($1);
1331  free($3);
1332  }
1333  ;
1334 
1335 %%
1338 /*
1339  *
1340  */
1341 boolean InitWorldFromFile(Tparameters *p,boolean error,char *fn,Tworld *w)
1342 {
1343  boolean ok;
1344 
1345  /* First we try to */
1346  if (InitTensegrityFromFile(p,fn,w))
1347  ok=TRUE;
1348  else
1349  {
1350  unsigned int i;
1351  Tfilename fworld;
1352 
1353  CreateFileName(NULL,fn,NULL,WORLD_EXT,&fworld);
1354 
1355  ReadWorldin=fopen(GetFileFullName(&fworld),"r");
1356 
1357  if (!ReadWorldin)
1358  {
1359  if (error)
1360  {
1361  char m[500];
1362 
1363  sprintf(m,"%.490s could not be read",GetFileFullName(&fworld));
1364  Error(m);
1365  }
1366  ok=FALSE;
1367  }
1368  else
1369  {
1370  fprintf(stderr,"Reading world from : %s\n",GetFileFullName(&fworld));
1371 
1372  NEW(rw_point,4,double*);
1373  for(i=0;i<4;i++)
1374  NEW(rw_point[i],3,double);
1375 
1376  NEW(rw_range_point,4,double*);
1377  for(i=0;i<4;i++)
1378  NEW(rw_range_point[i],3,double);
1379 
1380  NEW(rw_in_patch_point,2,double*);
1381  for(i=0;i<2;i++)
1382  NEW(rw_in_patch_point[i],3,double);
1383 
1384  rw_r=(unsigned int)(GetParameter(CT_REPRESENTATION,p));
1385 
1386  InitWorld(w); /*Generate an empty world*/
1387 
1388  InitConstants(&rw_constants); /*An empty set of constants*/
1389 
1390  /* Indicates whether the previous joint was revolute */
1391  rw_prevolute=FALSE;
1392 
1393  /*Reset the lines numbering*/
1394  RWline=1;
1395  firstLink=0;
1396  firstObject=0;
1397 
1398  /*we initalize the global pointer to make the parameters accesibles to any one inside the YACC module*/
1399  rw_world=w;
1400  rw_filename=&fworld;
1401  rw_parameters=p;
1402 
1403  /*and process the file*/
1404  ReadWorldparse();
1405 
1406  DeleteConstants(&rw_constants);
1407 
1409 
1410  for(i=0;i<4;i++)
1411  free(rw_point[i]);
1412  free(rw_point);
1413 
1414  for(i=0;i<4;i++)
1415  free(rw_range_point[i]);
1416  free(rw_range_point);
1417 
1418  for(i=0;i<2;i++)
1419  free(rw_in_patch_point[i]);
1420  free(rw_in_patch_point);
1421 
1422  fclose(ReadWorldin);
1423  ok=TRUE;
1424  }
1425 
1426  DeleteFileName(&fworld);
1427  }
1428  return(ok);
1429 }
1430 
Definition of the boolean type.
unsigned int RWline
Number of the line currently parsed when reading a .world file.
Definition: error_world.c:45
#define PURPLE
Purple.
Definition: color.h:72
void InitConstants(Tconstants *cts)
Initializes a constant set.
Definition: constants.c:21
void NewSegments(unsigned int n, double *x, double *y, double *z, Tcolor *c, Tpolyhedron *p)
Constructor.
Definition: polyhedron.c:1098
#define FALSE
FALSE.
Definition: boolean.h:30
void HTransformTxyz(double tx, double ty, double tz, THTransform *t)
Constructor.
Definition: htransform.c:146
double GetConstantValue(unsigned int n, Tconstants *cts)
Retrives a the value of a constant.
Definition: constants.c:113
void HTransformRx(double rx, THTransform *t)
Constructor.
Definition: htransform.c:161
Relation between two links.
Definition: joint.h:168
#define BLUE
Blue.
Definition: color.h:37
A table of constants.
Definition: constants.h:53
#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:271
void HTransformTz(double tz, THTransform *t)
Constructor.
Definition: htransform.c:134
A homgeneous transform in R^3.
Definition of a table of Tconstants.
void NoCheckConnectedCollisions(unsigned int fl, Tworld *w)
Desactivates the collision detection between connected links.
Definition: world.c:2225
void NewTriangularPrism(double *p1, double *p2, double *p3, double h, Tcolor *c, unsigned int bs, Tpolyhedron *p)
Constructor.
Definition: polyhedron.c:861
#define NORMAL_SHAPE
One of the possible type of shapes.
Definition: polyhedron.h:28
unsigned int CoupledWith(Tjoint *j)
Returns the identifier of the joint coupled with the query joint.
Definition: joint.c:1285
#define TRUE
TRUE.
Definition: boolean.h:21
void NewSphere(double r, double *center, Tcolor *c, unsigned int gr, unsigned int bs, Tpolyhedron *p)
Constructor.
Definition: polyhedron.c:1020
char * GetFilePath(Tfilename *fn)
Gets the file path.
Definition: filename.c:156
void Error(const char *s)
General error function.
Definition: error.c:80
void NoCheckLinkObstacleCollision(unsigned int a, unsigned int b, Tworld *w)
Desactivates the possible collision between a particular link and an object in the environment...
Definition: world.c:2200
All the necessary information to generate equations for mechanisms.
Definition: world.h:229
void CopyColor(Tcolor *c_dst, Tcolor *c_src)
Copy constructor.
Definition: color.c:57
A color.
Definition: color.h:86
void NewBox(double xl, double yl, double zl, double xu, double yu, double zu, Tcolor *c, unsigned int bs, Tpolyhedron *p)
Constructor.
Definition: polyhedron.c:946
void CheckObstacleCollision(unsigned int fl, unsigned int b, Tworld *w)
Activates the possible collision between a particular obstacle and all the links. ...
Definition: world.c:2209
void NoCheckAllCollisions(unsigned int fl, unsigned int fo, Tworld *w)
Desactivates all the possible collision between links and links and obstacles.
Definition: world.c:2119
CBLAS_INLINE void HTransformProduct(THTransform *t1, THTransform *t2, THTransform *t3)
Product of two homogeneous transforms.
Definition: htransform.c:410
void CopyInterval(Tinterval *i_dst, Tinterval *i_org)
Copy constructor.
Definition: interval.c:59
#define WHITE
White.
Definition: color.h:58
void NoCheckObstacleCollision(unsigned int fl, unsigned int b, Tworld *w)
Deactivates the possible collision between a particular obstacle and all the links.
Definition: world.c:2217
Definition of the Tworld type and the associated functions.
A polyhedron.
Definition: polyhedron.h:134
Error and warning functions.
void DeleteFileName(Tfilename *fn)
Destructor.
Definition: filename.c:205
#define BLACK
Black.
Definition: color.h:44
void CheckAllCollisions(unsigned int fl, unsigned int fo, Tworld *w)
Activates all the possible collision between links and links and obstacles.
Definition: world.c:2097
void AddLeg2World(char *name, boolean planar, unsigned int type, unsigned int lID1, unsigned int lID2, double **points, Tinterval *length, double stiffness, Tinterval *rest, Tinterval *force, double radius, unsigned int gr, Tcolor *color, unsigned int bs, Tworld *w)
Adds a sph-sph joint to the world.
Definition: world.c:1446
void HTransformRz(double rz, THTransform *t)
Constructor.
Definition: htransform.c:195
unsigned int GetWorldObstacleID(char *obsName, Tworld *w)
Gets the identifier of an obstacle from its name.
Definition: world.c:1837
void GenerateWorldEquations(Tparameters *p, Tworld *w)
Generates all the cuiksystems derived from the world information.
Definition: world.c:2431
void CheckSelfCollisions(unsigned int fl, Tworld *w)
Activates all the possible collision between links.
Definition: world.c:2138
#define LEG
One of the possible types of legs.
Definition: world.h:115
void AddObstacle2World(char *name, Tpolyhedron *o, Tworld *w)
Adds an obstacle to the environment in the world.
Definition: world.c:1788
unsigned int AddLink2World(Tlink *l, boolean object, Tworld *w)
Adds a link to the mechanism in the world.
Definition: world.c:1383
Definitions of constants and macros used in several parts of the cuik library.
#define M_PI_2
Pi/2.
Definition: defines.h:92
void NewRevoluteJoint(unsigned int id, unsigned int r, unsigned int linkID1, Tlink *link1, unsigned int linkID2, Tlink *link2, double **points, boolean hasLimits, Tinterval *range, double **rPoints, boolean avoidLimits, double avoidLimitsWeight, Tjoint *coupled, Tjoint *j)
Constructor.
Definition: joint.c:124
void NewUniversalJoint(unsigned int id, unsigned int r, unsigned int linkID1, Tlink *link1, unsigned int linkID2, Tlink *link2, double **points, boolean hasLimits, Tinterval *range1, Tinterval *range2, double **rPoints, boolean avoidLimits, double avoidLimitsWeight, Tjoint *j)
Constructor.
Definition: joint.c:280
void ScaleColor(double s, Tcolor *c)
Scales a color.
Definition: color.c:76
void NewInPatchJoint(unsigned int id, unsigned int linkID1, Tlink *link1, unsigned int linkID2, Tlink *link2, double **points, double **patch, boolean avoidLimits, double avoidLimitsWeight, Tjoint *j)
Constructor.
Definition: joint.c:715
void DeleteInterval(Tinterval *i)
Destructor.
Definition: interval.c:1021
#define YELLOW
Yellow.
Definition: color.h:65
#define GREEN
Green.
Definition: color.h:30
unsigned int GetJointType(Tjoint *j)
Gets the joint type.
Definition: joint.c:931
A table of parameters.
void CreateFileName(char *path, char *name, char *suffix, char *ext, Tfilename *fn)
Constructor.
Definition: filename.c:22
#define GREY
Grey.
Definition: color.h:51
void NewCylinder(double r, double *p1, double *p2, Tcolor *c, unsigned int gr, unsigned int bs, Tpolyhedron *p)
Constructor.
Definition: polyhedron.c:1044
Definition of the THTransform type and the associated functions.
unsigned int AddJoint2World(Tjoint *j, Tworld *w)
Adds a joint to the mechanism in the world.
Definition: world.c:1436
unsigned int AddConstant(char *name, double v, Tconstants *cts)
Add a constant.
Definition: constants.c:65
void InitPolyhedronFromFile(Tfilename *fname, Tcolor *c, unsigned int gr, unsigned int bs, Tpolyhedron *p)
Constructor.
Definition: polyhedron.c:727
void NewFixJoint(unsigned int id, unsigned int linkID1, Tlink *link1, unsigned int linkID2, Tlink *link2, THTransform *t, Tjoint *j)
Constructor.
Definition: joint.c:102
boolean InitTensegrityFromFile(Tparameters *p, char *fn, Tworld *w)
Constructor.
char * GetFileFullName(Tfilename *fn)
Gets the file full name (paht+name+extension).
Definition: filename.c:151
#define PRISMATIC_LEG
One of the possible types of legs.
Definition: world.h:126
#define M_PI
Pi.
Definition: defines.h:83
#define CT_REPRESENTATION
Representation.
Definition: parameters.h:215
void CheckLinkLinkCollision(unsigned int a, unsigned int b, Tworld *w)
Activates the possible collision between a particular pair of links.
Definition: world.c:2167
#define REV_JOINT
One of the possible type of joints.
Definition: joint.h:59
boolean InitWorldFromFile(Tparameters *p, boolean error, char *fn, Tworld *w)
Constructor.
#define WORLD_EXT
File extension for problem files.
Definition: filename.h:162
#define MEM_DUP(_var, _n, _type)
Duplicates a previously allocated memory space.
Definition: defines.h:414
Definition of the Tcolor type and the associated functions.
#define NO_UINT
Used to denote an identifier that has not been initialized.
Definition: defines.h:435
unsigned int GetWorldLinkID(char *linkName, Tworld *w)
Gets the identifier of a link from its name.
Definition: world.c:1832
void HTransformTx(double tx, THTransform *t)
Constructor.
Definition: htransform.c:112
#define CYAN
Cyan.
Definition: color.h:79
Definition of the Tvector type and the associated functions.
boolean EmptyInterval(Tinterval *i)
Checks if a given interval is empty.
Definition: interval.c:335
Tlink * GetWorldLink(unsigned int linkID, Tworld *w)
Gets a link from its identifier.
Definition: world.c:1842
void NoCheckLinkLinkCollision(unsigned int a, unsigned int b, Tworld *w)
Desactivates the possible collision between a particular pair of links.
Definition: world.c:2179
Tjoint * GetWorldJoint(unsigned int jointID, Tworld *w)
Gets a joint from its identifier.
Definition: world.c:1847
unsigned int GetWorldNJoints(Tworld *w)
Gets the number of joints in the mechanism included in the world.
Definition: world.c:1857
void HTransformDelete(THTransform *t)
Destructor.
Definition: htransform.c:887
unsigned int GetConstantWithName(char *name, Tconstants *cts)
Retrives a constant from the set.
Definition: constants.c:88
#define MEM_EXPAND(_var, _n, _type)
Expands a previously allocated memory space.
Definition: defines.h:404
void GetPolyhedronDefiningPoint(unsigned int i, double *point, Tpolyhedron *p)
Gets a point defining a a object.
Definition: polyhedron.c:1398
double GetParameter(unsigned int n, Tparameters *p)
Gets the value for a particular parameter.
Definition: parameters.c:93
void InitWorld(Tworld *w)
Constructor.
Definition: world.c:1358
void NoCheckSelfCollisions(unsigned int fl, Tworld *w)
Desactivates all the possible collision between links.
Definition: world.c:2153
void DeletePolyhedron(Tpolyhedron *p)
Destructor.
Definition: polyhedron.c:1692
void NewSphericalJoint(unsigned int id, unsigned int linkID1, Tlink *link1, unsigned int linkID2, Tlink *link2, double **points, boolean hasLimits, double range, double **rPoints, boolean avoidLimits, double avoidLimitsWeight, Tjoint *j)
Constructor.
Definition: joint.c:444
void AccumulateColor(Tcolor *c1, Tcolor *c)
Adds a color.
Definition: color.c:83
void NewInterval(double lower, double upper, Tinterval *i)
Constructor.
Definition: interval.c:47
int ReadWorlderror(const char *s)
Syntax errors in .world files.
Definition: error_world.c:47
void HTransformTy(double ty, THTransform *t)
Constructor.
Definition: htransform.c:123
#define RED
Red.
Definition: color.h:23
void DeleteConstants(Tconstants *cts)
Destructor.
Definition: constants.c:137
void NewColor(double r, double g, double b, Tcolor *c)
Constructor.
Definition: color.c:14
unsigned int GetParameterID(char *name, Tparameters *p)
Returns the parameter identifier given the paramete name.
Definition: parameters.c:110
Defines a interval.
Definition: interval.h:33
void HTransformRy(double ry, THTransform *t)
Constructor.
Definition: htransform.c:178
void HTransformIdentity(THTransform *t)
Constructor.
Definition: htransform.c:69
void CheckLinkObstacleCollision(unsigned int a, unsigned int b, Tworld *w)
Activates the possible collision between a particular link and an object in the environment.
Definition: world.c:2191
void DeleteJoint(Tjoint *j)
Destructor.
Definition: joint.c:3190
void NewColorWithID(unsigned int id, Tcolor *c)
Constructor.
Definition: color.c:21
void NewPrismaticJoint(unsigned int id, unsigned int linkID1, Tlink *link1, unsigned int linkID2, Tlink *link2, double **points, Tinterval *range, boolean avoidLimits, double avoidLimitsWeight, Tjoint *j)
Constructor.
Definition: joint.c:533
#define DECOR_SHAPE
One of the possible type of shapes.
Definition: polyhedron.h:46
Error function specific of world.
#define HIDDEN_SHAPE
One of the possible type of shapes.
Definition: polyhedron.h:37
void NewLine(double *p1, double *p2, Tcolor *c, unsigned int bs, Tpolyhedron *p)
Constructor.
Definition: polyhedron.c:1071