00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include <IKOR/general.h>
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 int main (int argc, char **argv)
00032 {
00033 int i, j,
00034 IKCriterion[2]={-1, -1},
00035
00036 IKMethod[5]={0,0,0,0,0},
00037 MethodChosen=FALSE,
00038 Optimization=LAGRANGIAN,
00039 IKstatus,
00040 Platform = FALSE,
00041 Orient = FALSE;
00042 char *temp, *plat_type, *ornt_type, temp2[2]={ '\0','\0' };
00043
00044 for (i=1; i<argc; i++)
00045 {
00046 switch (argv[i][0]) {
00047 case 'm':
00048 case 'M': temp = argv[i] +1; M = atoi(temp); break;
00049 case 'n':
00050 case 'N': temp = argv[i] +1; N = atoi(temp); break;
00051 case 't':
00052 case 'T': temp = argv[i] +1; temp2[0]=temp[0];
00053 IKCriterion[0] = atoi(temp2);
00054 if (strlen(argv[i]) > 2)
00055 { temp = argv[i] +2; IKCriterion[1] = atoi(temp); }
00056 break;
00057 case 's':
00058 case 'S': temp = argv[i] +1; STEP = atoi(temp); break;
00059 case 'f':
00060 case 'F': MethodChosen = TRUE;
00061 for (j=1; j<strlen(argv[i]); j++)
00062 switch (argv[i][j]){
00063 case 'l':
00064 case 'L': IKMethod[JN_LIMITS] = TRUE; break;
00065 case 'o':
00066 case 'O': IKMethod[OBSTACLES] = TRUE; break;
00067 case 'b':
00068 case 'B': IKMethod[ACCELRATN] = TRUE; break;
00069 case 'i':
00070 case 'I': IKMethod[EE_IMPACT] = TRUE; break;
00071 case 'e':
00072 case 'E': temp = argv[i]+j+1;
00073 IKMethod[4] = atoi(temp); break;
00074 }; break;
00075 case 'o':
00076 case 'O': ornt_type = argv[i] +1; Orient = TRUE; break;
00077 case 'p':
00078 case 'P': plat_type = argv[i] +1; Platform = TRUE; break;
00079 case 'd':
00080 case 'D': DEBUG = TRUE; break;
00081 case 'c':
00082 case 'C': CHANGE_SPHERES = TRUE; break;
00083
00084 default : fprintf(stderr,"Unknown argument! \n"); help();
00085 break;
00086 }
00087 }
00088
00089 Init_Globals();
00090 if (Orient) if (ornt_type[0]=='1') Orient = ZEROD_OMEGAS;
00091 if (Platform)
00092 if ((plat_type[0] == 'N')||(plat_type[0] == 'n'))
00093 Robot->PLAT.Holonomic=FALSE;
00094 if (M > Robot->NA) { IKerror (16, OK, "short.c"); M == -1; }
00095 if (N > 6) { IKerror (17, OK, "short.c"); N == -1; }
00096 if ((STEP != ONE) && (STEP != TWO))
00097 { IKerror(23, OK, "short.c"); STEP = ONE; }
00098 Robot->Orient = Orient;
00099 Robot->PLAT.Active = Platform;
00100 if ((Platform) && (!Robot->PLAT.Exist))
00101 { IKerror(24, OK, "ROBOT.dat"); Robot->PLAT.Active = FALSE; }
00102 fprintf(stderr, "NL: %d, NA: %d, Platform?: %s, Orient: %s.\n",
00103 Robot->NL, Robot->NA, Robot->PLAT.Active ? "Yes" : "No",
00104 Robot->Orient ? "Yes" : "No");
00105
00106
00107 if ((M==-1) && (Robot->PLAT.Active)) M = Robot->NA;
00108 else if (M==-1) M = Robot->NA - 3;
00109
00110 if ((N==-1) && (Orient)) N = 6;
00111 else if (N==-1) N = 3;
00112
00113 if (IKCriterion[0]==4)
00114 switch (IKCriterion[1]) {
00115 case 1: Optimization = LAGRANGIAN; break;
00116 case 2: Optimization = BANGBANG; break;
00117 case 3: Optimization = SIMPLEX; break;
00118 default: fprintf(stderr,"\nParameter for Least Flow Optimization %s",
00119 "does not exist. Choices are (1,2, or 3)\n");
00120 IKerror(31,FATAL,"No such Optimization");
00121 }
00122 if (IKCriterion[0]==-1) IKCriterion[0] = 0;
00123
00124 fprintf(stderr, "IKOR Parameters: N: %d, M: %d, Plat: %s, Orient: %s.\n",
00125 N, M, Robot->PLAT.Active ? "Yes" : "No",
00126 Robot->Orient ? "Yes" : "No");
00127
00128
00129 IKstatus = IKOR_driver(IKCriterion, IKMethod, Optimization, N, M);
00130
00131 switch (IKstatus) {
00132 case -2 : fprintf(stderr,"\nSome kind of file error, sorry!\n");
00133 break;
00134 case -1 : fprintf(stderr,"\nFile completion. Partial Trajectory Only\n");
00135 break;
00136 default : fprintf(stderr,"\nFile completion. Full Trajectory\n");
00137 break;
00138
00139 return (IKstatus);
00140 }
00141 }
00142
00143
00144
00145 int help( void )
00146 {
00147 FILE *temp;
00148 char one;
00149
00150
00151 if ((temp = fopen("../COMPILE/IKOR/inform", "r")) == NULL)
00152 fprintf(stderr, "INFO FILE GONE: COMPILE/IKOR/inform. Use at own RISK!\n");
00153 else
00154 while (!feof(temp)) fputc(fgetc(temp), stderr);
00155 if (!temp) fclose (temp);
00156
00157 exit(-1);
00158 }