00001 /* ________________________________________________________ 00002 | | 00003 | Program Name: Jacob_UTILS.c | 00004 |________________________________________________________| 00005 | | 00006 | description: Driver for GET_JACOB as well as code for | 00007 | the transformation matrixes and the extraction of | 00008 | Euler Angles. | 00009 | | 00010 | Procedures: | 00011 | GET_JACOBIAN : | 00012 |________________________________________________________| */ 00013 00014 00015 #include <IKOR/general.h> /* Generic Constants */ 00016 00017 /* ________________________________________________________ 00018 | name: GET_JACOBIAN /GET_JACOBIAN_ALTERED | 00019 | description: if N SPACE == 6 or 3, then the jacobian | 00020 | is a (6x7), or (6x10), or a (3x7), or (3x10) matrix.| 00021 | | 00022 | For Obstacle Avoidance, the Jacobian must be comput-| 00023 | ed at the point of intersection. Functions in | 00024 | Jacob_UTILS.c accomplish this assuming the follow- | 00025 | ing hold: | 00026 | 1. The links should be labeled as LL[0] - LL[4] | 00027 | 2. Change constants such as Link Lengths ect.. | 00028 | into a data file (see ROBOT_AIRARM.dat and | 00029 | the Users Guide) | 00030 | | 00031 | inputs: Initial Qarray and LL[0]-LL[4] | 00032 | outputs: Returns the Jacobian | 00033 |________________________________________________________| 00034 | Authors: Date: Modifications: | 00035 | c hacker 10/94 Created | 00036 |________________________________________________________| */ 00037 00038 void GET_JACOBIAN (MATRIX *Jacob, MATRIX *Qarray) 00039 { 00040 int i; 00041 for (i=0; i<Robot->NL; i++) LL[i] = Robot->LINKS[i]; 00042 00043 GET_JACOB (Jacob, Qarray); 00044 } 00045 00046 void GET_JACOBIAN_ALTERED (MATRIX *Jacob, MATRIX *Qarray) 00047 { 00048 GET_JACOB (Jacob, Qarray); 00049 } 00050 00051 00052 /* ________________________________________________________ 00053 | name: getT2 | 00054 | description: Calculate transformation matrix for a | 00055 | given three angular rotations and three transla- | 00056 | tions. Parameters entered in the order: z axis | 00057 | rotation, y axis rotation, x axis rotation, x axis | 00058 | translation, y axis translation, z axis transla- | 00059 | tion. The following equations come from the mult- | 00060 | iplication of three separate rotation matrices and | 00061 | one translation matrix (all are 4x4). | 00062 | | 00063 | inputs: x,y,z rot and x,y,z tran | 00064 | outputs: Returns the Transformation Matrix | 00065 |________________________________________________________| 00066 | Authors: Date: Modifications: | 00067 | unkown ?/?? Created | 00068 |________________________________________________________| */ 00069 00070 MATRIX *getT2(double ZA,double YB,double XG, double tx,double ty,double tz) 00071 { 00072 double sa, sb, sg, ca, cb, cg; 00073 MATRIX *T; 00074 00075 T=mat_malloc(4,4); 00076 00077 sa = sin(ZA); sb = sin(YB); sg = sin(XG); 00078 ca = cos(ZA); cb = cos(YB); cg = cos(XG); 00079 00080 T->p[0][0]= ca*cb; T->p[0][1]=ca*sb*sg-sa*cg; T->p[0][2]=ca*sb*cg+sa*sg; 00081 T->p[1][0]= sa*cb; T->p[1][1]=sa*sb*sg+ca*cg; T->p[1][2]=sa*sb*cg-ca*sg; 00082 T->p[2][0]= -sb; T->p[2][1]=cb*sg; T->p[2][2]=cb*cg; 00083 T->p[3][0]= 0.0; T->p[3][1]=0.0; T->p[3][2]=0.0; 00084 T->p[0][3]= tx; 00085 T->p[1][3]= ty; 00086 T->p[2][3]= tz; 00087 T->p[3][3]= 1; 00088 00089 return (T); 00090 } /* getT2 */ 00091 00092 00093 00094 /* ________________________________________________________ 00095 | name: ExtractRPY2 | 00096 | description: Now to extract Euler Angles from T matrix | 00097 | which is in effect the homogenous transform matrix | 00098 | from base to end effector. Purpose- extracts roll,| 00099 | pitch, and yaw angles from orthogonal rotation | 00100 | matrix using J.J. Craig's algorithm(2nd ed. 1989) | 00101 | | 00102 | inputs: transformation matrix | 00103 | outputs: Returns Euler angles in x_of_link structur | 00104 |________________________________________________________| 00105 | Authors: Date: Modifications: | 00106 | unkown ?/?? Implemented | 00107 | c hacker 3/95 incorporated new x_of_link | 00108 |________________________________________________________| */ 00109 00110 void ExtractRPY2(MATRIX * T, MATRIX *x_of_link) 00111 { 00112 extern FILE *datafp; 00113 double SMALL_RPY = 0.01745; 00114 double temp1, temp2, temp3, 00115 gamma = 0, beta = 0, alpha = 0; 00116 00117 temp1 = sqrt(T->p[0][0]*T->p[0][0] + T->p[1][0]*T->p[1][0]); 00118 temp2 = - (T->p[2][0]); 00119 00120 beta = atan2(temp2, temp1); /* beta or attitude angle */ 00121 00122 if (fabs(beta - (PI / 2.0e0)) < SMALL) { 00123 gamma = ZERO; /* gamma or heading angle */ 00124 temp1 = T -> p[1][1]; 00125 temp2 = T -> p[0][1]; 00126 alpha = atan2(temp2, temp1); /* alpha or bank angle */ 00127 } 00128 00129 else if (fabs(beta + (PI / 2.0e0)) < SMALL) { 00130 gamma = ZERO; /* gamma or heading angle */ 00131 temp1 = T -> p[1][1]; 00132 temp2 = T -> p[0][1]; 00133 alpha = -atan2(temp2, temp1); /* alpha or bank angle */ 00134 } 00135 00136 else { 00137 temp3 = cos(beta); 00138 temp2 = T -> p[1][0] / temp3; 00139 temp1 = T -> p[0][0] / temp3; 00140 gamma = atan2(temp2, temp1); /* gamma or heading angle */ 00141 temp2 = T -> p[2][1] / temp3; 00142 temp1 = T -> p[2][2] / temp3; 00143 alpha = atan2(temp2, temp1); /* alpha or bank angle */ 00144 } 00145 00146 if (x_of_link->cols > 3) x_of_link -> p[Robot->NL][3] = gamma; 00147 if (x_of_link->cols > 4) x_of_link -> p[Robot->NL][4] = beta; 00148 if (x_of_link->cols > 5) x_of_link -> p[Robot->NL][5] = alpha; 00149 00150 } /* ExtractRPY2 */ 00151 00152 00153