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