Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
hand.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2011 LpzRobots development team *
3  * Georg Martius <georg dot martius at web dot de> *
4  * Frank Guettler <guettler at informatik dot uni-leipzig dot de *
5  * Frank Hesse <frank at nld dot ds dot mpg dot de> *
6  * Ralf Der <ralfder at mis dot mpg dot de> *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the *
20  * Free Software Foundation, Inc., *
21  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22  * *
23  ***************************************************************************/
24 #ifndef __HAND_H
25 #define __HAND_H
26 
27 #include "oderobot.h"
28 #include <selforg/configurable.h>
29 #include "primitive.h"
30 #include "joint.h"
31 #include "angularmotor.h"
32 #include "oneaxisservo.h"
33 
34 #include "primitive.h"
35 #include "osgforwarddecl.h"
36 #include "axis.h"
37 
38 #include "irsensor.h"
39 #include "raysensorbank.h"
40 #include "raysensor.h"
41 
42 namespace lpzrobots {
43 
45  {
48  };
49 
55  };
56 
57  // struct containing geom and body for each beam (= box, (cappped)cylinder, sphere)
58  typedef struct {
59 
60  public:
61  double velocity;
62  double power; // used when non-servo motor is used
63  double servo_motor_Power; // used when servo motor is used
65  enum Motor_type set_typ_of_motor;
66  double factorSensor;
72  bool initWithOpenHand; // init hand with open or half closed hand
73 
74  //---------------InfrarRedSensor--------------------------
75  double irRange;
81  enum RaySensor::rayDrawMode ray_draw_mode; // for possible modes see sensors/raysensor.h
82  } HandConf;
83 
84  enum GripMode{
87  };
88 
89  /**
90  * Artificial Hand
91  *
92  */
93  class Hand : public OdeRobot{
94  public:
95 
96  /**
97  * constructor of hand
98  * @param odeHandle data structure for accessing ODE
99  * @param osgHandle ata structure for accessing OSG
100  * @param conf configuration of robot
101  */
102  Hand(const OdeHandle& odeHandle, const OsgHandle& osgHandle, const HandConf& conf, const std::string& name);
103 
105  {
106  HandConf conf;
107  conf.velocity = 0.2;
108  conf.power = 5;
109  conf.servo_motor_Power = 0.1;
110  conf.show_contacts = true;
112  conf.irRange = 2;
113  conf.ir_sensor_used=true;
114  conf.irs_at_fingerbottom=true;
115  conf.irs_at_fingercenter=true;
116  conf.irs_at_fingertop =true;
117  conf.irs_at_fingertip =false;
119  conf.factorSensor=1.0;
120  conf.fix_palm_joint=true;
121  conf.one_finger_as_one_motor=false;
122  conf.draw_joints=false;
123  conf.showFingernails=true;
124  conf.fingerJointBendAngle=M_PI/2;
125  conf.initWithOpenHand=true; // init with open hand
126  return conf;
127  }
128 
129 
130  /**
131  * update the subcomponents
132  */
133  virtual void update();
134 
135  /**
136  * sets the pose of the vehicle
137  * @param pose desired 4x4 pose matrix
138  */
139  virtual void placeIntern(const osg::Matrix& pose);
140 
141  virtual void sense(GlobalData& globalData) override;
142 
143  /** returns actual sensorvalues
144  @param sensors sensors scaled to [-1,1]
145  @param sensornumber length of the sensor array
146  @return number of actually written sensors
147  */
148  virtual int getSensorsIntern(sensor* sensors, int sensornumber);
149 
150  /** sets actual motorcommands
151  @param motors motors scaled to [-1,1]
152  @param motornumber length of the motor array
153  */
154  virtual void setMotorsIntern(const double* motors, int motornumber);
155 
156  /** returns number of sensors
157  */
158  virtual int getSensorNumberIntern();
159 
160  /** returns number of motors
161  */
162  virtual int getMotorNumberIntern();
163 
164  /** returns a vector with the positions of all segments of the robot
165  @param poslist vector of positions (of all robot segments)
166  @return length of the list
167  */
168  // virtual int getSegmentsPosition(vector<Position> &poslist);
169 
170  /******** CONFIGURABLE ***********/
171  virtual void notifyOnChange(const paramkey& key);
172 
173 
174  protected:
175  /**
176  * Returns the palm as the main object of the robot,
177  * which is used for position and speed tracking.
178  */
179  virtual Primitive* getMainPrimitive() const {
180  if(!objects.empty()){
181  return (objects[0]); // returns forearm for fixation
182  //return (objects[1]); // returns palm
183  }else return 0;
184  }
185 
186 
187  private:
188 
189  /**
190  * creates the hand at the desired pose
191  * @param pose 4x4 pose matrix
192  */
193  virtual void create(const osg::Matrix& pose);
194 
195  /**
196  * destroys robot and space
197  */
198  virtual void destroy();
199 
200  static void mycallback(void *data, dGeomID o1, dGeomID o2);
201 
202  /** true if robot was created */
203  bool created;
204 
205  protected:
206 
207  /** configuration of hand */
209 
210  /** vector containing OSGPrimitives */
211  std::vector <OSGPrimitive*> osg_objects;
212  /** vector containing Primitivesinfrared sensors */
213  std::vector <IRSensor*> ir_sensors;
214 
215  /** true if contact joint is created */
217 
218  //std::vector <HingeServo*> servos;
219  //objects.reserve(number_beams);
220 
221  /** vector of the joints used in hand */
222 
223 
224  /** vector of the angular motors */
225  std::vector <AngularMotor*> frictionmotors;
226 
227  /** vector of the used hinge servos*/
228  std::vector <HingeServo*> servos;
229 
230  /** a collection of ir sensors */
232 
233 
234  /** space containing the hand */
235  dSpaceID hand_space;
236 
237  //Beam beam[number_beams]; // array of elements (rectangle and cylinders)
238  //dJointID joint[number_joints]; // array containg "normal" joints for connecting the elementsconf
239  //dJointID fix_joint[number_fix_joints]; //joints for keeping index, middle, ring and little finger together to achieve mor prosthetic like motion
240 
241  /** motorjoint for actuating the forearm_palm joint (ball joint) */
243 
244  /** motorjoint for actuating the palm_thumb joint (ball joint) */
246 
247  /** Hinge Joint between thumb_buttom and thumb_top*/
249 
250  /** Hinge Joint between buttom, center and top part of the index finger*/
252 
253  /** Hinge Joint between buttom, center and top part of the middle finger*/
255 
256  /** Hinge Joint between buttom, center and top part of the ring finger*/
258 
259  /** Hinge Joint between buttom, center and top part of the little finger*/
261 
262 
263 
264  /** for handling lateral and precision grip modes */
266 
267 
268 
269  /** initial position of robot */
271 
272 
274 
275  int sensorno;
276  int motorno;
280 
281  double velocity;
282 
283 
284  };
285 
286 }
287 
288 #endif
289 
Class for a bank (collection) of ray sensors.
Definition: raysensorbank.h:36
Joint * index_ct
Definition: hand.h:251
virtual void sense(GlobalData &globalData) override
this function is called each controlstep before control.
Definition: hand.cpp:114
Definition: hand.h:58
Data structure for accessing the ODE.
Definition: odehandle.h:44
double velocity
Definition: hand.h:61
Definition: hand.h:51
Joint * index_bc
Definition: hand.h:251
paramval factorForce
Definition: hand.h:278
dSpaceID hand_space
space containing the hand
Definition: hand.h:235
Definition: hand.h:53
virtual Primitive * getMainPrimitive() const
Returns the palm as the main object of the robot, which is used for position and speed tracking...
Definition: hand.h:179
virtual void setMotorsIntern(const double *motors, int motornumber)
sets actual motorcommands
Definition: hand.cpp:337
Matrixd Matrix
Definition: osgforwarddecl.h:47
bool one_finger_as_one_motor
Definition: hand.h:68
std::vector< HingeServo * > servos
vector of the used hinge servos
Definition: hand.h:228
int motorno
Definition: hand.h:276
virtual int getSensorNumberIntern()
returns number of sensors
Definition: hand.cpp:563
charArray paramkey
Definition: avrtypes.h:36
Definition: hand.h:52
Definition: joint.h:41
Definition: raysensor.h:56
rayDrawMode
Definition: raysensor.h:56
double factorSensor
Definition: hand.h:66
bool irs_at_fingerbottom
Definition: hand.h:80
std::vector< IRSensor * > ir_sensors
vector containing Primitivesinfrared sensors
Definition: hand.h:213
double sensor
Definition: types.h:29
virtual void notifyOnChange(const paramkey &key)
returns a vector with the positions of all segments of the robot
Definition: hand.cpp:1350
HingeJoint * thumb_bt
Hinge Joint between thumb_buttom and thumb_top.
Definition: hand.h:248
std::vector< AngularMotor * > frictionmotors
vector of the joints used in hand
Definition: hand.h:225
Definition: pos.h:36
Data structure for accessing the OpenSceneGraph.
Definition: osghandle.h:79
double fingerJointBendAngle
Definition: hand.h:71
int sensorno
Definition: hand.h:275
Joint * little_ct
Definition: hand.h:260
Joint * little_bc
Definition: hand.h:260
GripMode gripmode
for handling lateral and precision grip modes
Definition: hand.h:265
GripMode
Definition: hand.h:84
Motor_type
Definition: hand.h:44
IrSensor_Type
Definition: hand.h:50
Joint * palm_index
Hinge Joint between buttom, center and top part of the index finger.
Definition: hand.h:251
int sensor_number
Definition: hand.h:277
Definition: position.h:30
Definition: hand.h:46
Joint * ring_ct
Definition: hand.h:257
double paramval
Definition: configurable.h:88
Joint * palm_middle
Hinge Joint between buttom, center and top part of the middle finger.
Definition: hand.h:254
Definition: hand.h:54
double velocity
Definition: hand.h:281
virtual int getMotorNumberIntern()
returns number of motors
Definition: hand.cpp:569
virtual int getSensorsIntern(sensor *sensors, int sensornumber)
returns actual sensorvalues
Definition: hand.cpp:207
virtual void update()
update the subcomponents
Definition: hand.cpp:86
Joint * middle_bc
Definition: hand.h:254
Interface class for primitives represented in the physical and graphical world.
Definition: primitive.h:80
bool contact_joint_created
true if contact joint is created
Definition: hand.h:216
Abstract angular motor class.
Definition: angularmotor.h:36
enum RaySensor::rayDrawMode ray_draw_mode
Definition: hand.h:81
Data structure holding all essential global information.
Definition: globaldata.h:57
double irRange
Definition: hand.h:75
bool draw_joints
Definition: hand.h:69
bool fix_palm_joint
Definition: hand.h:67
std::list< SensorAttachment > sensors
Definition: oderobot.h:269
RaySensorBank irSensorBank
a collection of ir sensors
Definition: hand.h:231
Hand(const OdeHandle &odeHandle, const OsgHandle &osgHandle, const HandConf &conf, const std::string &name)
constructor of hand
Definition: hand.cpp:35
AngularMotor * thumb_motor_joint
motorjoint for actuating the palm_thumb joint (ball joint)
Definition: hand.h:245
double power
Definition: hand.h:62
bool irs_at_fingertip
Definition: hand.h:77
HandConf conf
configuration of hand
Definition: hand.h:208
Joint * ring_bc
Definition: hand.h:257
bool show_contacts
Definition: hand.h:64
OsgHandle osgHandle
Definition: oderobot.h:278
Joint * palm_ring
Hinge Joint between buttom, center and top part of the ring finger.
Definition: hand.h:257
Joint * middle_ct
Definition: hand.h:254
OdeHandle odeHandle
Definition: oderobot.h:277
bool irs_at_fingercenter
Definition: hand.h:79
Definition: hand.h:47
Joint * palm_little
Hinge Joint between buttom, center and top part of the little finger.
Definition: hand.h:260
static HandConf getDefaultConf()
Definition: hand.h:104
Definition: hand.h:86
Definition: hand.h:85
Abstract class for ODE robots.
Definition: oderobot.h:64
double servo_motor_Power
Definition: hand.h:63
Pos oldp
Definition: hand.h:273
virtual void placeIntern(const osg::Matrix &pose)
sets the pose of the vehicle
Definition: hand.cpp:110
Primitives objects
list of objects (should be populated by subclasses)
Definition: oderobot.h:265
bool showFingernails
Definition: hand.h:70
Definition: joint.h:183
Position initial_pos
initial position of robot
Definition: hand.h:270
Artificial Hand.
Definition: hand.h:93
std::list< MotorAttachment > motors
Definition: oderobot.h:270
bool initWithOpenHand
Definition: hand.h:72
std::vector< OSGPrimitive * > osg_objects
vector containing OSGPrimitives
Definition: hand.h:211
enum Motor_type set_typ_of_motor
Definition: hand.h:65
bool ir_sensor_used
Definition: hand.h:76
bool irs_at_fingertop
Definition: hand.h:78
paramval frictionGround
Definition: hand.h:279
AngularMotor * palm_motor_joint
motorjoint for actuating the forearm_palm joint (ball joint)
Definition: hand.h:242