GraspTable.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *   http://www.apache.org/licenses/LICENSE-2.0
00009 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016  
00017 
00018 #ifndef __GRASP_TABLE_H__
00019 #define __GRASP_TABLE_H__
00020 
00021 #include <tinyxml.h>
00022 #include <iostream>
00023 #include <vector>
00024 
00025 #define MAX_NO_OF_OBJECTS 200
00026 
00027 
00028 class Grasp
00029 {
00030   public:
00031     Grasp(){;}
00032 
00033     std::vector<double> GetTCPPreGraspPose(){return m_TCPPreGraspPose;}
00034     void SetTCPPreGraspPose(std::vector<double> TCPPreGraspPose){m_TCPPreGraspPose = TCPPreGraspPose;}
00035 
00036     std::vector<double> GetTCPGraspPose(){return m_TCPGraspPose;}
00037     void SetTCPGraspPose(std::vector<double> TCPGraspPose){m_TCPGraspPose = TCPGraspPose;}
00038 
00040     std::vector<double>  GetHandPreGraspConfig(){return m_HandPreGraspConfig;}
00041     void SetHandPreGraspConfig(std::vector<double>  HandPreGraspConfig){m_HandPreGraspConfig=HandPreGraspConfig;}
00042 
00043     std::vector<double>  GetHandGraspConfig(){return m_HandGraspConfig;}
00044     void SetHandGraspConfig(std::vector<double>  HandGraspConfig){m_HandGraspConfig=HandGraspConfig;}
00045 
00046     std::vector<double>  GetHandOptimalGraspConfig(){return m_HandOptimalGraspConfig;}
00047     void SetHandOptimalGraspConfig(std::vector<double>  HandOptimalGraspConfig){m_HandOptimalGraspConfig=HandOptimalGraspConfig;}
00048 
00049     void SetGraspId(int graspId){m_GraspId = graspId;}
00050     int GetGraspId(){return m_GraspId;}
00051 
00052   private:
00053     std::vector<double> m_TCPGraspPose;
00054     std::vector<double> m_TCPPreGraspPose;
00055     std::vector<double> m_HandPreGraspConfig;
00056     std::vector<double> m_HandGraspConfig;
00057     std::vector<double> m_HandOptimalGraspConfig;
00058 
00059     int m_GraspId;
00060 };
00061 
00062 class GraspTableObject
00063 {
00064   public:
00065     GraspTableObject():m_GraspReadPtr(0),m_GraspWritePtr(0),m_ObjectClassId(0)
00066       {m_GraspTableObject.clear();}
00067 
00068     int Init(int size)
00069       {m_GraspTableObject.resize(size);return 0;}
00070 
00071 
00073     std::vector<Grasp*>& Get()
00074       {return m_GraspTableObject;}
00075 
00076     Grasp * GetNextGrasp()
00077     {
00078       if (m_GraspReadPtr <m_GraspWritePtr)
00079         return m_GraspTableObject[m_GraspReadPtr++];
00080       else
00081         return NULL;
00082     }
00083 
00084     Grasp * GetGrasp(unsigned int graspId)
00085     {
00086       if (graspId < m_GraspTableObject.size())
00087         return m_GraspTableObject[graspId];
00088       else
00089         return NULL;
00090     }
00091 
00092     void AddGrasp(Grasp *  grasp)
00093       {  if (m_GraspWritePtr < m_GraspTableObject.size()) m_GraspTableObject[m_GraspWritePtr++]=grasp;  }
00094 
00095     unsigned int GetObjectClassId(){  return m_ObjectClassId;  }
00096     void SetObjectClassId(unsigned int ObjectClassId){  m_ObjectClassId = ObjectClassId;  }
00097 
00098     void ResetGraspReadPtr(){  m_GraspReadPtr=0;  }
00099 
00100   private:
00101     unsigned int m_GraspReadPtr;
00102     unsigned int m_GraspWritePtr;
00103     unsigned int m_ObjectClassId;
00104     std::vector<Grasp*> m_GraspTableObject;
00105 };
00106 
00107 
00108 class GraspTable
00109 {
00110   public:
00111     GraspTable(){;}
00112 
00113     int Init(char * iniFile, unsigned int table_size=MAX_NO_OF_OBJECTS);
00114     void AddGraspTableObject(GraspTableObject * graspTableObject);
00115 
00116     Grasp * GetNextGrasp(unsigned int object_class_id);
00117     Grasp * GetGrasp(unsigned int object_class_id, unsigned int & grasp_id);
00118     void ResetReadPtr(unsigned int object_class_id);
00119 
00120   private:
00121     void ReadDoubleValue(TiXmlElement* xml, const char * tag, double * value);
00122     void ReadJoint(TiXmlElement* xml, const char * tag, std::vector<double> & values);
00123     void ReadPose(TiXmlElement* xml, const char * tag, std::vector<double> & values);
00124     int ReadFromFile(const char * filename, GraspTableObject * tableObject);
00125 
00126     std::vector<GraspTableObject*> m_GraspTable;
00127     unsigned int m_lastObjectClassId;
00128 };
00129 
00130 #endif


cob_pick_place_action
Author(s): Felix Messmer
autogenerated on Thu Jun 6 2019 21:23:15