Fawkes API  Fawkes Development Version
openrave_connector.h
1 
2 /***************************************************************************
3  * openrave_connector.h - Fawkes OpenRave connector interface
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. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef _PLUGINS_OPENRAVE_ASPECT_OPENRAVE_CONNECTOR_H_
25 #define _PLUGINS_OPENRAVE_ASPECT_OPENRAVE_CONNECTOR_H_
26 
27 #include <core/utils/refptr.h>
28 
29 #include <string>
30 
31 namespace fawkes {
32 
33 class OpenRaveEnvironment;
34 class OpenRaveRobot;
35 class OpenRaveManipulator;
36 
37 ///\brief RefPtr to OpenRaveEnvironment
38 typedef RefPtr<OpenRaveEnvironment> OpenRaveEnvironmentPtr;
39 ///\brief RefPtr to OpenRaveRobot
41 ///\brief RefPtr to OpenRaveManipulator
43 
44 /** @class OpenRaveConnector <plugins/openrave/aspect/openrave_connector.h>
45  * Interface for a OpenRave connection creator.
46  * @author Bahram Maleki-Fard
47  */
49 {
50 public:
51  /** Virtual empty destructor. */
53  {
54  }
55 
56  /** Clone basically everything
57  * We pass pointers to pointer as parameters, so the pointers we create before calling this clone()
58  * method will point to the new objects.
59  * @param env Pointer to pointer of the copied environment
60  * @param robot Pointer to pointer of the copied robot
61  * @param manip Pointer to pointer of the copied manipulator
62  */
63  virtual void clone(OpenRaveEnvironmentPtr &env,
64  OpenRaveRobotPtr & robot,
65  OpenRaveManipulatorPtr &manip) const = 0;
66 
67  /** Start OpenRave viewer */
68  virtual void start_viewer() const = 0;
69 
70  /** Run planner on previously set target.
71  * @param robot robot to use planner on. If none is given, the currently used robot is taken
72  * @param sampling sampling time between each trajectory point (in seconds)
73  */
74  virtual void run_planner(OpenRaveRobotPtr &robot, float sampling = 0.01f) = 0;
75 
76  /** Run planner on previously set target. Uses currently active robot.
77  * @param sampling sampling time between each trajectory point (in seconds)
78  */
79  virtual void run_planner(float sampling = 0.01f) = 0;
80 
81  /** Run graspplanning script for a given target.
82  * @param target_name name of targeted object (KinBody)
83  * @param robot robot to use planner on. If none is given, the currently used robot is taken
84  */
85  virtual void run_graspplanning(const std::string &target_name, OpenRaveRobotPtr &robot) = 0;
86 
87  /** Run graspplanning script for a given target. Uses currently active robot.
88  * @param target_name name of targeted object (KinBody)
89  */
90  virtual void run_graspplanning(const std::string &target_name) = 0;
91 
92  /** Get pointer to OpenRaveEnvironment object.
93  * @return pointer
94  */
95  virtual OpenRaveEnvironmentPtr get_environment() const = 0;
96 
97  /** Get pointer to currently used OpenRaveRobot object.
98  * @return pointer
99  */
100  virtual OpenRaveRobotPtr get_active_robot() const = 0;
101 
102  /** Set robot to be used
103  * @param robot OpenRaveRobot that should be used implicitly in other methods
104  */
105  virtual void set_active_robot(OpenRaveRobotPtr robot) = 0;
106 
107  /** Set robot to be used
108  * @param robot OpenRaveRobot that should be used implicitly in other methods
109  */
110  virtual void set_active_robot(OpenRaveRobot *robot) = 0;
111 
112  /** Add a new robot to the environment, and set it as the currently active one.
113  * @param filename_robot path to robot's xml file
114  * @param autogenerate_IK if true: autogenerate IKfast IK solver for robot
115  * @return pointer to new OpenRaveRobot object
116  */
117  virtual OpenRaveRobotPtr add_robot(const std::string &filename_robot, bool autogenerate_IK) = 0;
118 
119  /** Set OpenRaveManipulator object for robot, and calculate
120  * coordinate-system offsets or set them directly.
121  * Make sure to update manip angles before calibrating!
122  * @param robot pointer to OpenRaveRobot object, explicitly set
123  * @param manip pointer to OpenRAVManipulator that is set for robot
124  * @param trans_x transition offset on x-axis
125  * @param trans_y transition offset on y-axis
126  * @param trans_z transition offset on z-axis
127  * @param calibrate decides whether to calculate offset (true )or set them directly (false; default)
128  */
129  virtual void set_manipulator(OpenRaveRobotPtr & robot,
130  OpenRaveManipulatorPtr &manip,
131  float trans_x = 0.f,
132  float trans_y = 0.f,
133  float trans_z = 0.f,
134  bool calibrate = 0) = 0;
135 
136  /** Set OpenRaveManipulator object for robot, and calculate
137  * coordinate-system offsets or set them directly.
138  * Make sure to update manip angles before calibrating!
139  * Uses default OpenRaveRobot object.
140  * @param manip pointer to OpenRAVManipulator that is set for robot
141  * @param trans_x transition offset on x-axis
142  * @param trans_y transition offset on y-axis
143  * @param trans_z transition offset on z-axis
144  * @param calibrate decides whether to calculate offset (true )or set them directly (false; default)
145  */
146  virtual void set_manipulator(OpenRaveManipulatorPtr &manip,
147  float trans_x = 0.f,
148  float trans_y = 0.f,
149  float trans_z = 0.f,
150  bool calibrate = 0) = 0;
151 
152  // object handling methods
153  /** Add an object to the environment.
154  * @param name name that should be given to that object
155  * @param filename path to xml file of that object (KinBody)
156  * @return true if successful
157  */
158  virtual bool add_object(const std::string &name, const std::string &filename) = 0;
159 
160  /** Remove object from environment.
161  * @param name name of the object
162  * @return true if successful
163  */
164  virtual bool delete_object(const std::string &name) = 0;
165 
166  /** Rename object.
167  * @param name current name of the object
168  * @param new_name new name of the object
169  * @return true if successful
170  */
171  virtual bool rename_object(const std::string &name, const std::string &new_name) = 0;
172 
173  /** Move object in the environment.
174  * Distances are given in meters
175  * @param name name of the object
176  * @param trans_x transition along x-axis
177  * @param trans_y transition along y-axis
178  * @param trans_z transition along z-axis
179  * @param robot if given, move relatively to robot (in most simple cases robot is at position (0,0,0) anyway, so this has no effect)
180  * @return true if successful
181  */
182  virtual bool move_object(const std::string &name,
183  float trans_x,
184  float trans_y,
185  float trans_z,
186  OpenRaveRobotPtr & robot) = 0;
187 
188  /** Move object in the environment. Uses currently active robot.
189  * Distances are given in meters
190  * @param name name of the object
191  * @param trans_x transition along x-axis
192  * @param trans_y transition along y-axis
193  * @param trans_z transition along z-axis
194  * @return true if successful
195  */
196  virtual bool
197  move_object(const std::string &name, float trans_x, float trans_y, float trans_z) = 0;
198 
199  /** Rotate object by a quaternion.
200  * @param name name of the object
201  * @param quat_x x value of quaternion
202  * @param quat_y y value of quaternion
203  * @param quat_z z value of quaternion
204  * @param quat_w w value of quaternion
205  * @return true if successful
206  */
207  virtual bool rotate_object(const std::string &name,
208  float quat_x,
209  float quat_y,
210  float quat_z,
211  float quat_w) = 0;
212 
213  /** Rotate object along its axis.
214  * Rotation angles should be given in radians.
215  * @param name name of the object
216  * @param rot_x 1st rotation, along x-axis
217  * @param rot_y 2nd rotation, along y-axis
218  * @param rot_z 3rd rotation, along z-axis
219  * @return true if successful
220  */
221  virtual bool rotate_object(const std::string &name, float rot_x, float rot_y, float rot_z) = 0;
222 
223  /** Attach a kinbody to the robot.
224  * @param name name of the object
225  * @param robot pointer to OpenRaveRobot that the target is set for
226  * @param manip_name name of the manipulator to attach the object to
227  * @return true if successful
228  */
229  virtual bool attach_object(const char *name, OpenRaveRobotPtr &robot, const char *manip_name) = 0;
230 
231  /** Attach a kinbody to the robot. Uses currently active robot.
232  * @param name name of the object
233  * @param manip_name name of the manipulator to attach the object to
234  * @return true if successful
235  */
236  virtual bool attach_object(const char *name, const char *manip_name) = 0;
237 
238  /** Release a kinbody from the robot.
239  * @param name name of the object
240  * @param robot pointer to OpenRaveRobot that object is released from
241  * @return true if successful
242  */
243  virtual bool release_object(const std::string &name, OpenRaveRobotPtr &robot) = 0;
244 
245  /** Release a kinbody from the robot. Uses currently active robot.
246  * @param name name of the object
247  * @return true if successful
248  */
249  virtual bool release_object(const std::string &name) = 0;
250 
251  /** Release all grabbed kinbodys from the robot.
252  * @param robot pointer to OpenRaveRobot that objects are released from
253  * @return true if successful
254  */
255  virtual bool release_all_objects(OpenRaveRobotPtr &robot) = 0;
256 
257  /** Release all grabbed kinbodys from the robot. Uses currently active robot.
258  * @return true if successful
259  */
260  virtual bool release_all_objects() = 0;
261 
262  /** Set an object as the target.
263  * Currently the object should be cylindric, and stand upright. It may
264  * also be rotated on its x-axis, but that rotation needs to be given in an argument
265  * to calculate correct position for endeffecto. This is only temporary until
266  * proper graps planning for 5DOF in OpenRave is provided.
267  * @param name name of the object
268  * @param robot pointer to OpenRaveRobot that the target is set for
269  * @param rot_x rotation of object on x-axis (radians)
270  * @return true if IK solvable
271  */
272  virtual bool
273  set_target_object(const std::string &name, OpenRaveRobotPtr &robot, float rot_x = 0) = 0;
274 };
275 
276 } // end namespace fawkes
277 
278 #endif
fawkes::OpenRaveConnector::clone
virtual void clone(OpenRaveEnvironmentPtr &env, OpenRaveRobotPtr &robot, OpenRaveManipulatorPtr &manip) const =0
Clone basically everything We pass pointers to pointer as parameters, so the pointers we create befor...
fawkes::OpenRaveManipulatorPtr
RefPtr< OpenRaveManipulator > OpenRaveManipulatorPtr
RefPtr to OpenRaveManipulator.
Definition: openrave_connector.h:46
fawkes::OpenRaveConnector::set_target_object
virtual bool set_target_object(const std::string &name, OpenRaveRobotPtr &robot, float rot_x=0)=0
Set an object as the target.
fawkes::OpenRaveConnector::release_all_objects
virtual bool release_all_objects()=0
Release all grabbed kinbodys from the robot.
fawkes::OpenRaveConnector::attach_object
virtual bool attach_object(const char *name, OpenRaveRobotPtr &robot, const char *manip_name)=0
Attach a kinbody to the robot.
fawkes::OpenRaveConnector::move_object
virtual bool move_object(const std::string &name, float trans_x, float trans_y, float trans_z, OpenRaveRobotPtr &robot)=0
Move object in the environment.
fawkes::RefPtr
RefPtr<> is a reference-counting shared smartpointer.
Definition: refptr.h:55
fawkes::OpenRaveConnector::run_graspplanning
virtual void run_graspplanning(const std::string &target_name, OpenRaveRobotPtr &robot)=0
Run graspplanning script for a given target.
fawkes::OpenRaveConnector::run_planner
virtual void run_planner(OpenRaveRobotPtr &robot, float sampling=0.01f)=0
Run planner on previously set target.
fawkes::OpenRaveConnector::add_robot
virtual OpenRaveRobotPtr add_robot(const std::string &filename_robot, bool autogenerate_IK)=0
Add a new robot to the environment, and set it as the currently active one.
fawkes::OpenRaveConnector::~OpenRaveConnector
virtual ~OpenRaveConnector()
Virtual empty destructor.
Definition: openrave_connector.h:56
fawkes::OpenRaveRobot
OpenRAVE Robot class.
Definition: robot.h:41
fawkes::OpenRaveConnector::rename_object
virtual bool rename_object(const std::string &name, const std::string &new_name)=0
Rename object.
fawkes::OpenRaveConnector::set_manipulator
virtual void set_manipulator(OpenRaveRobotPtr &robot, OpenRaveManipulatorPtr &manip, float trans_x=0.f, float trans_y=0.f, float trans_z=0.f, bool calibrate=0)=0
Set OpenRaveManipulator object for robot, and calculate coordinate-system offsets or set them directl...
fawkes
fawkes::OpenRaveConnector::add_object
virtual bool add_object(const std::string &name, const std::string &filename)=0
Add an object to the environment.
fawkes::OpenRaveRobotPtr
RefPtr< OpenRaveRobot > OpenRaveRobotPtr
RefPtr to OpenRaveRobot.
Definition: openrave_connector.h:44
fawkes::OpenRaveConnector
Definition: openrave_connector.h:52
fawkes::OpenRaveConnector::start_viewer
virtual void start_viewer() const =0
Start OpenRave viewer.
fawkes::OpenRaveConnector::get_active_robot
virtual OpenRaveRobotPtr get_active_robot() const =0
Get pointer to currently used OpenRaveRobot object.
fawkes::OpenRaveConnector::get_environment
virtual OpenRaveEnvironmentPtr get_environment() const =0
Get pointer to OpenRaveEnvironment object.
fawkes::OpenRaveConnector::set_active_robot
virtual void set_active_robot(OpenRaveRobotPtr robot)=0
Set robot to be used.
fawkes::OpenRaveConnector::release_object
virtual bool release_object(const std::string &name, OpenRaveRobotPtr &robot)=0
Release a kinbody from the robot.
fawkes::OpenRaveEnvironmentPtr
RefPtr< OpenRaveEnvironment > OpenRaveEnvironmentPtr
RefPtr to OpenRaveEnvironment.
Definition: openrave_connector.h:39
fawkes::OpenRaveConnector::rotate_object
virtual bool rotate_object(const std::string &name, float quat_x, float quat_y, float quat_z, float quat_w)=0
Rotate object by a quaternion.
fawkes::OpenRaveConnector::delete_object
virtual bool delete_object(const std::string &name)=0
Remove object from environment.