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