|
Fast Research Interface Library
Manual and Documentation
|
00001 // ---------------------- Doxygen info ---------------------- 00050 // ---------------------------------------------------------- 00051 // For a convenient reading of this file's source code, 00052 // please use a tab width of four characters. 00053 // ---------------------------------------------------------- 00054 00055 00056 #include <FastResearchInterface.h> 00057 #include <Console.h> 00058 #include <errno.h> 00059 #include <OSAbstraction.h> 00060 00061 #define TIMEOUT_VALUE_IN_SECONDS_TO_REACH_MONITOR_MODE 10.0 00062 00063 00064 // **************************************************************** 00065 // StartRobot() 00066 // 00067 int FastResearchInterface::StopRobot(void) 00068 { 00069 unsigned int DataTelegramCounter = 0; 00070 00071 int ResultValue = 0; 00072 00073 // The KRL program running on the robot controller waits for a 00074 // integer value change at position 15 (i.e., 16 in KRL). 00075 // A value of 20 lets the KRL program call friStop() 00076 this->SetKRLIntValue(15, 20); 00077 00078 // wait for the next data telegram of the KRC unit 00079 pthread_mutex_lock(&(this->MutexForControlData)); 00080 this->NewDataFromKRCReceived = false; 00081 pthread_mutex_unlock(&(this->MutexForControlData)); 00082 ResultValue = this->WaitForKRCTick(((unsigned int)(this->CycleTime * 3000000.0))); 00083 00084 if (ResultValue != EOK) 00085 { 00086 this->OutputConsole->printf("FastResearchInterface::StopRobot(): ERROR, the KRC unit does not respond anymore. Probably, the FRI was closed or there is no UDP connection anymore."); 00087 return(ENOTCONN); 00088 } 00089 00090 // wait until we are in monitor mode again 00091 while ( ((double)DataTelegramCounter * this->CycleTime < TIMEOUT_VALUE_IN_SECONDS_TO_REACH_MONITOR_MODE) 00092 && (this->GetFRIMode() != FRI_STATE_MON ) ) 00093 { 00094 ResultValue = this->WaitForKRCTick(((unsigned int)(this->CycleTime * 3000000.0))); 00095 00096 if (ResultValue != EOK) 00097 { 00098 this->OutputConsole->printf("FastResearchInterface::StartRobot(): ERROR, the KRC unit does not respond anymore. Probably, the FRI was closed or there is no UDP connection anymore."); 00099 return(ENOTCONN); 00100 } 00101 00102 DataTelegramCounter++; 00103 } 00104 00105 // wait until the KRC unit ready for the reception of the next command 00106 while ( ((double)DataTelegramCounter * this->CycleTime < TIMEOUT_VALUE_IN_SECONDS_TO_REACH_MONITOR_MODE) 00107 && (this->GetKRLIntValue(15) != 10) ) 00108 { 00109 ResultValue = this->WaitForKRCTick(((unsigned int)(this->CycleTime * 3000000.0))); 00110 00111 if (ResultValue != EOK) 00112 { 00113 this->OutputConsole->printf("FastResearchInterface::StartRobot(): ERROR, the KRC unit does not respond anymore. Probably, the FRI was closed or there is no UDP connection anymore."); 00114 return(ENOTCONN); 00115 } 00116 00117 DataTelegramCounter++; 00118 } 00119 00120 if ((double)DataTelegramCounter * this->CycleTime < TIMEOUT_VALUE_IN_SECONDS_TO_REACH_MONITOR_MODE) 00121 { 00122 delay(12); // KUKA interpolation cycle time 00123 return(EOK); 00124 } 00125 else 00126 { 00127 return(ETIME); 00128 } 00129 } 00130