Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
openrave_thread.h
1 
2 /***************************************************************************
3  * openrave_thread.h - OpenRAVE Thread
4  *
5  * Created: Fri Feb 25 15:08:00 2011
6  * Copyright 2011 Bahram Maleki-Fard
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef __PLUGINS_OPENRAVE_OPENRAVE_THREAD_H_
24 #define __PLUGINS_OPENRAVE_OPENRAVE_THREAD_H_
25 
26 #include <plugins/openrave/aspect/openrave_connector.h>
27 #include <plugins/openrave/aspect/openrave_inifin.h>
28 
29 #include <core/threading/thread.h>
30 #include <aspect/blocked_timing.h>
31 #include <aspect/logging.h>
32 #include <aspect/configurable.h>
33 #include <aspect/aspect_provider.h>
34 
35 namespace fawkes {
36  class OpenRaveEnvironment;
37  class OpenRaveRobot;
38  class OpenRaveManipulator;
39 }
40 
42 : public fawkes::Thread,
44  public fawkes::LoggingAspect,
48 {
49  public:
51  virtual ~OpenRaveThread();
52 
53  virtual void init();
54  virtual void loop();
55  virtual void finalize();
56 
57  //for OpenRaveConnector
58  //virtual void testDebug();
60  virtual fawkes::OpenRaveRobot* get_active_robot() const;
61  virtual void set_active_robot(fawkes::OpenRaveRobot* robot);
62  virtual fawkes::OpenRaveRobot* add_robot(const std::string& filename_robot, bool autogenerate_IK);
63  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);
64  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);
65 
66  virtual void start_viewer() const;
67  virtual void run_planner(fawkes::OpenRaveRobot* = NULL, float sampling=0.01f);
68  virtual void run_graspplanning(const std::string& target_name, fawkes::OpenRaveRobot* robot = NULL);
69 
70  //handling objects; mainly from environment.h
71  virtual bool add_object(const std::string& name, const std::string& filename);
72  virtual bool delete_object(const std::string& name);
73  virtual bool rename_object(const std::string& name, const std::string& new_name);
74  virtual bool move_object(const std::string& name, float trans_x, float trans_y, float trans_z, fawkes::OpenRaveRobot* robot=NULL);
75  virtual bool rotate_object(const std::string& name, float quat_x, float quat_y, float quat_z, float quat_w);
76  virtual bool rotate_object(const std::string& name, float rot_x, float rot_y, float rot_z);
77  virtual bool set_target_object(const std::string& name, fawkes::OpenRaveRobot* robot, float rot_x = 0);
78 
79  virtual bool attach_object(const std::string& name, fawkes::OpenRaveRobot* robot=NULL);
80  virtual bool release_object(const std::string& name, fawkes::OpenRaveRobot* robot=NULL);
81  virtual bool release_all_objects(fawkes::OpenRaveRobot* robot=NULL);
82 
83  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
84  protected: virtual void run() { Thread::run(); }
85 
86  private:
87  fawkes::OpenRaveAspectIniFin __or_aspectIniFin;
88 
90  fawkes::OpenRaveRobot* __OR_robot;
91 };
92 
93 #endif
OpenRaveThread()
Constructor.
virtual void set_active_robot(fawkes::OpenRaveRobot *robot)
Set robot to be used.
virtual bool attach_object(const std::string &name, fawkes::OpenRaveRobot *robot=NULL)
Attach a kinbody to the robot.
virtual void init()
Initialize the thread.
virtual bool set_target_object(const std::string &name, fawkes::OpenRaveRobot *robot, float rot_x=0)
Set an object as the target.
virtual void run_graspplanning(const std::string &target_name, fawkes::OpenRaveRobot *robot=NULL)
Run graspplanning script for a given target.
Thread class encapsulation of pthreads.
Definition: thread.h:42
virtual bool move_object(const std::string &name, float trans_x, float trans_y, float trans_z, fawkes::OpenRaveRobot *robot=NULL)
Move object in the environment.
virtual void finalize()
Finalize the thread.
virtual ~OpenRaveThread()
Destructor.
virtual fawkes::OpenRaveEnvironment * get_environment() const
Get pointer to OpenRaveEnvironment object.
Thread aspect to use blocked timing.
virtual bool delete_object(const std::string &name)
Remove object from environment.
virtual fawkes::OpenRaveRobot * add_robot(const std::string &filename_robot, bool autogenerate_IK)
Add a new robot to the environment, and set it as the currently active one.
OpenRaveAspect initializer/finalizer.
OpenRAVE Robot class.
Definition: robot.h:41
OpenRaveEnvironment class.
Definition: environment.h:45
virtual fawkes::OpenRaveRobot * get_active_robot() const
Get pointer to currently used OpenRaveRobot object.
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)
Set OpenRaveManipulator object for robot, and calculate coordinate-system offsets or set them directl...
virtual bool rotate_object(const std::string &name, float quat_x, float quat_y, float quat_z, float quat_w)
Rotate object by a quaternion.
virtual bool release_object(const std::string &name, fawkes::OpenRaveRobot *robot=NULL)
Release a kinbody from the robot.
Thread aspect to log output.
Definition: logging.h:35
Class containing information about all manipulator motors.
Definition: manipulator.h:35
const char * name() const
Get name of thread.
Definition: thread.h:95
Thread aspect provide a new aspect.
Thread aspect to access configuration data.
Definition: configurable.h:35
virtual void run()
Stub to see name in backtrace for easier debugging.
Interface for a OpenRave connection creator.
virtual void start_viewer() const
Start Viewer.
virtual void loop()
Code to execute in the thread.
virtual bool rename_object(const std::string &name, const std::string &new_name)
Rename object.
OpenRAVE Thread.
virtual void run_planner(fawkes::OpenRaveRobot *=NULL, float sampling=0.01f)
Run planner on previously set target.
virtual bool add_object(const std::string &name, const std::string &filename)
Add an object to the environment.
virtual bool release_all_objects(fawkes::OpenRaveRobot *robot=NULL)
Release all grabbed kinbodys from the robot.