00001 //###################################################################### 00002 // 00003 // GraspIt! 00004 // Copyright (C) 2002-2009 Columbia University in the City of New York. 00005 // All rights reserved. 00006 // 00007 // GraspIt! is free software: you can redistribute it and/or modify 00008 // it under the terms of the GNU General Public License as published by 00009 // the Free Software Foundation, either version 3 of the License, or 00010 // (at your option) any later version. 00011 // 00012 // GraspIt! is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License 00018 // along with GraspIt!. If not, see <http://www.gnu.org/licenses/>. 00019 // 00020 // Author(s): Andrew T. Miller and Matei T. Ciocarlie 00021 // 00022 // $Id: barrett.cpp,v 1.15 2009/06/17 21:06:37 saint Exp $ 00023 // 00024 //###################################################################### 00025 00030 #include <QTextStream> 00031 00032 #include "barrett.h" 00033 #include "world.h" 00034 00035 #ifdef HARDWARE_LIB 00036 #include "BarrettHand.h" 00037 #include "BarrettHandThread.h" 00038 #endif 00039 00040 //#define GRASPITDBG 00041 #include "debug.h" 00042 00043 Barrett::~Barrett() 00044 { 00045 #ifdef HARDWARE_LIB 00046 if (mRealHand) delete mRealHand; 00047 #endif 00048 } 00049 00050 int 00051 Barrett::loadFromXml(const TiXmlElement* root,QString rootPath) 00052 { 00053 if (Robot::loadFromXml(root, rootPath) == FAILURE) return FAILURE; 00054 mRealHand = NULL; 00055 return SUCCESS; 00056 } 00057 00061 BarrettHand* 00062 Barrett::getRealHand() 00063 { 00064 #ifdef HARDWARE_LIB 00065 if (mRealHand) return mRealHand; 00066 00067 //single threaded version 00068 //mRealHand = new BarrettHand(); 00069 //mRealHand->SetMode(BarrettHand::MODE_RETURN); 00070 00071 //multi-threaded version 00072 mRealHand = new BarrettHandThread(); 00073 ((BarrettHandThread*)mRealHand)->startThread(); 00074 00075 return mRealHand; 00076 #else 00077 assert(0); 00078 return NULL; 00079 #endif 00080 } 00081 00087 bool 00088 Barrett::isBusy() { 00089 #ifdef HARDWARE_LIB 00090 if (mRealHand) return mRealHand->isBusy(); 00091 #endif 00092 return false; 00093 }