|
Fast Research Interface Library
Manual and Documentation
|
00001 // ---------------------- Doxygen info ---------------------- 00051 // ---------------------------------------------------------- 00052 // For a convenient reading of this file's source code, 00053 // please use a tab width of four characters. 00054 // ---------------------------------------------------------- 00055 00056 00057 #include <FastResearchInterface.h> 00058 #include <pthread.h> 00059 #include <friComm.h> 00060 00061 00062 // **************************************************************** 00063 // GetFRIMode() 00064 // 00065 unsigned int FastResearchInterface::GetFRIMode(void) 00066 { 00067 unsigned int ReturnValue = false; 00068 00069 pthread_mutex_lock(&(this->MutexForControlData)); 00070 ReturnValue = this->ReadData.intf.state; 00071 pthread_mutex_unlock(&(this->MutexForControlData)); 00072 00073 return(ReturnValue); 00074 } 00075 00076 // **************************************************************** 00077 // GetCurrentControlScheme() 00078 // 00079 unsigned int FastResearchInterface::GetCurrentControlScheme(void) 00080 { 00081 unsigned int ResultValue = 0; 00082 00083 pthread_mutex_lock(&(this->MutexForControlData)); 00084 ResultValue = this->ReadData.robot.control; 00085 pthread_mutex_unlock(&(this->MutexForControlData)); 00086 00087 switch (ResultValue) 00088 { 00089 case FRI_CTRL_POSITION : 00090 return(FastResearchInterface::JOINT_POSITION_CONTROL); 00091 break; 00092 case FRI_CTRL_CART_IMP: 00093 return(FastResearchInterface::CART_IMPEDANCE_CONTROL); 00094 break; 00095 case FRI_CTRL_JNT_IMP: 00096 return(FastResearchInterface::JOINT_IMPEDANCE_CONTROL); 00097 break; 00098 } 00099 00100 return(0); 00101 } 00102 00103 00104 // **************************************************************** 00105 // IsRobotArmPowerOn() 00106 // 00107 bool FastResearchInterface::IsRobotArmPowerOn(void) 00108 { 00109 bool ReturnValue = false; 00110 00111 pthread_mutex_lock(&(this->MutexForControlData)); 00112 ReturnValue = (this->ReadData.robot.power != 0); 00113 pthread_mutex_unlock(&(this->MutexForControlData)); 00114 00115 return(ReturnValue); 00116 } 00117 00118 00119 // **************************************************************** 00120 // DoesAnyDriveSignalAnError() 00121 // 00122 bool FastResearchInterface::DoesAnyDriveSignalAnError(void) 00123 { 00124 bool ReturnValue = false; 00125 00126 pthread_mutex_lock(&(this->MutexForControlData)); 00127 ReturnValue = (this->ReadData.robot.error != 0); 00128 pthread_mutex_unlock(&(this->MutexForControlData)); 00129 00130 return(ReturnValue); 00131 } 00132 00133 00134 // **************************************************************** 00135 // DoesAnyDriveSignalAWarning() 00136 // 00137 bool FastResearchInterface::DoesAnyDriveSignalAWarning(void) 00138 { 00139 bool ReturnValue = 0.0; 00140 00141 pthread_mutex_lock(&(this->MutexForControlData)); 00142 ReturnValue = (this->ReadData.robot.warning != 0); 00143 pthread_mutex_unlock(&(this->MutexForControlData)); 00144 00145 return(ReturnValue); 00146 } 00147 00148 00149 // **************************************************************** 00150 // GetDriveTemperatures() 00151 // 00152 void FastResearchInterface::GetDriveTemperatures(float *Temperatures) 00153 { 00154 unsigned int i = 0; 00155 00156 pthread_mutex_lock(&(this->MutexForControlData)); 00157 for (i = 0; i < LBR_MNJ; i++) 00158 { 00159 Temperatures[i] = this->ReadData.robot.temperature[i]; 00160 } 00161 pthread_mutex_unlock(&(this->MutexForControlData)); 00162 00163 return; 00164 } 00165 00166 00167 // **************************************************************** 00168 // GetKRLBoolValues() 00169 // 00170 void FastResearchInterface::GetKRLBoolValues(bool *KRLBoolValues) 00171 { 00172 unsigned int i = 0; 00173 00174 pthread_mutex_lock(&(this->MutexForControlData)); 00175 for (i = 0; i < FRI_USER_SIZE; i++) 00176 { 00177 KRLBoolValues[i] = ((this->ReadData.krl.boolData & (1 << i)) != 0); 00178 } 00179 pthread_mutex_unlock(&(this->MutexForControlData)); 00180 00181 return; 00182 } 00183 00184 00185 // **************************************************************** 00186 // GetKRLIntValues() 00187 // 00188 void FastResearchInterface::GetKRLIntValues(int *KRLIntValues) 00189 { 00190 unsigned int i = 0; 00191 00192 pthread_mutex_lock(&(this->MutexForControlData)); 00193 for (i = 0; i < FRI_USER_SIZE; i++) 00194 { 00195 KRLIntValues[i] = this->ReadData.krl.intData[i]; 00196 } 00197 pthread_mutex_unlock(&(this->MutexForControlData)); 00198 00199 return; 00200 } 00201 00202 00203 // **************************************************************** 00204 // GetKRLFloatValues() 00205 // 00206 void FastResearchInterface::GetKRLFloatValues(float *KRLFloatValues) 00207 { 00208 unsigned int i = 0; 00209 00210 pthread_mutex_lock(&(this->MutexForControlData)); 00211 for (i = 0; i < FRI_USER_SIZE; i++) 00212 { 00213 KRLFloatValues[i] = this->ReadData.krl.realData[i]; 00214 } 00215 pthread_mutex_unlock(&(this->MutexForControlData)); 00216 00217 return; 00218 } 00219 00220 00221 // **************************************************************** 00222 // GetKRLBoolValue() 00223 // 00224 bool FastResearchInterface::GetKRLBoolValue(const unsigned int &Index) 00225 { 00226 bool ReturnValue = false; 00227 00228 pthread_mutex_lock(&(this->MutexForControlData)); 00229 ReturnValue = ((this->ReadData.krl.boolData & (1 << Index)) != 0); 00230 pthread_mutex_unlock(&(this->MutexForControlData)); 00231 00232 return(ReturnValue); 00233 } 00234 00235 00236 // **************************************************************** 00237 // GetKRLIntValue() 00238 // 00239 int FastResearchInterface::GetKRLIntValue(const unsigned int &Index) 00240 { 00241 int ReturnValue = 0; 00242 00243 pthread_mutex_lock(&(this->MutexForControlData)); 00244 ReturnValue = this->ReadData.krl.intData[Index]; 00245 pthread_mutex_unlock(&(this->MutexForControlData)); 00246 00247 return(ReturnValue); 00248 } 00249 00250 00251 // **************************************************************** 00252 // GetKRLFloatValue() 00253 // 00254 float FastResearchInterface::GetKRLFloatValue(const unsigned int &Index) 00255 { 00256 float ReturnValue = 0.0; 00257 00258 pthread_mutex_lock(&(this->MutexForControlData)); 00259 ReturnValue = this->ReadData.krl.realData[Index]; 00260 pthread_mutex_unlock(&(this->MutexForControlData)); 00261 00262 return(ReturnValue); 00263 } 00264 00265 00266 // **************************************************************** 00267 // GetCurrentJacobianMatrix() 00268 // 00269 void FastResearchInterface::GetCurrentJacobianMatrix(float **JacobianMatrix) 00270 { 00271 unsigned int i = 0 00272 , j = 0; 00273 00274 pthread_mutex_lock(&(this->MutexForControlData)); 00275 for (i = 0; i < FRI_CART_VEC; i++) 00276 { 00277 for (j = 0; j < LBR_MNJ; j++) 00278 { 00279 //JacobianMatrix[i][j] = this->ReadData.data.jacobian[(i==3)?(5):((i==5)?(3):(i))*LBR_MNJ+j]; 00280 JacobianMatrix[i][j] = this->ReadData.data.jacobian[i*LBR_MNJ+j]; 00281 } 00282 } 00283 pthread_mutex_unlock(&(this->MutexForControlData)); 00284 00285 return; 00286 } 00287 00288 00289 // **************************************************************** 00290 // GetCurrentMassMatrix() 00291 // 00292 void FastResearchInterface::GetCurrentMassMatrix(float **MassMatrix) 00293 { 00294 unsigned int i = 0 00295 , j = 0; 00296 00297 pthread_mutex_lock(&(this->MutexForControlData)); 00298 for (i = 0; i < LBR_MNJ; i++) 00299 { 00300 for (j = 0; j < LBR_MNJ; j++) 00301 { 00302 MassMatrix[i][j] = this->ReadData.data.massMatrix[i*LBR_MNJ+j]; 00303 } 00304 } 00305 pthread_mutex_unlock(&(this->MutexForControlData)); 00306 00307 return; 00308 } 00309 00310 00311 // **************************************************************** 00312 // GetCurrentGravityVector() 00313 // 00314 void FastResearchInterface::GetCurrentGravityVector(float *GravityVector) 00315 { 00316 unsigned int i = 0; 00317 00318 pthread_mutex_lock(&(this->MutexForControlData)); 00319 for (i = 0; i < LBR_MNJ; i++) 00320 { 00321 GravityVector[i] = this->ReadData.data.gravity[i]; 00322 } 00323 pthread_mutex_unlock(&(this->MutexForControlData)); 00324 00325 return; 00326 } 00327 00328 00329 // **************************************************************** 00330 // IsMachineOK() 00331 // 00332 bool FastResearchInterface::IsMachineOK(void) 00333 { 00334 bool ReturnValue = false; 00335 00336 pthread_mutex_lock(&(this->MutexForControlData)); 00337 ReturnValue = ( (this->ReadData.intf.state == FRI_STATE_CMD) 00338 && (this->ReadData.robot.power != 0) 00339 && (this->ReadData.robot.error == 0) ); 00340 pthread_mutex_unlock(&(this->MutexForControlData)); 00341 00342 return(ReturnValue); 00343 } 00344 00345