Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * openrave_thread.h - OpenRAVE Thread 00004 * 00005 * Created: Fri Feb 25 15:08:00 2011 00006 * Copyright 2011 Bahram Maleki-Fard 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU Library General Public License for more details. 00019 * 00020 * Read the full text in the LICENSE.GPL file in the doc directory. 00021 */ 00022 00023 #ifndef __PLUGINS_OPENRAVE_OPENRAVE_THREAD_H_ 00024 #define __PLUGINS_OPENRAVE_OPENRAVE_THREAD_H_ 00025 00026 #include <plugins/openrave/aspect/openrave_connector.h> 00027 #include <plugins/openrave/aspect/openrave_inifin.h> 00028 00029 #include <core/threading/thread.h> 00030 #include <aspect/blocked_timing.h> 00031 #include <aspect/logging.h> 00032 #include <aspect/configurable.h> 00033 #include <aspect/aspect_provider.h> 00034 00035 namespace fawkes { 00036 class OpenRaveEnvironment; 00037 class OpenRaveRobot; 00038 class OpenRaveManipulator; 00039 } 00040 00041 class OpenRaveThread 00042 : public fawkes::Thread, 00043 public fawkes::BlockedTimingAspect, 00044 public fawkes::LoggingAspect, 00045 public fawkes::ConfigurableAspect, 00046 public fawkes::AspectProviderAspect, 00047 public fawkes::OpenRaveConnector 00048 { 00049 public: 00050 OpenRaveThread(); 00051 virtual ~OpenRaveThread(); 00052 00053 virtual void init(); 00054 virtual void loop(); 00055 virtual void finalize(); 00056 00057 //for OpenRaveConnector 00058 //virtual void testDebug(); 00059 virtual fawkes::OpenRaveEnvironment* get_environment() const; 00060 virtual fawkes::OpenRaveRobot* get_active_robot() const; 00061 virtual void set_active_robot(fawkes::OpenRaveRobot* robot); 00062 virtual fawkes::OpenRaveRobot* add_robot(const std::string& filename_robot, bool autogenerate_IK); 00063 virtual void set_manipulator(fawkes::OpenRaveManipulator* manip, float trans_x=0.f, float trans_y=0.f, float trans_z=0.f, bool calibrate=0); 00064 virtual void set_manipulator(fawkes::OpenRaveRobot* robot, fawkes::OpenRaveManipulator* manip, float trans_x=0.f, float trans_y=0.f, float trans_z=0.f, bool calibrate=0); 00065 00066 virtual void start_viewer() const; 00067 virtual void run_planner(fawkes::OpenRaveRobot* = NULL, float sampling=0.01f); 00068 virtual void run_graspplanning(const std::string& target_name, fawkes::OpenRaveRobot* robot = NULL); 00069 00070 //handling objects; mainly from environment.h 00071 virtual bool add_object(const std::string& name, const std::string& filename); 00072 virtual bool delete_object(const std::string& name); 00073 virtual bool rename_object(const std::string& name, const std::string& new_name); 00074 virtual bool move_object(const std::string& name, float trans_x, float trans_y, float trans_z, fawkes::OpenRaveRobot* robot=NULL); 00075 virtual bool rotate_object(const std::string& name, float quat_x, float quat_y, float quat_z, float quat_w); 00076 virtual bool rotate_object(const std::string& name, float rot_x, float rot_y, float rot_z); 00077 virtual bool set_target_object(const std::string& name, fawkes::OpenRaveRobot* robot, float rot_x = 0); 00078 00079 virtual bool attach_object(const std::string& name, fawkes::OpenRaveRobot* robot=NULL); 00080 virtual bool release_object(const std::string& name, fawkes::OpenRaveRobot* robot=NULL); 00081 virtual bool release_all_objects(fawkes::OpenRaveRobot* robot=NULL); 00082 00083 /** Stub to see name in backtrace for easier debugging. @see Thread::run() */ 00084 protected: virtual void run() { Thread::run(); } 00085 00086 private: 00087 fawkes::OpenRaveAspectIniFin __or_aspectIniFin; 00088 00089 fawkes::OpenRaveEnvironment* __OR_env; 00090 fawkes::OpenRaveRobot* __OR_robot; 00091 }; 00092 00093 #endif