|
Fast Research Interface Library
Manual and Documentation
|
00001 // ---------------------- Doxygen info ---------------------- 00049 // ---------------------------------------------------------- 00050 // For a convenient reading of this file's source code, 00051 // please use a tab width of four characters. 00052 // ---------------------------------------------------------- 00053 00054 00055 #ifndef __FastResearchInterface__ 00056 #define __FastResearchInterface__ 00057 00058 00059 #include <Console.h> 00060 #include <DataLogging.h> 00061 #include <friComm.h> 00062 #include <pthread.h> 00063 00064 00065 // ---------------------- Doxygen info ---------------------- 00117 // ---------------------------------------------------------- 00118 class FastResearchInterface 00119 { 00120 public: 00121 00122 // ---------------------- Doxygen info ---------------------- 00169 // ---------------------------------------------------------- 00170 FastResearchInterface(const char *InitFileName); 00171 00172 00173 // ---------------------- Doxygen info ---------------------- 00197 // ---------------------------------------------------------- 00198 ~FastResearchInterface(void); 00199 00200 00201 // ---------------------- Doxygen info ---------------------- 00210 // ---------------------------------------------------------- 00211 enum LWRControlModes 00212 { 00214 JOINT_POSITION_CONTROL = 10, 00216 CART_IMPEDANCE_CONTROL = 20, 00218 JOINT_IMPEDANCE_CONTROL = 30, 00219 }; 00220 00221 00222 // ---------------------- Doxygen info ---------------------- 00308 // ---------------------------------------------------------- 00309 int StartRobot( const unsigned int &ControlMode 00310 , const float &TimeOutValueInSeconds = 120.0); 00311 00312 00313 // ---------------------- Doxygen info ---------------------- 00350 // ---------------------------------------------------------- 00351 int StopRobot(void); 00352 00353 00354 // ---------------------- Doxygen info ---------------------- 00365 // ---------------------------------------------------------- 00366 void GetMeasuredJointPositions(float *MeasuredJointPositions); 00367 00368 00369 // ---------------------- Doxygen info ---------------------- 00380 // ---------------------------------------------------------- 00381 void GetCommandedJointPositions(float *CommandedJointPositions); 00382 00383 00384 // ---------------------- Doxygen info ---------------------- 00395 // ---------------------------------------------------------- 00396 void GetCommandedJointPositionOffsets(float *CommandedJointPositionOffsets); 00397 00398 00399 // ---------------------- Doxygen info ---------------------- 00410 // ---------------------------------------------------------- 00411 void GetMeasuredJointTorques(float *MeasuredJointTorques); 00412 00413 00414 // ---------------------- Doxygen info ---------------------- 00425 // ---------------------------------------------------------- 00426 void GetEstimatedExternalJointTorques(float *EstimatedExternalJointTorques); 00427 00428 00429 // ---------------------- Doxygen info ---------------------- 00440 // ---------------------------------------------------------- 00441 void GetMeasuredCartPose(float *MeasuredCartPose); 00442 00443 00444 // ---------------------- Doxygen info ---------------------- 00455 // ---------------------------------------------------------- 00456 void GetCommandedCartPose(float *CommandedCartPose); 00457 00458 00459 // ---------------------- Doxygen info ---------------------- 00470 // ---------------------------------------------------------- 00471 void GetCommandedCartPoseOffsets(float *CommandedCartPoseOffsets); 00472 00473 00474 // ---------------------- Doxygen info ---------------------- 00485 // ---------------------------------------------------------- 00486 void GetEstimatedExternalCartForcesAndTorques(float *EstimatedExternalCartForcesAndTorques); 00487 00488 00489 // ---------------------- Doxygen info ---------------------- 00503 // ---------------------------------------------------------- 00504 void SetCommandedJointPositions(const float *CommandedJointPositions); 00505 00506 00507 // ---------------------- Doxygen info ---------------------- 00521 // ---------------------------------------------------------- 00522 void SetCommandedJointTorques(const float *CommandedJointTorques); 00523 00524 00525 // ---------------------- Doxygen info ---------------------- 00539 // ---------------------------------------------------------- 00540 void SetCommandedJointStiffness(const float *CommandedJointStiffness); 00541 00542 00543 // ---------------------- Doxygen info ---------------------- 00557 // ---------------------------------------------------------- 00558 void SetCommandedJointDamping(const float *CommandedJointDamping); 00559 00560 00561 // ---------------------- Doxygen info ---------------------- 00575 // ---------------------------------------------------------- 00576 void SetCommandedCartPose(const float *CommandedCartPose); 00577 00578 00579 // ---------------------- Doxygen info ---------------------- 00593 // ---------------------------------------------------------- 00594 void SetCommandedCartForcesAndTorques(const float *CartForcesAndTorques); 00595 00596 00597 // ---------------------- Doxygen info ---------------------- 00611 // ---------------------------------------------------------- 00612 void SetCommandedCartStiffness(const float *CommandedCartStiffness); 00613 00614 00615 // ---------------------- Doxygen info ---------------------- 00629 // ---------------------------------------------------------- 00630 void SetCommandedCartDamping(const float *CommandedCartDamping); 00631 00632 00633 // ---------------------- Doxygen info ---------------------- 00647 // ---------------------------------------------------------- 00648 unsigned int GetFRIMode(void); 00649 00650 00651 // ---------------------- Doxygen info ---------------------- 00665 // ---------------------------------------------------------- 00666 unsigned int GetCurrentControlScheme(void); 00667 00668 00669 // ---------------------- Doxygen info ---------------------- 00682 // ---------------------------------------------------------- 00683 bool IsRobotArmPowerOn(void); 00684 00685 00686 // ---------------------- Doxygen info ---------------------- 00699 // ---------------------------------------------------------- 00700 bool DoesAnyDriveSignalAnError(void); 00701 00702 00703 // ---------------------- Doxygen info ---------------------- 00716 // ---------------------------------------------------------- 00717 bool DoesAnyDriveSignalAWarning(void); 00718 00719 00720 // ---------------------- Doxygen info ---------------------- 00731 // ---------------------------------------------------------- 00732 void GetDriveTemperatures(float *Temperatures); 00733 00734 00735 // ---------------------- Doxygen info ---------------------- 00752 // ---------------------------------------------------------- 00753 void GetCurrentJacobianMatrix(float **JacobianMatrix); 00754 00755 00756 // ---------------------- Doxygen info ---------------------- 00773 // ---------------------------------------------------------- 00774 void GetCurrentMassMatrix(float **MassMatrix); 00775 00776 00777 // ---------------------- Doxygen info ---------------------- 00794 // ---------------------------------------------------------- 00795 void GetCurrentGravityVector(float *GravityVector); 00796 00797 00798 // ---------------------- Doxygen info ---------------------- 00809 // ---------------------------------------------------------- 00810 float GetFRICycleTime(void); 00811 00812 00813 // ---------------------- Doxygen info ---------------------- 00828 // ---------------------------------------------------------- 00829 int GetCommunicationTimingQuality(void); 00830 00831 00832 // ---------------------- Doxygen info ---------------------- 00843 // ---------------------------------------------------------- 00844 float GetUDPAnswerRate(void); 00845 00846 00847 // ---------------------- Doxygen info ---------------------- 00858 // ---------------------------------------------------------- 00859 float GetUDPLatencyInSeconds(void); 00860 00861 00862 // ---------------------- Doxygen info ---------------------- 00873 // ---------------------------------------------------------- 00874 float GetUDPJitterInSeconds(void); 00875 00876 00877 // ---------------------- Doxygen info ---------------------- 00888 // ---------------------------------------------------------- 00889 float GetUDPPackageLossRate(void); 00890 00891 00892 // ---------------------- Doxygen info ---------------------- 00903 // ---------------------------------------------------------- 00904 unsigned int GetNumberOfMissedUDPPackages(void); 00905 00906 00907 // ---------------------- Doxygen info ---------------------- 00921 // ---------------------------------------------------------- 00922 unsigned int GetValueOfKRCSequenceCounter(void); 00923 00924 00925 // ---------------------- Doxygen info ---------------------- 00946 // ---------------------------------------------------------- 00947 void GetKRLBoolValues(bool *KRLBoolValues); 00948 00949 00950 // ---------------------- Doxygen info ---------------------- 00965 // ---------------------------------------------------------- 00966 void GetKRLIntValues(int *KRLIntValues); 00967 00968 00969 // ---------------------- Doxygen info ---------------------- 00984 // ---------------------------------------------------------- 00985 void GetKRLFloatValues(float *KRLFloatValues); 00986 00987 00988 // ---------------------- Doxygen info ---------------------- 01010 // ---------------------------------------------------------- 01011 bool GetKRLBoolValue(const unsigned int &Index); 01012 01013 01014 // ---------------------- Doxygen info ---------------------- 01030 // ---------------------------------------------------------- 01031 int GetKRLIntValue(const unsigned int &Index); 01032 01033 01034 // ---------------------- Doxygen info ---------------------- 01050 // ---------------------------------------------------------- 01051 float GetKRLFloatValue(const unsigned int &Index); 01052 01053 01054 // ---------------------- Doxygen info ---------------------- 01075 // ---------------------------------------------------------- 01076 void SetKRLBoolValues(const bool *KRLBoolValues); 01077 01078 01079 // ---------------------- Doxygen info ---------------------- 01094 // ---------------------------------------------------------- 01095 void SetKRLIntValues(const int *KRLIntValues); 01096 01097 01098 // ---------------------- Doxygen info ---------------------- 01113 // ---------------------------------------------------------- 01114 void SetKRLFloatValues(const float *KRLFloatValues); 01115 01116 01117 // ---------------------- Doxygen info ---------------------- 01141 // ---------------------------------------------------------- 01142 void SetKRLBoolValue( const unsigned int &Index 01143 , const bool &Value ); 01144 01145 01146 // ---------------------- Doxygen info ---------------------- 01164 // ---------------------------------------------------------- 01165 void SetKRLIntValue( const unsigned int &Index 01166 , const int &Value ); 01167 01168 01169 // ---------------------- Doxygen info ---------------------- 01187 // ---------------------------------------------------------- 01188 void SetKRLFloatValue( const unsigned int &Index 01189 , const float &Value ); 01190 01191 01192 // ---------------------- Doxygen info ---------------------- 01235 // ---------------------------------------------------------- 01236 int WaitForKRCTick(const unsigned int &TimeoutValueInMicroSeconds = 0); 01237 01238 01239 // ---------------------- Doxygen info ---------------------- 01281 // ---------------------------------------------------------- 01282 int WaitForTimerTick(const unsigned int &TimeoutValueInMicroSeconds = 0); 01283 01284 01285 // ---------------------- Doxygen info ---------------------- 01306 // ---------------------------------------------------------- 01307 bool IsMachineOK(void); 01308 01309 01310 // ---------------------- Doxygen info ---------------------- 01324 // ---------------------------------------------------------- 01325 const char* GetCompleteRobotStateAndInformation(void); 01326 01327 01328 // ---------------------- Doxygen info ---------------------- 01335 // ---------------------------------------------------------- 01336 int printf(const char* Format, ...); 01337 01338 01339 // ---------------------- Doxygen info ---------------------- 01379 // ---------------------------------------------------------- 01380 int PrepareLogging(const char *FileIdentifier = NULL); 01381 01382 01383 // ---------------------- Doxygen info ---------------------- 01415 // ---------------------------------------------------------- 01416 int StartLogging(void); 01417 01418 01419 // ---------------------- Doxygen info ---------------------- 01454 // ---------------------------------------------------------- 01455 int StopLogging(void); 01456 01457 01458 // ---------------------- Doxygen info ---------------------- 01493 // ---------------------------------------------------------- 01494 int WriteLoggingDataFile(void); 01495 01496 01497 protected: 01498 01499 01500 // ---------------------- Doxygen info ---------------------- 01517 // ---------------------------------------------------------- 01518 int ReadInitFile(const char *InitFileName); 01519 01520 01521 // ---------------------- Doxygen info ---------------------- 01551 // ---------------------------------------------------------- 01552 int SetControlScheme(const unsigned int &ControlScheme); 01553 01554 01555 // ---------------------- Doxygen info ---------------------- 01576 // ---------------------------------------------------------- 01577 static void *TimerThreadMain(void *ThreadArgument); 01578 01579 01580 // ---------------------- Doxygen info ---------------------- 01597 // ---------------------------------------------------------- 01598 static void *KRCCommunicationThreadMain(void *ThreadArgument); 01599 01600 01601 // ---------------------- Doxygen info ---------------------- 01611 // ---------------------------------------------------------- 01612 enum CalledLoggingMethod 01613 { 01614 PrepareLoggingCalled = 1, 01615 StartLoggingCalled = 2, 01616 StopLoggingCalled = 3, 01617 WriteLoggingDataFileCalled = 4 01618 }; 01619 01620 01621 // ---------------------- Doxygen info ---------------------- 01626 // ---------------------------------------------------------- 01627 bool TerminateTimerThread; 01628 01629 01630 // ---------------------- Doxygen info ---------------------- 01635 // ---------------------------------------------------------- 01636 bool TimerFlag; 01637 01638 01639 // ---------------------- Doxygen info ---------------------- 01644 // ---------------------------------------------------------- 01645 bool TerminateKRCCommunicationThread; 01646 01647 01648 // ---------------------- Doxygen info ---------------------- 01653 // ---------------------------------------------------------- 01654 bool NewDataFromKRCReceived; 01655 01656 01657 // ---------------------- Doxygen info ---------------------- 01662 // ---------------------------------------------------------- 01663 bool LoggingIsActive; 01664 01665 01666 // ---------------------- Doxygen info ---------------------- 01675 // ---------------------------------------------------------- 01676 bool ThreadCreated; 01677 01678 01679 // ---------------------- Doxygen info ---------------------- 01684 // ---------------------------------------------------------- 01685 CalledLoggingMethod LoggingState; 01686 01687 01688 // ---------------------- Doxygen info ---------------------- 01695 // ---------------------------------------------------------- 01696 char *RobotName; 01697 01698 01699 // ---------------------- Doxygen info ---------------------- 01706 // ---------------------------------------------------------- 01707 char *LoggingPath; 01708 01709 01710 // ---------------------- Doxygen info ---------------------- 01717 // ---------------------------------------------------------- 01718 char *LoggingFileName; 01719 01720 01721 // ---------------------- Doxygen info ---------------------- 01728 // ---------------------------------------------------------- 01729 char *RobotStateString; 01730 01731 01732 // ---------------------- Doxygen info ---------------------- 01739 // ---------------------------------------------------------- 01740 unsigned int CurrentControlScheme; 01741 01742 01743 // ---------------------- Doxygen info ---------------------- 01749 // ---------------------------------------------------------- 01750 unsigned int NumberOfLoggingFileEntries; 01751 01752 01753 // ---------------------- Doxygen info ---------------------- 01761 // ---------------------------------------------------------- 01762 unsigned int PriorityKRCCommunicationThread; 01763 01764 01765 // ---------------------- Doxygen info ---------------------- 01773 // ---------------------------------------------------------- 01774 unsigned int PriorityTimerThread; 01775 01776 01777 // ---------------------- Doxygen info ---------------------- 01783 // ---------------------------------------------------------- 01784 unsigned int PriorityMainThread; 01785 01786 01787 // ---------------------- Doxygen info ---------------------- 01795 // ---------------------------------------------------------- 01796 unsigned int PriorityOutputConsoleThread; 01797 01798 01799 // ---------------------- Doxygen info ---------------------- 01806 // ---------------------------------------------------------- 01807 double CycleTime; 01808 01809 01810 // ---------------------- Doxygen info ---------------------- 01815 // ---------------------------------------------------------- 01816 pthread_mutex_t MutexForControlData; 01817 01818 01819 // ---------------------- Doxygen info ---------------------- 01824 // ---------------------------------------------------------- 01825 pthread_mutex_t MutexForCondVarForTimer; 01826 01827 01828 // ---------------------- Doxygen info ---------------------- 01833 // ---------------------------------------------------------- 01834 pthread_mutex_t MutexForLogging; 01835 01836 01837 // ---------------------- Doxygen info ---------------------- 01845 // ---------------------------------------------------------- 01846 pthread_mutex_t MutexForThreadCreation; 01847 01848 01849 // ---------------------- Doxygen info ---------------------- 01855 // ---------------------------------------------------------- 01856 pthread_cond_t CondVarForTimer; 01857 01858 01859 // ---------------------- Doxygen info ---------------------- 01865 // ---------------------------------------------------------- 01866 pthread_cond_t CondVarForDataReceptionFromKRC; 01867 01868 01869 // ---------------------- Doxygen info ---------------------- 01877 // ---------------------------------------------------------- 01878 pthread_cond_t CondVarForThreadCreation; 01879 01880 01881 // ---------------------- Doxygen info ---------------------- 01886 // ---------------------------------------------------------- 01887 pthread_t KRCCommunicationThread; 01888 01889 01890 // ---------------------- Doxygen info ---------------------- 01895 // ---------------------------------------------------------- 01896 pthread_t TimerThread; 01897 01898 01899 // ---------------------- Doxygen info ---------------------- 01904 // ---------------------------------------------------------- 01905 pthread_t MainThread; 01906 01907 01908 // ---------------------- Doxygen info ---------------------- 01913 // ---------------------------------------------------------- 01914 Console *OutputConsole; 01915 01916 01917 // ---------------------- Doxygen info ---------------------- 01922 // ---------------------------------------------------------- 01923 DataLogging *DataLogger; 01924 01925 01926 // ---------------------- Doxygen info ---------------------- 01931 // ---------------------------------------------------------- 01932 tFriMsrData ReadData; 01933 01934 01935 // ---------------------- Doxygen info ---------------------- 01940 // ---------------------------------------------------------- 01941 tFriCmdData CommandData; 01942 01943 }; // class FastResearchInterface 01944 01945 #endif