00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <IKOR/general.h>
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
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
00052
00053
00054
00055
00056
00057
00058
00059
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
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 void init_ARM()
00087 {
00088 int i,j;
00089 FILE *ARM;
00090 double temp_f;
00091 int temp_i;
00092 extern float EEzaxis;
00093 extern float EEyaxis;
00094 extern float EExaxis;
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);
00103 fscanf(ARM,"%d",&temp_i);
00104 Robot->NL = temp_i;
00105
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);
00112
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);
00120 fscanf(ARM,"%d",&temp_i);
00121 Robot->NA = temp_i;
00122
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);
00130
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);
00143
00144 temp_i = rm_blanks(ARM);
00145
00146
00147
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);
00155 EEyaxis = (EEyaxis*PI/ 180.0);
00156 EExaxis = (EExaxis*PI / 180.0);
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);
00166
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;
00177
00178
00179
00180
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