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

robot/control/oldikor/IKOR/Manipulators.c

Go to the documentation of this file.
00001 /* ________________________________________________________
00002   |                                                        |
00003   | Program Name:   Manipulators.c                         |
00004   |________________________________________________________|
00005   |                                                        |
00006   | description: Integrates different manipulator's into   |
00007   |    the system by reading ARM_file, "ROBOT.dat".  This  |
00008   |    allows a data file, such as ROBOT_AIRARM.dat, to be |
00009   |    copied into ROBOT.dat and the system will now emul- |
00010   |    the new manipulator. See User's Guide or sample a   |
00011   |    sample data file for creation of a new manipulator. |
00012   |                                                        |
00013   | Procedures:                                            |
00014   |    go_next         :                                   |
00015   |    rm_blanks       :                                   |
00016   |    init_arm        :                                   |
00017   |________________________________________________________| */
00018 
00019 
00020 #include <IKOR/general.h>
00021 
00022 /* ________________________________________________________
00023   | name:            go_next                               |
00024   | description:  Finds an Exclamation Mark in requested   |
00025   |     file and then continues to read the rest of the    |
00026   |     line containing that delimiter.  Prepares file     |
00027   |     read pointer to get input on the line immediately  |
00028   |     following the excamation mark.                     |
00029   |           33 is the exclamation '!' character          |
00030   |           10 is the newline    '\n' character          |
00031   |                                                        |
00032   | inputs:  File to find the delimiter                    |
00033   | outputs: File read pointer points to beginning of next |
00034   |     line.                                              |
00035   |________________________________________________________|
00036   | Authors:     Date:     Modifications:                  |
00037   | c hacker      3/95     Created                         |
00038   |________________________________________________________| */
00039 int go_next(FILE *ARM)
00040 {
00041   char CHAR = 'x';
00042 
00043   while ((!feof(ARM)) && (CHAR != 33)) CHAR = fgetc(ARM);
00044   if (!feof(ARM))
00045     while ((!feof(ARM)) && (CHAR != 10)) CHAR = fgetc(ARM);
00046 
00047   if (feof(ARM)) IKerror (19, FATAL, "go_next");
00048 }
00049 
00050 /* ________________________________________________________
00051   | name:            rm_blanks                             |
00052   | description:  Reads past all blanks and tabls in a     |
00053   |     line and returns the first character found.        |
00054   |                                                        |
00055   | inputs:  File to find the character                    |
00056   | outputs: Returns first non blank or non tab character  |
00057   |________________________________________________________|
00058   | Authors:     Date:     Modifications:                  |
00059   | c hacker      3/95     Created                         |
00060   |________________________________________________________| */
00061 
00062 int rm_blanks(FILE *ARM)
00063 {
00064   char CHAR=' ';
00065 
00066   while ((!feof(ARM)) && ((CHAR == 32) || (CHAR == 9))) CHAR = fgetc(ARM);
00067   if (feof(ARM)) IKerror (19, FATAL, "rm_blanks"); 
00068 
00069   return CHAR;
00070 }
00071 
00072 /* ________________________________________________________
00073   | name:            init_ARM                              |
00074   | description:  Reads file determined by global character|
00075   |      constant defined in Globals.h, and then builds a  |
00076   |      manipulator based on that data.                   |
00077   |                                                        |
00078   | inputs:  char constant ARM_file                        |
00079   | outputs: Global variables PLAT, Angles, LINKS, and LL  |
00080   |      are built.                                        |
00081   |________________________________________________________|
00082   | Authors:     Date:     Modifications:                  |
00083   | c hacker      3/95     Created                         |
00084   |________________________________________________________| */
00085 
00086 void init_ARM()
00087 {
00088   int   i,j;       /* Loop counter variable                    */
00089   FILE *ARM;     /* File pointer that will point to ARM_file */
00090   double temp_f; /* Temporary float variable for reading     */
00091   int    temp_i; /* Temporary int   variable for reading     */
00092   extern float EEzaxis;  /* these are used to correct the default               */
00093   extern float EEyaxis; /* orientation of the EE. Used in Jacob_ROBOT.c IF the */
00094   extern float EExaxis;   /* end-effector description is being overriden.        */
00095   
00096 
00097   if (( ARM = fopen(ARM_file, "r") )==NULL) IKerror (11, FATAL, ARM_file);
00098 
00099   if (!(Robot = (Manipulator_struct *) malloc ( sizeof(Manipulator_struct))))
00100         IKerror (18, FATAL, "init_ARM");
00101 
00102   go_next(ARM);         /* find next exclamation mark       */
00103   fscanf(ARM,"%d",&temp_i);
00104   Robot->NL = temp_i;   /* Read in Number of Links          */
00105                         /* Allocate memory for LINKS and LL */
00106   if (!(Robot->LINKS = (double *) malloc( Robot->NL * sizeof(double) )))
00107         IKerror (18, FATAL, "init_ARM");
00108   if (!(LL           = (double *) malloc( Robot->NL * sizeof(double) )))
00109         IKerror (18, FATAL, "init_ARM");
00110 
00111   go_next(ARM);         /* find next exclamation mark       */
00112                         /* Assign Link Lengths to LINKS     */
00113   for (i=0; i<Robot->NL; i++)
00114   {
00115     fscanf(ARM,"%lf", &temp_f);
00116     Robot->LINKS[i] = temp_f;
00117   }
00118 
00119   go_next(ARM);         /* find next exclamation mark       */
00120   fscanf(ARM,"%d",&temp_i);
00121   Robot->NA = temp_i;   /* Read in Number of Angles         */
00122                         /* Allocate memory for Angles struct*/
00123   if (!(Robot->Angles = (ANGLE *) malloc (Robot->NA * sizeof(ANGLE))))
00124         IKerror (18, FATAL, "init_ARM");
00125   Robot->Weights= mat_malloc (Robot->NA, Robot->NA);
00126   for(i=0; i<Robot->NA; i++)
00127     for(j=0; j<Robot->NA; j++)
00128       Robot->Weights->p[i][j] = 0.0;
00129   go_next(ARM);         /* find next exclamation mark       */
00130                         /* Assign Angle info to Angles      */
00131   for (i=0; i<Robot->NA; i++) {
00132     fscanf(ARM,"%f", &(Robot->Angles[i].Max_limit));
00133     fscanf(ARM,"%f", &(Robot->Angles[i].Min_limit));
00134     Robot->Angles[i].Prism = rm_blanks(ARM);
00135     if ((Robot->Angles[i].Prism == 'N') || (Robot->Angles[i].Prism == 'n'))
00136          Robot->Angles[i].Prism = FALSE;
00137     else Robot->Angles[i].Prism = TRUE;
00138     fscanf(ARM,"%f", &(Robot->Weights->p[i][i]));
00139     fscanf(ARM,"%f", &(Robot->Angles[i].Home));
00140   }
00141 
00142   go_next(ARM);         /* find next exclamation mark       */
00143                         /* Determine if Robot has platform  */
00144   temp_i = rm_blanks(ARM);
00145 
00146 
00147   /*if the next parameter is "e", read optional EE control*/
00148   if ((temp_i == 'e') || (temp_i == 'E'))
00149     {
00150       go_next(ARM);
00151       fscanf(ARM,"%f", &EEzaxis);
00152       fscanf(ARM,"%f", &EEyaxis);
00153       fscanf(ARM,"%f", &EExaxis);
00154       EEzaxis =  (EEzaxis*PI / 180.0);     /* convert to radians */
00155       EEyaxis = (EEyaxis*PI/ 180.0);       /* convert to radians */
00156       EExaxis =   (EExaxis*PI  / 180.0);   /* convert to radians */
00157       go_next(ARM);
00158       temp_i = rm_blanks(ARM);
00159     }
00160 
00161   if ((temp_i == 'y') || (temp_i == 'Y'))
00162     Robot->PLAT.Exist = TRUE;
00163   else Robot->PLAT.Exist = FALSE;
00164 
00165   go_next(ARM);         /* find next exclamation mark       */
00166                         /* If Platform exists, Assing info  */
00167   if (Robot->PLAT.Exist) {
00168      fscanf( ARM,"%f", &( Robot->PLAT.Length  ) );
00169      fscanf( ARM,"%f", &( Robot->PLAT.Width   ) );
00170      fscanf( ARM,"%f", &( Robot->PLAT.Thick   ) );
00171      go_next(ARM);
00172      fscanf( ARM,"%f", &( Robot->PLAT.Z_OFF   ) );
00173      fscanf( ARM,"%f", &( Robot->PLAT.L_OFF   ) );
00174      fscanf( ARM,"%f", &( Robot->PLAT.ANG_OFF ) );
00175   }
00176   Robot->PLAT.Holonomic = 1;   /* Currently all platforms assumed holonomic */
00177 
00178   /*********************************************************
00179    *                                                       *
00180    *  Print out all data attained from Manipulator file    *
00181    *                                                       *
00182    *********************************************************/
00183 
00184   #ifndef FSP_DEBUG
00185   if (DEBUG) {
00186     fprintf(stderr, "\n NL: %d", Robot->NL);
00187     for (i=0; i<Robot->NL; i++) 
00188       fprintf(stderr, "\n LINK[%d]: %f", i, Robot->LINKS[i]);
00189     fprintf(stderr, "\n NA: %d", Robot->NA);
00190     for (i=0; i<Robot->NA; i++) 
00191       fprintf(stderr, "\n%3d %s %s %9.2f %s %9.2f %s %s %s %6.4f %s %7.2f",
00192         i, ":",
00193         "Max:"   ,Robot->Angles[i].Max_limit,
00194         "Min:"   ,Robot->Angles[i].Min_limit,
00195         "Prism:" ,(Robot->Angles[i].Prism) ? "YES" : "NO ",
00196         "Weight:",Robot->Weights->p[i][i]   ,
00197         "Home:"  ,Robot->Angles[i].Home       );
00198 
00199     fprintf(stderr, "\n PLAT: %s", Robot->PLAT.Exist ? "Yes" : "No");
00200     fprintf(stderr, "\n   Length   : %f", Robot->PLAT.Length); 
00201     fprintf(stderr, "\n   Width    : %f", Robot->PLAT.Width);
00202     fprintf(stderr, "\n   Thickness: %f", Robot->PLAT.Thick);
00203     fprintf(stderr, "\n   Z_OFF    : %f", Robot->PLAT.Z_OFF);
00204     fprintf(stderr, "\n   L_OFF    : %f", Robot->PLAT.L_OFF);
00205     fprintf(stderr, "\n   ANG_OFF  : %f\n\n", Robot->PLAT.ANG_OFF);
00206   }
00207   #endif
00208 
00209   fclose(ARM);
00210 }
00211 
00212 
00213 
00214 
00215 

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