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

robot/control/oldikor/IKOR/criteria.c

Go to the documentation of this file.
00001 /* ________________________________________________________
00002   |                                                        |
00003   | Program Name:   criteria.c                             |
00004   |________________________________________________________|
00005   |                                                        |
00006   | description: This file contains the declarations for   |
00007   |    different criteria, such as Least Norm, Force,      |
00008   |    Torque, or strength optimization.                   |
00009   |                                                        |
00010   | Procedures:                                            |
00011   |    Least_Norm() : H is ZERO, and B is identity.        |
00012   |    Least_Flow() : H is ZERO, and B is governing matrix |
00013   |________________________________________________________| */
00014 
00015 
00016 #include <IKOR/general.h>       /* Header File to link all others */
00017 
00018 /* ________________________________________________________
00019   | name:    Least_Norm()                                  |
00020   | description:  Form Least Norm Motion, the reference    |
00021   |     vector Zr is zero and therefore H is zero.  The B  |
00022   |     vector is also zero.                               |
00023   |                                                        |
00024   | inputs:  none                                          |
00025   | outputs: H is the zero vector, B is the identity matrix|
00026   |________________________________________________________|
00027   | Authors:     Date:     Modifications:                  |
00028   | c hacker      3/95    Created                          |
00029   |________________________________________________________| */
00030 
00031 int Least_Norm (MATRIX *B, MATRIX *H, FILE *datafp)
00032 {
00033   int i, j=0;
00034   
00035   
00036   for (i=0; i<H->rows; i++)   H->p[i][0] = 0.0;  /* this is Zr reference */
00037   for (j=0; j<B->cols; j++)
00038     for (i=0; i<B->rows; i++)
00039       if (i==j)
00040         B->p[i][j] = 1.0;
00041       else
00042         B->p[i][j] = ZERO;
00043 
00044   if (DEBUG) {
00045     fmat_pr(datafp,"Least Norm B", B);
00046     fmat_pr(datafp,"Least Norm H", H);
00047   }
00048 }
00049 
00050 /* ________________________________________________________
00051   | name:    Least_FLOW()                                  |
00052   | description:  Form Least Flow Motion, the reference    |
00053   |     vector Zr is zero and therefore H is zero.  The B  |
00054   |     vector is a matrix built upon the flows of the     |
00055   |     hydrolic pumps (currently on AIARM is implemented) |
00056   |                                                        |
00057   | inputs:  Previous Joint Angles and Previous dq         |
00058   | outputs: H is the zero vector, B is the govrning matrix|
00059   |________________________________________________________|
00060   | Authors:     Date:     Modifications:                  |
00061   | c hacker     12/95       Created                       |
00062   |________________________________________________________| */
00063 
00064 int Least_Flow (MATRIX *B, MATRIX *H, MATRIX *Qarray, FILE* datafp)
00065 {
00066   int i, j;
00067 
00068   for (i=0; i<H->rows; i++)   H->p[i][0] = 0.0;  /* this is Zr reference */
00069   for (j=0; j<B->cols; j++)
00070     for (i=0; i<B->rows; i++)
00071       /* The 1.0 for dq really means don't modifiy the equations, while */
00072       /* the negative distance means don't generate output to datafile  */
00073       if (i==j) B->p[i][i] = calc_flow(i, Qarray->p[i][0], 1.0, -1.0, 
00074                                                         (MATRIX *) 0);
00075       else      B->p[i][j] = ZERO;
00076 
00077 
00078   if (DEBUG) {
00079     fmat_pr(datafp,"Least FLOW B", B);
00080     fmat_pr(datafp,"Least FLOW H", H);
00081   }
00082 }
00083 
00084 /* FLOW equations for AIRARM's Hydraulic Motors */
00085 float calc_flow(int index, float Q, float dq, float distance, MATRIX *old)
00086 {
00087   static float FLOW=ZERO, totaltime = ZERO;
00088   float  numerator, denominator, dFLOW, time;
00089 
00090   dq = fabs(dq);
00091   switch (index) {
00092         case 0 :
00093             Q           = 1.5479 - Q;
00094             numerator   = 0.386 * sin(Q);
00095             denominator = sqrt( 1.29 - .769 * cos(Q) );
00096             dFLOW       = numerator / denominator;
00097               if (dq<ZERO)  dFLOW *= dq * 4.28;                 /*push*/
00098               else          dFLOW *= dq * 2.60;                 /*pull*/
00099             break;
00100         case 1 :
00101             Q           = 1.360 - (Q - PI/2);
00102             numerator   = 0.574 * sin(Q);
00103             denominator = sqrt( 2.05 - 1.15 * cos(Q) );
00104             dFLOW       = numerator / denominator;
00105               if (dq<ZERO)  dFLOW *= dq * 4.82;                 /*push*/
00106               else          dFLOW *= dq * 2.68;                 /*pull*/
00107             break;
00108         case 2 :
00109               if (dq>ZERO)  dFLOW = dq * .838;          /*push*/
00110               else          dFLOW = dq * .429;          /*pull*/
00111             break;
00112         case 3 :
00113             Q           = 0.546 - (Q); dq = -dq;
00114             numerator   = 0.190 * sin(Q);  
00115             denominator = sqrt( 0.82 - 0.38 * cos(Q) );
00116             dFLOW       = numerator / denominator;
00117               if (dq<ZERO)  dFLOW *= dq * 2.10;
00118               else          dFLOW *= dq * 1.73;
00119             break;
00120         case 4 :
00121             dFLOW = .05500 * dq;
00122             break;
00123         case 5 :
00124             dFLOW = .00688 * dq;
00125             break;
00126   }
00127 
00128   /* if the B Matrix is not being Calculated */
00129   if (distance >= ZERO) {  
00130     time  = distance/(60*SPEED);  /* SPEED is (.3m/s) defined in general.h */
00131  /*   FLOW += (fabs(dFLOW)/time);        /* Uncomment for flow comparisons */
00132     FLOW += SQUARE(fabs(dFLOW)/time);  /* Uncomment for norm comparisons */
00133 
00134     if (index==0) fprintf(FLWfile, "%7.5f", totaltime);
00135 
00136     fprintf(FLWfile, " %11.8f",       (time)?(fabs(dFLOW)/time):ZERO);
00137     if (DEBUG) {
00138       fprintf(datafp, "dFLOW[%d]: %10.4f dF/dt: %13.8f\n", index, fabs(dFLOW), 
00139                         fabs(dFLOW)/time);
00140       if (index == 5) 
00141         fprintf(datafp, "FLOW: %f  TIME: %f  DISTANCE: %f\nFLOWRATE: %f\n",
00142                          FLOW, time, distance, (time)?FLOW/time:0.0);
00143     }
00144     if (index==5){
00145         fprintf(FLWfile, " %11.6f\n", (time)?FLOW:ZERO); 
00146         fprintf(distfp, "%f \n", distance);
00147         FLOW = 0.0;
00148         totaltime += time;
00149     }
00150   }
00151 
00152   return (fabs(dFLOW));
00153 }

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