libmove3d
3.13.0
|
00001 #ifndef _LOCALPATH_DEF_H 00002 #define _LOCALPATH_DEF_H 00003 00004 #include "../localpath/flat/include/struct_flat.h" 00005 #ifdef MULTILOCALPATH 00006 #include "softMotion/softMotionStruct.h" 00007 #endif 00008 #include "../localpath/include/p3d_localPathGroup.h" 00009 00010 #define NB_COORD_TRAILER 5 00011 #define NB_COORD_REEDS_SHEPP 4 00012 #define NB_COORD_HILFLAT 4 00013 00014 #define NB_JNT_TRAILER 3 00015 #define NB_JNT_HILFLAT 2 00016 #define NB_JNT_REEDS_SHEPP 1 00017 00018 /* Index of each coordinate in array numdof of struct flat_trailer */ 00019 #define TRAILER_DOF_X 0 00020 #define TRAILER_DOF_Y 1 00021 #define TRAILER_DOF_THETA 2 00022 #define TRAILER_DOF_PHI 3 00023 #define TRAILER_DOF_DC_DS 4 00024 00025 /* Index of each coordinate in array numdof of struct lm_hilflat */ 00026 #define HILFLAT_DOF_X 0 00027 #define HILFLAT_DOF_Y 1 00028 #define HILFLAT_DOF_THETA 2 00029 #define HILFLAT_DOF_CURV 3 00030 00031 00032 //#define SOFTMOTION_DOF 7 00033 #define NB_PARAMS_SOFTMOTION 6 00034 /* Number of params from .p3d that include Number of kinematic constraints \ 00035 initialized with p3d files (Jmax, Amax and Vmax) \ 00036 for linear and angular motion*/ 00037 #ifdef MULTILOCALPATH 00038 /* Maximun number of multigraph, you can change it if you want */ 00039 #define MAX_MULTILOCALPATH_NB 10 00040 #endif 00041 00042 #ifdef LIGHT_PLANNER 00043 #define MAX_CARRIED_OBJECTS 10 00044 #endif 00045 00046 typedef enum { 00047 REEDS_SHEPP, 00048 LINEAR, 00049 MANHATTAN, 00050 TRAILER, 00051 TRAILER_FORWARD, 00052 HILFLAT, 00053 HILFLAT_FORWARD, 00054 DUBINS, 00055 #ifdef MULTILOCALPATH 00056 SOFT_MOTION, /* XB */ 00057 MULTI_LOCALPATH, 00058 #endif 00059 NBLP_TYPE 00060 } p3d_localpath_type; 00061 00063 //typedef enum { 00064 // REEDS_SHEPP, 00065 // LINEAR, 00066 // MANHATTAN, 00067 // TRAILER, 00068 // TRAILER_FORWARD, 00069 // HILFLAT, 00070 // HILFLAT_FORWARD, 00071 // DUBINS, 00072 //#ifdef MULTILOCALPATH 00073 // SOFT_MOTION, /* XB */ 00074 // MULTI_LOCALPATH, // Call softMotion planner and softmotion call the specific planner ... 00075 //#endif 00076 // NBLP_TYPE 00077 //} p3d_localpath_type; 00078 00079 extern int P3D_NB_LOCAL_PLANNER; 00080 00081 #define DEFAULT_LOCAL_PLANNER LINEAR 00082 00083 /* types of Reeds and Shepp curve parts */ 00084 #define rs_type int 00085 #define RIGHT 1 00086 #define LEFT 2 00087 #define STRAIGHT 3 00088 00089 #define whichway int 00090 #define BACKWARD -1 00091 #define FORWARD 1 00092 00093 00095 typedef struct s_stay_within_dist_data { 00096 double vmax; /* maximum linear speed for the joint */ 00097 double wmax; /* maximum angular speed for the joint */ 00098 p3d_point p; /* position of the joint */ 00099 struct s_stay_within_dist_data * prev; /* previous joint */ 00100 double vmax0; /* maximum linear speed before the joint */ 00101 double wmax0; /* maximum angular speed before the joint */ 00102 00103 } p3d_stay_within_dist_data; 00104 00105 /* structure de chemin de Reeds et Shepp sur les trois premieres 00106 variables de configuration et lineaires sur les autres */ 00107 typedef struct rs_data{ 00108 configPt q_init; /* config init sur la courbe */ 00109 configPt q_end; /* config fin sur la courbe */ 00110 double centre_x; /* centre du cercle correspondant */ 00111 double centre_y; /* en x et y si c'est le cas (sinon 0) */ 00112 double radius; /* rayon du disque */ 00113 whichway dir_rs; /* sens = 1/-1 pour avant/arriere */ 00114 double val_rs; /* valeur de la portion de courbe */ 00115 rs_type type_rs; /* type = 1/2/3 pour droite/gauche/segment */ 00116 struct rs_data *next_rs; /* pointeur sur portion suivante */ 00117 struct rs_data *prev_rs; /* pointeur sur portion precedente */ 00118 } p3d_rs_data, *pp3d_rs_data; 00119 00120 /* structure de chemin lineaire */ 00121 typedef struct lin_data{ 00122 configPt q_init; /* config init sur la courbe */ 00123 configPt q_end; /* config fin sur la courbe */ 00124 } p3d_lin_data, *pp3d_lin_data; 00125 00126 /* structure de chemin Manhattan */ 00127 typedef struct manh_data{ 00128 configPt q_init; /* config init sur la courbe */ 00129 configPt q_end; /* config fin sur la courbe */ 00130 configPt crit_q_init; /* critere sens depend de cette config init sur la courbe originale */ 00131 configPt crit_q_end; /* critere sens depend de cette config fin sur la courbeo riginale */ 00132 double val_manh; /* valeur de la portion de courbe */ 00133 } p3d_manh_data, *pp3d_manh_data; 00134 00135 typedef struct sub_trailer_data{ 00136 configPt q_init; /* init config on sub local path */ 00137 configPt q_end; /* end config on sub local path */ 00138 double v; /* projection of q_end on Gamma_init */ 00139 double length; /*length of the sub local path between q_init and q_end*/ 00140 double alpha_0; /* third derivative of alpha at beginning */ 00141 double alpha_1; /* third derivative of alpha at end */ 00142 double u_start; /* parameter beginning of localpath on combination */ 00143 double u_end; /* parameter end of localpath on combination */ 00144 double gamma_1_min; /*the min of the first derivation of the curve*/ 00145 double v_1_rob_max;/*maximal linear acceleration of robot on all the sub path*/ 00146 double v_1_rem_max;/*maximal linear acceleration of trailer on all the sub path*/ 00147 double w_1_rob_max;/* max angular acceleration of robot along sub path */ 00148 double w_1_rem_max;/* max angular acceleration of trailer along sub path */ 00149 double phi_max;/*the max of phi on all the way*/ 00150 double phi_min;/*the min of phi on all the way*/ 00151 double phi_1_tot;/*this is the kind of integral of phi_2 on the path*/ 00152 }p3d_sub_trailer_data, *pp3d_sub_trailer_data; 00153 00154 00155 typedef struct trailer_data{ 00156 p3d_sub_trailer_data *init_cusp; 00157 p3d_sub_trailer_data *cusp_end; 00158 int symmetric; 00159 } p3d_trailer_data, *pp3d_trailer_data; 00160 00161 typedef struct sub_hilflat_data{ 00162 configPt q_init; /* init config on sub local path */ 00163 configPt q_end; /* end config on sub local path */ 00164 double v; /* projection of q_end on Gamma_init */ 00165 double length; /*length of the sub local path between q_init and q_end*/ 00166 double u_start; /* parameter beginning of localpath on combination */ 00167 double u_end; /* parameter end of localpath on combination */ 00168 double gamma_1_min; /*the min of the first derivation of the curve*/ 00169 double v_1_rob_max; /*maximal linear acceleration of robot on 00170 all the sub path*/ 00171 double w_1_rob_max; /*maximal angular acceleration of robot 00172 on all the sub path*/ 00173 double theta_1_tot;/*this is the kind of integral of theta' along the path*/ 00174 } p3d_sub_hilflat_data, *pp3d_sub_hilflat_data; 00175 00176 00177 typedef struct hilflat_data{ 00178 p3d_sub_hilflat_data *init_cusp; 00179 p3d_sub_hilflat_data *cusp_end; 00180 int symmetric; 00181 } p3d_hilflat_data, *pp3d_hilflat_data; 00182 00183 #ifdef MULTILOCALPATH 00184 /* Soft Motion interpolation */ 00185 // typedef struct softMotion_data_FREEFLYER{ 00186 // double J_max_lin; /* Initialized with p3d files */ 00187 // double A_max_lin; /* Initialized with p3d files */ 00188 // double V_max_lin; /* Initialized with p3d files */ 00189 // double J_max_ang; /* Initialized with p3d files */ 00190 // double A_max_ang; /* Initialized with p3d files */ 00191 // double V_max_ang; /* Initialized with p3d files */ 00192 // Gb_v3 poseLinInit; 00193 // Gb_v3 poseLinEnd; 00194 // Gb_v3 velLinInit; 00195 // Gb_v3 velLinEnd; 00196 // Gb_v3 poseAngInit; 00197 // Gb_v3 poseAngEnd; 00198 // Gb_v3 velAngInit; 00199 // Gb_v3 velAngEnd; 00200 // SM_MOTION motion; 00201 // double motionTime; //Duration of motion = range_param 00202 // } p3d_softMotion_data_FREEFLYER, *pp3d_softMotion_data_FREEFLYER; 00203 // 00204 // typedef struct softMotion_data_joint{ 00205 // double* J_max; /* Initialized with p3d files */ 00206 // double* A_max; /* Initialized with p3d files */ 00207 // double* V_max; /* Initialized with p3d files */ 00208 // double* velInit; 00209 // double* velEnd; 00210 // SM_MOTION_MONO* motion; 00211 // double motionTime; //Duration of motion = range_param 00212 // } p3d_softMotion_data_joint, *pp3d_softMotion_data_joint; 00213 00214 typedef struct softMotion_data_specific{ 00215 double* J_max; /* Initialized with p3d files */ 00216 double* A_max; /* Initialized with p3d files */ 00217 double* V_max; /* Initialized with p3d files */ 00218 double* velInit; 00219 double* velEnd; 00220 double* accInit; 00221 double* accEnd; 00222 SM_MOTION_MONO* motion; 00223 double motionTime; //Duration of motion = range_param 00224 } p3d_softMotion_data_specific, *pp3d_softMotion_data_specific; 00225 00226 /* Soft Motion interpolation */ 00227 typedef struct softMotion_data{ 00228 int isPlanned; /* TRUE motion is planned else FALSE */ 00229 int isPTP; /* TRUE is point to point motion else FALSE */ 00230 int nbJoints; 00231 int nbDofs; 00232 p3d_group_type gpType; 00233 configPt q_init; /* config init */ 00234 configPt q_end; /* config end */ 00235 configPt q_endp1; /* config end+1 */ 00236 p3d_softMotion_data_specific* specific; 00237 double kinematic_cost; /* cost in ]0 1] that controls speed, acceleration and jerk */ 00238 } p3d_softMotion_data, *pp3d_softMotion_data; 00239 00240 /* data relative to softMotion local method and stored in p3d_rob */ 00241 typedef struct lm_softMotion{ 00242 int nbJoints; 00243 int nbDofs; 00244 pgp_specific_str specific; 00245 } softMotion_str, *psoftMotion_str; 00246 #endif 00247 00248 /* pointeur sur les structues specifiques a chaque methode locale */ 00249 typedef union lm_specific { 00250 pp3d_rs_data rs_data; 00251 pp3d_lin_data lin_data; 00252 pp3d_manh_data manh_data; 00253 pp3d_trailer_data trailer_data; 00254 pp3d_hilflat_data hilflat_data; 00255 #ifdef MULTILOCALPATH 00256 pp3d_softMotion_data softMotion_data; /* XB */ 00257 #endif 00258 } p3d_lm_specific, *pp3d_lm_specific; 00259 00260 /* data structure that encodes a local path */ 00261 typedef struct localpath{ 00262 /* 00263 * fields 00264 */ 00265 p3d_localpath_type type_lp; /* type de methode locale */ 00266 char *localplanner_name; /* name of local planner that 00267 built this local path */ 00268 p3d_lm_specific specific; /* pointeur vers les donnees specifiques 00269 a chaque type de chemin local */ 00270 00271 #ifdef MULTILOCALPATH 00272 //p3d_lm_specific mgSpecific[MAX_MULTIGRAPH_NB]; /* pointeur vers les donnees specifiques 00273 //a chaque type de chemin local pour chaque multigraph*/ 00274 struct localpath* mlpLocalpath[MAX_MULTILOCALPATH_NB]; 00275 int mlpID; /* ID of graph to which the localpath is associated */ 00276 configPt q_init; 00277 int mlpGpIsActive[MAX_MULTILOCALPATH_NB]; 00278 #endif 00279 00280 struct localpath* prev_lp; /* the local paths can be put in a list */ 00281 struct localpath* next_lp; 00282 int valid; /* TRUE if no collision */ 00283 int lp_id; /* index of loc path in p3d_traj */ 00284 int sdk_id; /* id of localpath in SDK */ 00285 double length_lp; /* store length of local path */ 00286 double range_param; /* parameter range: [0,range_param] */ 00287 int* ikSol; /* witch solutions of constraint are used*/ 00288 int nbActiveCntrts; /*The number of active constraints in the localpath*/ 00289 int* activeCntrts; /*The ids of active constraints in the localpath*/ 00290 00291 #if defined(LIGHT_PLANNER) 00292 int isCarryingObject; 00293 struct rob* carriedObject[MAX_CARRIED_OBJECTS]; 00294 #endif 00295 00296 /* 00297 * methods associated to the local path * 00298 */ 00299 /*computes length of local path */ 00300 double (*length)(struct rob *, struct localpath*); 00301 /*copy the local path */ 00302 struct localpath* (*copy)(struct rob*, struct localpath*); 00303 /* extract from a local path a sub local path starting from length 00304 l1 and ending at length l2 */ 00305 struct localpath* (*extract_sub_localpath)(struct rob *, 00306 struct localpath *localpathPt, 00307 double l1, double l2); 00308 /* extract from a local path a sub local path starting from parameter 00309 u1 and ending at parameter u2 */ 00310 struct localpath* (*extract_by_param)(struct rob *, 00311 struct localpath *localpathPt, 00312 double l1, double l2); 00313 /* destroy the localpath */ 00314 void (*destroy)(struct rob*, struct localpath*); 00315 /* computes the configuration at given distance along the path */ 00316 configPt (*config_at_distance)(struct rob*, 00317 struct localpath*, 00318 double); 00319 /* computes the configuration for a given parameter along the path */ 00320 configPt (*config_at_param)(struct rob*, 00321 struct localpath*, 00322 double); 00323 /* from a configuration on a local path, this function computes an 00324 interval of parameter on the local path on which all the points 00325 of the robot move by less than the distance given as input. 00326 The interval is centered on the configuration given as input. The 00327 function returns the half length of the interval */ 00328 double (*stay_within_dist)(struct rob*, 00329 struct localpath*, 00330 double, whichway, double*); 00331 /* compute the cost of a local path */ 00332 double (*cost)(struct rob*, struct localpath*); 00333 /* function that simplifies the sequence of two local paths: valid 00334 only for RS curves */ 00335 struct localpath* (*simplify)(struct rob*, 00336 struct localpath*, 00337 int*); 00338 int (*write)(FILE *, struct rob*, struct localpath*); 00339 } p3d_localpath , *pp3d_localpath; 00340 00341 /* data relative to RS local method and stored in p3d_rob */ 00342 typedef struct lm_reeds_shepp{ 00343 double radius; /* rayon de braquage */ 00344 int numdof[NB_COORD_REEDS_SHEPP]; /* degrees of freedom on which 00345 RS method applies (x, y, theta, z) (z is optional 00346 if its value is -1, we don't use it) */ 00347 int numjnt ; /* the number of the main joint */ 00348 int nb_other_jnt; /* number of other joints which are free */ 00349 int *other_jnt; /* other joints that are free */ 00350 } lm_reeds_shepp_str, *plm_reeds_shepp_str; 00351 00352 /* data relative to the trailer and stored in p3d_rob */ 00353 typedef struct flat_trailer{ 00354 int numdof[NB_COORD_TRAILER]; /* respective coord of x, y, theta, 00355 phi, dc_ds */ 00356 int numjnt[NB_JNT_TRAILER]; /* respective the number of the main 00357 joint of the trailer joint and of 00358 the dc_ds joint*/ 00359 int nb_other_jnt; /* number of other joints which are free */ 00360 int *other_jnt; /* other joints that are free */ 00361 FLAT_STR *flat_str; 00362 } flat_trailer_str, *pflat_trailer_str; 00363 00364 /* data relative to RS local method and stored in p3d_rob */ 00365 typedef struct lm_hilflat{ 00366 int numdof[NB_COORD_HILFLAT]; /* degrees of freedom on 00367 which hilare flat method applies (x, y, 00368 theta, curv) (z is optional if its value is 00369 -1, we don't use it) */ 00370 int numjnt[NB_JNT_HILFLAT]; /* joint ids */ 00371 int nb_other_jnt; /* number of other joints which are free */ 00372 int *other_jnt; /* other joints that are free */ 00373 } hilflat_str, *philflat_str; 00374 00375 00376 /* pointer to a local planner function */ 00377 typedef pp3d_localpath (*ptr_to_localplanner)(struct rob*, configPt, configPt, int*); 00378 #ifdef MULTILOCALPATH 00379 typedef pp3d_localpath (*ptr_to_softMotion_localplanner)(struct rob*, configPt, configPt, configPt, int*); 00380 00381 /* Array of pointers to localplanner functions. The indices of the array 00382 are the elements of the p3d_localpath_type enumeration. */ 00383 00384 extern ptr_to_localplanner array_localplanner[]; 00385 00386 extern char * array_localplanner_name[]; 00387 00388 typedef int (*ptr_to_softMotion_groupplanner)(struct rob*, int , p3d_group_type , p3d_softMotion_data*, int*); 00389 00390 extern ptr_to_softMotion_groupplanner array_softMotion_groupplanner[]; 00391 extern char * array_group_name[]; 00392 #endif 00393 #endif