Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
robot.h
1 
2 /***************************************************************************
3  * robot.h - Fawkes to OpenRAVE Robot Handler
4  *
5  * Created: Mon Sep 20 14:50:34 2010
6  * Copyright 2010 Bahram Maleki-Fard, AllemaniACs RoboCup Team
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_ROBOT_H
24 #define __PLUGINS_OPENRAVE_ROBOT_H
25 
26 #include "types.h"
27 
28 #include <openrave/openrave.h>
29 #include <vector>
30 
31 namespace fawkes {
32 #if 0 /* just to make Emacs auto-indent happy */
33 }
34 #endif
35 
36 class Logger;
37 class OpenRaveManipulator;
38 class OpenRaveEnvironment;
39 
40 /** OpenRAVE Robot class */
42 {
43  public:
44  OpenRaveRobot(fawkes::Logger* logger = 0);
45  OpenRaveRobot(const std::string& filename, fawkes::OpenRaveEnvironment* env, fawkes::Logger* logger = 0);
46  virtual ~OpenRaveRobot();
47 
48  // build/load robot parts
49  virtual void load(const std::string& filename, fawkes::OpenRaveEnvironment* env);
50  virtual void set_ready();
51  virtual void set_offset(float trans_x, float trans_y, float trans_z);
52  virtual void calibrate(float device_trans_x, float device_trans_y, float device_trans_z);
53  virtual void set_manipulator(fawkes::OpenRaveManipulator* manip, bool display_movements = false);
54  virtual void update_manipulator();
55  virtual void update_model();
56 
57  virtual bool attach_object(OpenRAVE::KinBodyPtr object);
58  virtual bool attach_object(const std::string& name, fawkes::OpenRaveEnvironment* env);
59  virtual bool release_object(OpenRAVE::KinBodyPtr object);
60  virtual bool release_object(const std::string& name, fawkes::OpenRaveEnvironment* env);
61  virtual bool release_all_objects();
62 
63  virtual bool set_target_rel(float trans_x, float trans_y, float trans_z, bool is_extension=false);
64  virtual bool set_target_straight(float trans_x, float trans_y, float trans_z);
65  virtual bool set_target_quat(float trans_x, float trans_y, float trans_z, float quat_w, float quat_x, float quat_y, float quat_z, bool no_offset = false);
66  virtual bool set_target_axis_angle(float trans_x, float trans_y, float trans_z, float angle, float axisX, float axisY, float axisZ, bool no_offset = false);
67  virtual bool set_target_euler(euler_rotation_t type, float trans_x, float trans_y, float trans_z, float phi, float theta, float psi, bool no_offset = false);
68  virtual bool set_target_ikparam(OpenRAVE::IkParameterization ik_param);
69  virtual void set_target_plannerparams(std::string& params);
70  virtual void set_target_angles( std::vector<float>& angles ); // just temporary
71 
72  virtual bool set_target_object_position(float trans_x, float trans_y, float trans_z, float rot_x);
73 
74  virtual OpenRAVE::RobotBasePtr get_robot_ptr() const;
75  virtual target_t get_target() const;
76  virtual OpenRaveManipulator* get_manipulator() const;
77  virtual OpenRAVE::PlannerBase::PlannerParametersPtr get_planner_params() const;
78  virtual std::vector< std::vector<OpenRAVE::dReal> >* get_trajectory() const;
79  virtual std::vector< std::vector<float> >* get_trajectory_device() const;
80 
81  virtual bool display_planned_movements() const;
82 
83  virtual OpenRAVE::ModuleBasePtr get_basemanip() const;
84 
85  private:
86  void init();
87  bool set_target_transform(OpenRAVE::Vector& trans, OpenRAVE::Vector& rotQuat, bool no_offset = false);
88  bool set_target_euler(OpenRAVE::Vector& trans, std::vector<float>& rotations, bool no_offset = false);
89  OpenRAVE::IkParameterization get_5dof_ikparam(OpenRAVE::Transform& trans);
90 
91  fawkes::Logger* __logger;
92 
93  std::string __name;
94  OpenRAVE::RobotBasePtr __robot;
95  OpenRAVE::RobotBase::ManipulatorPtr __arm;
96  OpenRaveManipulator* __manip;
97  target_t __target;
98 
99 
100  OpenRAVE::ModuleBasePtr __mod_basemanip;
101 
102  OpenRAVE::PlannerBase::PlannerParametersPtr __planner_params;
103  std::vector< std::vector<OpenRAVE::dReal> >* __traj;
104 
105  float __trans_offset_x;
106  float __trans_offset_y;
107  float __trans_offset_z;
108 
109  bool __display_planned_movements;
110 };
111 
112 } // end of namespace fawkes
113 
114 #endif