Fawkes API  Fawkes Development Version
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 "types.h"
27 
28 #include <plugins/openrave/aspect/openrave_connector.h>
29 #include <plugins/openrave/aspect/openrave_inifin.h>
30 
31 #include <core/threading/thread.h>
32 #include <aspect/blocked_timing.h>
33 #include <aspect/logging.h>
34 #include <aspect/configurable.h>
35 #include <aspect/aspect_provider.h>
36 
38 : public fawkes::Thread,
40  public fawkes::LoggingAspect,
44 {
45  public:
47  virtual ~OpenRaveThread();
48 
49  virtual void init();
50  virtual void loop();
51  virtual void finalize();
52 
53  //for OpenRaveConnector
54  //virtual void testDebug();
55  virtual void clone(fawkes::OpenRaveEnvironmentPtr& env,
57  fawkes::OpenRaveManipulatorPtr& manip) const;
58 
61  virtual void set_active_robot(fawkes::OpenRaveRobotPtr robot);
62  virtual void set_active_robot(fawkes::OpenRaveRobot* robot);
63  virtual fawkes::OpenRaveRobotPtr add_robot(const std::string& filename_robot, bool autogenerate_IK);
64 
66  float trans_x=0.f, float trans_y=0.f, float trans_z=0.f, bool calibrate=0);
68  float trans_x=0.f, float trans_y=0.f, float trans_z=0.f, bool calibrate=0);
69 
70  virtual void start_viewer() const;
71  virtual void run_planner(fawkes::OpenRaveRobotPtr& robot, float sampling=0.01f);
72  virtual void run_planner(float sampling=0.01f);
73  virtual void run_graspplanning(const std::string& target_name, fawkes::OpenRaveRobotPtr& robot);
74  virtual void run_graspplanning(const std::string& target_name);
75 
76  //handling objects; mainly from environment.h
77  virtual bool add_object(const std::string& name, const std::string& filename);
78  virtual bool delete_object(const std::string& name);
79  virtual bool delete_all_objects();
80  virtual bool rename_object(const std::string& name, const std::string& new_name);
81  virtual bool move_object(const std::string& name, float trans_x, float trans_y, float trans_z, fawkes::OpenRaveRobotPtr& robot);
82  virtual bool move_object(const std::string& name, float trans_x, float trans_y, float trans_z);
83  virtual bool rotate_object(const std::string& name, float quat_x, float quat_y, float quat_z, float quat_w);
84  virtual bool rotate_object(const std::string& name, float rot_x, float rot_y, float rot_z);
85  virtual bool set_target_object(const std::string& name, fawkes::OpenRaveRobotPtr& robot, float rot_x = 0);
86 
87  virtual bool attach_object(const char* name, fawkes::OpenRaveRobotPtr& robot, const char* manip_name = NULL);
88  virtual bool attach_object(const char* name, const char* manip_name = NULL);
89  virtual bool release_object(const std::string& name, fawkes::OpenRaveRobotPtr& robot);
90  virtual bool release_object(const std::string& name);
91  virtual bool release_all_objects(fawkes::OpenRaveRobotPtr& robot);
92  virtual bool release_all_objects();
93 
94  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
95  protected: virtual void run() { Thread::run(); }
96 
97  private:
98  fawkes::OpenRaveAspectIniFin __or_aspectIniFin;
99 
101  fawkes::OpenRaveRobotPtr __OR_robot;
102 };
103 
104 #endif
virtual void set_manipulator(fawkes::OpenRaveManipulatorPtr &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...
OpenRaveThread()
Constructor.
virtual void set_active_robot(fawkes::OpenRaveRobotPtr robot)
Set robot to be used.
virtual void init()
Initialize the thread.
virtual bool attach_object(const char *name, fawkes::OpenRaveRobotPtr &robot, const char *manip_name=NULL)
Attach a kinbody to the robot.
Thread class encapsulation of pthreads.
Definition: thread.h:42
virtual bool delete_all_objects()
Remove all objects from environment.
virtual void finalize()
Finalize the thread.
virtual ~OpenRaveThread()
Destructor.
virtual bool release_object(const std::string &name, fawkes::OpenRaveRobotPtr &robot)
Release a kinbody from the robot.
virtual bool move_object(const std::string &name, float trans_x, float trans_y, float trans_z, fawkes::OpenRaveRobotPtr &robot)
Move object in the environment, relatively to robot.
Thread aspect to use blocked timing.
virtual bool delete_object(const std::string &name)
Remove object from environment.
virtual void clone(fawkes::OpenRaveEnvironmentPtr &env, fawkes::OpenRaveRobotPtr &robot, fawkes::OpenRaveManipulatorPtr &manip) const
Clone basically everything We pass pointers to pointer as parameters, so the pointers we create befor...
OpenRaveAspect initializer/finalizer.
virtual bool release_all_objects()
Release all grabbed kinbodys from the robot.
OpenRAVE Robot class.
Definition: robot.h:39
virtual fawkes::OpenRaveRobotPtr get_active_robot() const
Get RefPtr to currently used OpenRaveRobot object.
virtual bool set_target_object(const std::string &name, fawkes::OpenRaveRobotPtr &robot, float rot_x=0)
Set an object as the target.
virtual void run_planner(fawkes::OpenRaveRobotPtr &robot, float sampling=0.01f)
Run planner on previously set target.
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.
const char * name() const
Get name of thread.
Definition: thread.h:95
Thread aspect to log output.
Definition: logging.h:35
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 run_graspplanning(const std::string &target_name, fawkes::OpenRaveRobotPtr &robot)
Run graspplanning script for a given target.
RefPtr<> is a reference-counting shared smartpointer.
Definition: refptr.h:49
virtual void loop()
Code to execute in the thread.
virtual void start_viewer() const
Start Viewer.
virtual bool rename_object(const std::string &name, const std::string &new_name)
Rename object.
virtual fawkes::OpenRaveEnvironmentPtr get_environment() const
Get pointer to OpenRaveEnvironment object.
OpenRAVE Thread.
virtual bool add_object(const std::string &name, const std::string &filename)
Add an object to the environment.
virtual fawkes::OpenRaveRobotPtr 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.