hand.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __HAND_H
00025 #define __HAND_H
00026
00027 #include "oderobot.h"
00028 #include <selforg/configurable.h>
00029 #include "primitive.h"
00030 #include "joint.h"
00031 #include "angularmotor.h"
00032 #include "oneaxisservo.h"
00033
00034 #include "primitive.h"
00035 #include "osgforwarddecl.h"
00036 #include "axis.h"
00037
00038 #include "irsensor.h"
00039 #include "raysensorbank.h"
00040 #include "raysensor.h"
00041
00042 namespace lpzrobots {
00043
00044 enum Motor_type
00045 {
00046 With_servo_motor,
00047 Without_servo_motor
00048 };
00049
00050 enum IrSensor_Type{
00051 irDrawAll,
00052 irBack,
00053 irSide,
00054 irFront
00055 };
00056
00057
00058 typedef struct {
00059
00060 public:
00061 double velocity;
00062 double power;
00063 double servo_motor_Power;
00064 bool show_contacts;
00065 enum Motor_type set_typ_of_motor;
00066 double factorSensor;
00067 bool fix_palm_joint;
00068 bool one_finger_as_one_motor;
00069 bool draw_joints;
00070 bool showFingernails;
00071 double fingerJointBendAngle;
00072 bool initWithOpenHand;
00073
00074
00075 double irRange;
00076 bool ir_sensor_used;
00077 bool irs_at_fingertip;
00078 bool irs_at_fingertop;
00079 bool irs_at_fingercenter;
00080 bool irs_at_fingerbottom;
00081 enum RaySensor::rayDrawMode ray_draw_mode;
00082 } HandConf;
00083
00084 enum GripMode{
00085 lateral,
00086 precision
00087 };
00088
00089
00090
00091
00092
00093 class Hand : public OdeRobot{
00094 public:
00095
00096
00097
00098
00099
00100
00101
00102 Hand(const OdeHandle& odeHandle, const OsgHandle& osgHandle, const HandConf& conf, const std::string& name);
00103
00104 static HandConf getDefaultConf()
00105 {
00106 HandConf conf;
00107 conf.velocity = 0.2;
00108 conf.power = 5;
00109 conf.servo_motor_Power = 0.1;
00110 conf.show_contacts = true;
00111 conf.set_typ_of_motor = Without_servo_motor;
00112 conf.irRange = 2;
00113 conf.ir_sensor_used=true;
00114 conf.irs_at_fingerbottom=true;
00115 conf.irs_at_fingercenter=true;
00116 conf.irs_at_fingertop =true;
00117 conf.irs_at_fingertip =false;
00118 conf.ray_draw_mode=RaySensor::drawAll;
00119 conf.factorSensor=1.0;
00120 conf.fix_palm_joint=true;
00121 conf.one_finger_as_one_motor=false;
00122 conf.draw_joints=false;
00123 conf.showFingernails=true;
00124 conf.fingerJointBendAngle=M_PI/2;
00125 conf.initWithOpenHand=true;
00126 return conf;
00127 }
00128
00129
00130
00131
00132
00133 virtual void update();
00134
00135
00136
00137
00138
00139 virtual void place(const osg::Matrix& pose);
00140
00141
00142
00143
00144
00145 virtual void doInternalStuff(GlobalData& globalData);
00146
00147
00148
00149
00150
00151
00152
00153 virtual int getSensors(sensor* sensors, int sensornumber);
00154
00155
00156
00157
00158
00159 virtual void setMotors(const motor* motors, int motornumber);
00160
00161
00162
00163 virtual int getSensorNumber();
00164
00165
00166
00167 virtual int getMotorNumber();
00168
00169
00170
00171
00172
00173
00174
00175
00176 virtual void notifyOnChange(const paramkey& key);
00177
00178
00179 protected:
00180
00181
00182
00183
00184 virtual Primitive* getMainPrimitive() const {
00185 if(!objects.empty()){
00186 return (objects[0]);
00187
00188 }else return 0;
00189 }
00190
00191
00192 private:
00193
00194
00195
00196
00197
00198 virtual void create(const osg::Matrix& pose);
00199
00200
00201
00202
00203 virtual void destroy();
00204
00205 static void mycallback(void *data, dGeomID o1, dGeomID o2);
00206
00207
00208 bool created;
00209
00210 protected:
00211
00212
00213 HandConf conf;
00214
00215
00216 std::vector <OSGPrimitive*> osg_objects;
00217
00218 std::vector <IRSensor*> ir_sensors;
00219
00220
00221 bool contact_joint_created;
00222
00223
00224
00225
00226
00227
00228
00229
00230 std::vector <AngularMotor*> frictionmotors;
00231
00232
00233 std::vector <HingeServo*> servos;
00234
00235
00236 RaySensorBank irSensorBank;
00237
00238
00239
00240 dSpaceID hand_space;
00241
00242
00243
00244
00245
00246
00247 AngularMotor* palm_motor_joint;
00248
00249
00250 AngularMotor* thumb_motor_joint;
00251
00252
00253 HingeJoint* thumb_bt;
00254
00255
00256 Joint *palm_index, *index_bc, *index_ct;
00257
00258
00259 Joint *palm_middle, *middle_bc, *middle_ct;
00260
00261
00262 Joint *palm_ring, *ring_bc, *ring_ct;
00263
00264
00265 Joint *palm_little, *little_bc, *little_ct;
00266
00267
00268
00269
00270 GripMode gripmode;
00271
00272
00273
00274
00275 Position initial_pos;
00276
00277
00278 Pos oldp;
00279
00280 int sensorno;
00281 int motorno;
00282 int sensor_number;
00283 paramval factorForce;
00284 paramval frictionGround;
00285
00286 double velocity;
00287
00288
00289 };
00290
00291 }
00292
00293 #endif
00294