libmove3d
3.13.0
|
00001 #ifndef __DLROBJECT_H__ 00002 #define __DLROBJECT_H__ 00003 #include <iostream> 00004 #include <vector> 00005 #include "P3d-pkg.h" 00006 #include "device.h" 00007 00008 #include "p3d_matrix.h" 00009 00010 class DlrObject { 00011 public: 00012 //Constructors and destructors 00013 DlrObject(std::string name); 00014 DlrObject(std::string name, std::vector<double> rightAttachFrame, std::vector<double> leftAttachFrame); 00015 virtual ~DlrObject(); 00016 //setters and getters 00017 void setRightAttachFrame(std::vector<double> attachFrame); 00018 double* getRightAttachFrame(); 00019 void setLeftAttachFrame(std::vector<double> attachFrame); 00020 double* getLeftAttachFrame(); 00021 void addPosition(std::vector<double>pos, int id); 00022 double* getPosition(int id); 00023 p3d_rob* getRobot(); 00024 p3d_obj* getObject(); 00025 int isAStaticOrMobileObject(); 00026 protected: 00027 void setObjectOrRobot(std::string name); 00028 double* convertFrame(std::vector<double> vec); 00029 void convertDlrGraspFrameToMove3d(double* array); 00030 private: 00031 std::string _name; 00032 p3d_obj* _m3dObject; 00033 p3d_rob* _m3dRobot; 00034 std::vector<double*> _positions; 00035 double* _rightAttFrame; 00036 double* _leftAttFrame; 00037 //static members 00038 public: 00039 static void convertArrayToP3d_matrix4(double* array, p3d_matrix4 mat){ 00040 for(int i = 0; i < 4; i++){ 00041 for(int j = 0; j < 4; j++){ 00042 if(array){ 00043 mat[i][j] = array[i*4+j]; 00044 }else{ 00045 mat[i][j] = 0; 00046 } 00047 } 00048 } 00049 } 00050 static void convertDlrToMove3dFrame(double* array){ 00051 p3d_matrix4 dlrMat, move3dMat, tmp; 00052 p3d_matrix4 transform = {{0, -1, 0, 0},{0, 0, 1, 0},{-1, 0, 0, 0},{0, 0, 0, 1}}; 00053 convertArrayToP3d_matrix4(array, dlrMat); 00054 p3d_matMultXform(dlrMat, transform, tmp); 00055 p3d_matInvertXform(tmp, move3dMat); 00056 for(int i = 0; i < 4; i++){ 00057 for(int j = 0; j < 4; j++){ 00058 array[i*4+j] = move3dMat[i][j]; 00059 } 00060 } 00061 } 00062 }; 00063 00064 #endif