Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

robot/control/oldikor/IKOR/short.c

Go to the documentation of this file.
00001 /* ________________________________________________________
00002   |                                                        |
00003   | Program Name:   short.c                                |
00004   |________________________________________________________|
00005   |                                                        |
00006   | description: Aquires Betas for constraints and det-    |
00007   |     ermine the Analytical solution for each time step. |
00008   |                                                        |
00009   | Procedures:                                            |
00010   |    main            :                                   |
00011   |________________________________________________________| */
00012 
00013 
00014 #include <IKOR/general.h>       /* Header File to link all others */
00015 
00016 /* ________________________________________________________
00017   | name:    main                                          |
00018   | description:  launches system with as little as poss-  |
00019   |     possible.  If it is possible to launch with less,  |
00020   |     make it so.  This is a short driver that enables   |
00021   |     a command-line approach to the IKOR-FSP system.    |
00022   |     see help file for more information.                |
00023   |                                                        |
00024   | inputs:  The file info which contains help.            |
00025   | outputs: Calls IKOR_driver with proper parameters.     |
00026   |________________________________________________________|
00027   | Authors:     Date:     Modifications:                  |
00028   |  c hacker     10/94    Created                         |
00029   |________________________________________________________| */
00030 
00031 int main (int argc, char **argv)
00032 {
00033   int   i, j,                    /* counter variable                       */
00034         IKCriterion[2]={-1, -1}, /* 0-FSP/LN, 1-Pseudo, 2-mindx, 3-mindist */
00035                                  /* 4-FLOW                                 */
00036         IKMethod[5]={0,0,0,0,0}, /* 0-JL, 1-OBS, 2-BA, 3-EEdir             */
00037         MethodChosen=FALSE,
00038         Optimization=LAGRANGIAN, /* BANGBANG, SIMPLEX, LAGRANGIAN          */
00039         IKstatus,                /* return status from IKOR_driver         */ 
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(); /* Mostly for CheezyIGRIP & Manipulator Initialization */
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   /* set default joint space.*/
00107   if ((M==-1) && (Robot->PLAT.Active)) M = Robot->NA;
00108   else if (M==-1)                      M = Robot->NA - 3;  /*lst 3 are pltfrm*/
00109   /* set default task space. */
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;      /* default: FSP   */
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   /* begin driver */
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   } /* end switch */
00141 } /* end short */
00142 
00143 
00144 
00145 int help( void )
00146 {
00147   FILE *temp;      /* used to point to help file             */
00148   char  one;       /* used to read help file                 */
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 }

Generated on Thu Jul 29 15:56:35 2004 for OpenSim by doxygen 1.3.6