chart.h
Go to the documentation of this file.
1 #ifndef CHARTH
2 #define CHARTH
3 
4 #include "boolean.h"
5 #include "parameters.h"
6 #include "cpolytope.h"
7 #include "scpolytope.h"
8 #include "jacobian.h"
9 
10 #include "plot3d.h"
11 
12 #include "geom.h"
13 
14 #include "cuiksystem.h"
15 #include "world.h"
16 
41 #define COMPUTE_LQRPOLICY_IN_T 1
42 
56 #define PLOT_ON_MANIFOLD 0
57 
66 #define PLOT_AS_POLYGONS 1
67 
68 
75 #define MIN_SAMPLING_RADIUS 1e-3
76 
86 typedef struct {
87  /* The chart information */
89  unsigned int m;
90  unsigned int k;
91  unsigned int da;
92  unsigned int n;
93  unsigned int nrJ;
96  double error;
97  double eCurv;
98  double r;
100  unsigned int degree;
101  boolean collision;
102  boolean frontier;
105  boolean singular;
109  double *center;
110  double *T;
112  boolean *BJ;
116  unsigned int ml;
119  unsigned int nl;
120  unsigned int *l;
122  /* Polytope information (can be full or simple) */
123  boolean simple;
127  /* Information about the linearized dynamics (optional) */
128  double *A;
130  double *B;
132  double *c;
134  double *d;
135  double *iRBt;
137  double *BiRBt;
138 } Tchart;
139 
171 unsigned int InitChart(Tparameters *pr,boolean simple,Tbox *domain,unsigned int *tp,
172  unsigned int m,unsigned int k,double *p,double e, double eCurv,double r,
173  TJacobian *sJ,TAtlasBase *w,
174  Tchart *c);
204 unsigned int InitPossiblySingularChart(Tparameters *pr,boolean simple,Tbox *domain,unsigned int *tp,
205  unsigned int m,unsigned int k,double *p,double e, double eCurv,double r,
206  TJacobian *sJ,TAtlasBase *w,
207  Tchart *c);
208 
237 unsigned int InitSingularChart(Tparameters *pr,boolean simple,Tbox *domain,unsigned int *tp,
238  unsigned int m,unsigned int k,double *p,double e, double eCurv,double r,
239  TJacobian *sJ,TAtlasBase *w,
240  Tchart *c);
241 
270 unsigned int InitTrustedChart(Tparameters *pr,boolean simple,Tbox *domain,unsigned int *tp,
271  unsigned int m,unsigned int k,double *p,double e, double eCurv,double r,
272  TJacobian *sJ,TAtlasBase *w,
273  Tchart *c);
274 
307 unsigned int InitChartWithTangent(Tparameters *pr,boolean simple,Tbox *domain,unsigned int *tp,
308  unsigned int m,unsigned int k,double *p,double *T,
309  double e, double eCurv, double r,TJacobian *sJ,
310  TAtlasBase *w,Tchart *c);
311 
335 void SetLinearizedDynamics(unsigned int da,double *mA,double *mB,double *vc,double *iR,Tchart *c);
336 
353 void GetLinearizedDynamics(double **mA,double **mAt,double **mB,double**vc,double **vd,
354  double **iRBt,double **BiRBt,Tchart *c);
355 
364 void CopyChart(Tchart *c_dst,Tchart *c_src);
365 
383 boolean CompareTangentSpaces(Tchart *c1,Tchart *c2);
384 
397 double MinCosinusBetweenCharts(Tchart *c1,Tchart *c2);
398 
413 
423 double *GetChartCenter(Tchart *c);
424 
434 double GetChartRadius(Tchart *c);
435 
448 double GetChartSamplingRadius(Tchart *c);
449 
459 double GetChartMaxError(Tchart *c);
460 
470 double GetChartMaxCurvError(Tchart *c);
471 
481 unsigned int GetChartAmbientDim(Tchart *c);
482 
492 unsigned int GetChartManifoldDim(Tchart *c);
493 
504 double *GetChartTangentSpace(Tchart *c);
505 
516 boolean SingularChart(Tchart *c);
517 
529 boolean *GetChartJacobianBasis(Tchart *c);
530 
571 unsigned int GetChartDegree(Tparameters *pr,double *T,TJacobian *sJ,
572  boolean *singular,Tchart *c);
573 
609 double Manifold2Chart(double *p,unsigned int *tp,double *t,Tchart *c);
610 
649 double Chart2Manifold(Tparameters *pr,TJacobian *sJ,
650  double *t,unsigned int *tp,double *pInit,
651  double *p,Tchart *c);
652 
653 
665 void Local2Global(double *t,unsigned int *tp,double *p,Tchart *c);
666 
688 double ChartErrorFromParameters(double *t,double *p,
689  unsigned int *tp,Tchart *c);
690 
704 double Error2Chart(double *p,unsigned int *tp,Tchart *c);
705 
719 boolean CloseCharts(Tparameters *pr,unsigned int *tp,
720  Tchart *c1,Tchart *c2);
721 
738 boolean IntersectCharts(Tparameters *pr,unsigned int *tp,Tbox *ambient,
739  unsigned int id1,Tchart *c1,
740  unsigned int id2,Tchart *c2);
741 
751 boolean CollisionChart(Tchart *c);
752 
762 boolean FrontierChart(Tchart *c);
763 
772 void ChartIsFrontier(Tchart *c);
773 
788 boolean ExpandibleChart(Tchart *c);
789 
808 boolean OpenChart(Tchart *c);
809 
818 void WrongCorner(unsigned int nv,Tchart *c);
819 
831 boolean InsideChartPolytope(double *t,Tchart *c);
832 
845 unsigned int DetermineChartNeighbour(double epsilon,double *t,Tchart *c);
846 
861 void EnlargeChart(double *t,Tchart *c);
862 
878 boolean BoundaryPointFromExternalCorner(boolean rand,unsigned int *nv,double *t,Tchart *c);
879 
896 void BoundaryPointsFromExternalCorners(unsigned int *n,unsigned int **nv,double ***t,Tchart *c);
897 
908 boolean RandomPointOnBoundary(double *t,Tchart *c);
909 
933 boolean RandomPointInChart(Tparameters *pr,double scale,
934  unsigned int *tp,double *t,double *p,Tchart *c);
935 
944 
953 
967 double ChartMaxVolume(Tchart *c);
968 
991 double ChartVolume(Tparameters *pr,boolean collisionFree,
992  unsigned int *tp,TJacobian *sJ,Tchart *c);
993 
1008 boolean FocusedPointOnBoundary(double *p,unsigned int *tp,double *t,Tchart *c);
1009 
1010 
1040 boolean PathInChart(Tparameters *pr,double *t,unsigned int *tp,TJacobian *sJ,
1041  unsigned int nvs,boolean *systemVars,
1042  unsigned int *ms,
1043  double *pl,unsigned int *ns,double ***path,
1044  Tchart *c);
1045 
1061 double DistanceOnChart(Tparameters *pr,double *t,unsigned int *tp,TJacobian *sJ,
1062  Tchart *c);
1063 
1079 boolean PointOnChart(Tparameters *pr,TJacobian *sJ,
1080  double *p,unsigned int *tp,
1081  double *t,Tchart *c);
1082 
1114 unsigned int ClassifyPointInChart(Tparameters *pr,boolean error,TJacobian *sJ,
1115  double *p,unsigned int *tp,
1116  double *t,Tchart *c);
1138 void LinkCharts(unsigned int id1,Tchart *c1,unsigned int id2,Tchart *c2);
1139 
1153 void AddBorderConstraint(Tparameters *pr,double *t,unsigned int *tp,Tbox *ambient,Tchart *c);
1154 
1172 void ForceChartCut(Tparameters *pr,unsigned int *tp,Tbox *ambient,
1173  unsigned int id1,Tchart *c1,
1174  unsigned int id2,Tchart *c2) ;
1175 
1190 unsigned int ChartNumNeighbours(Tchart *c);
1191 
1207 unsigned int ChartNeighbourID(unsigned int n,Tchart *c);
1208 
1234  unsigned int *nn,unsigned int **cID1,unsigned int **cID2,Tchart *c);
1235 
1271 void PlotChart(Tparameters *pr,FILE *fcost,TJacobian *sJ,
1272  unsigned int xID,unsigned int yID,unsigned int zID,
1273  Tplot3d *p3d,Tchart *c);
1274 
1284 unsigned int ChartMemSize(Tchart *c);
1285 
1294 void SaveChart(FILE *f,Tchart *c);
1295 
1306 void LoadChart(FILE *f,TAtlasBase *w,Tchart *c);
1307 
1317 void PrintChartDefines(FILE *f);
1318 
1326 void DeleteChart(Tchart *c);
1327 
1328 #endif