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): Matei T. Ciocarlie 00021 // 00022 // $Id: taskDispatcher.h,v 1.3 2010/04/12 20:15:30 cmatei Exp $ 00023 // 00024 //###################################################################### 00025 00026 #include "openClosePlugin.h" 00027 00028 #include "mainWindow.h" 00029 #include "graspitGUI.h" 00030 #include "world.h" 00031 #include "robot.h" 00032 00033 #include <iostream> 00034 00035 namespace openclose { 00036 00037 OpenClosePlugin::OpenClosePlugin() 00038 { 00039 std::cerr << "Open-close plugin created\n"; 00040 } 00041 00042 OpenClosePlugin::~OpenClosePlugin() 00043 { 00044 std::cerr << "Open-close plugin destroyed\n"; 00045 } 00046 00047 int OpenClosePlugin::init(int, char**) 00048 { 00049 std::cerr << "Open-close plugin initialized\n"; 00050 return 0; 00051 } 00052 00053 int OpenClosePlugin::mainLoop() 00054 { 00055 static int direction = 1.0; 00056 00057 World *world = graspItGUI->getMainWindow()->getMainWorld(); 00058 if (!world) std::cerr << "Open-close plugin main loop: no world?!?\n"; 00059 else if (!world->getCurrentHand()) std::cerr << "Open-close plugin main loop: no hand selected\n"; 00060 else world->getCurrentHand()->autoGrasp(true, direction); 00061 direction *= -1; 00062 return 0; 00063 } 00064 00065 } 00066 00067 extern "C" PLUGIN_API 00068 Plugin* createPlugin() { 00069 return new openclose::OpenClosePlugin(); 00070 } 00071 00072 extern "C" PLUGIN_API 00073 std::string getType() { 00074 return "open-close"; 00075 }