00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
#ifndef __HAND_H
00078
#define __HAND_H
00079
00080
#include <drawstuff/drawstuff.h>
00081
#include "oderobot.h"
00082
#include <selforg/configurable.h>
00083
#include "primitive.h"
00084
#include "joint.h"
00085
#include "angularmotor.h"
00086
#include "hingeservo.h"
00087
00088
#include "primitive.h"
00089
#include "osgforwarddecl.h"
00090
#include "axis.h"
00091
00092
#include "irsensor.h"
00093
#include "raysensorbank.h"
00094
00095
namespace lpzrobots {
00096
00097 enum Hand_Is_Drawn_Under_Angel
00098 {
00099
Is_Draw_under_180_degree,
00100
Is_Draw_under_90_degree
00101 };
00102
00103 enum Motor_type
00104 {
00105
With_servo_motor,
00106
Without_servo_motor
00107 };
00108
00109 enum IrSensor_Type{
00110
irDrawAll,
00111
irBack,
00112
irSide,
00113
irFront
00114 };
00115
00116 enum Draw_Part_of_Ir_Sensor
00117 {
00118
Draw_All,
00119
Draw_just_Sensor,
00120
Draw_just_Ray,
00121
Draw_Nothing
00122 };
00123
00124 typedef struct {
00125
public:
00126
00127 double velocity;
00128 double power;
00129 double servo_motor_Power;
00130 double invert;
00131 double jointLimit1;
00132 double jointLimit2;
00133 double frictionJoint;
00134 double x;
00135 double y;
00136 double z;
00137 bool show_contacts;
00138 double thumb_angle;
00139 enum Motor_type set_typ_of_motor;
00140 enum Hand_Is_Drawn_Under_Angel hand_is_drawn_under_angel;
00141 double factorSensor;
00142 double finger_winkel;
00143
00144
00145
00146
00147 double irRange;
00148 int number_of_ir_sensors;
00149 bool ir_sensor_used;
00150 enum Draw_Part_of_Ir_Sensor Draw_part_of_ir_sensor;
00151 }
HandConf;
00152
00153 enum GripMode{
00154
lateral,
00155
precision
00156 };
00157
00158
00159
00160
00161
00162 class Hand :
public OdeRobot{
00163
public:
00164
00165
Hand(
const OdeHandle& odeHandle,
const OsgHandle& osgHandle,
const HandConf&
conf,
const std::string& name);
00166
00167
00168
00169
00170 static HandConf getDefaultConf()
00171 {
00172
HandConf conf;
00173 conf.
velocity = 0.2;
00174 conf.
power = 0.5;
00175 conf.
servo_motor_Power = 0.1;
00176 conf.
frictionJoint = 90;
00177 conf.
invert = 1;
00178 conf.
x =0;
00179 conf.
y =0;
00180 conf.
z =2;
00181 conf.
show_contacts =
true;
00182 conf.
jointLimit1 = M_PI/2;
00183 conf.
jointLimit2 = 2*M_PI;
00184 conf.
set_typ_of_motor =
Without_servo_motor;
00185 conf.
thumb_angle=0;
00186
00187 conf.
irRange = 2;
00188 conf.
ir_sensor_used=
true;
00189 conf.
number_of_ir_sensors = 0;
00190 conf.
Draw_part_of_ir_sensor=
Draw_just_Ray;
00191 conf.
hand_is_drawn_under_angel =
Is_Draw_under_90_degree;
00192 conf.
factorSensor=2.0;
00193 conf.
finger_winkel=M_PI/2;
00194
return conf;
00195 }
00196
00197
00198
00199
00200
00201
00202
virtual void update();
00203
00204
00205
00206
00207
virtual void place(
const osg::Matrix& pose);
00208
00209
00210
00211
00212
00213
virtual bool collisionCallback(
void *data, dGeomID o1, dGeomID o2);
00214
00215
00216
00217
00218
virtual void doInternalStuff(
const GlobalData& globalData);
00219
00220
00221
00222
00223
00224
00225
00226
virtual int getSensors(
sensor* sensors,
int sensornumber);
00227
00228
00229
00230
00231
00232
virtual void setMotors(
const motor* motors,
int motornumber);
00233
00234
00235
00236
virtual int getSensorNumber();
00237
00238
00239
00240
virtual int getMotorNumber();
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
virtual paramlist
getParamList() const;
00251
00252 virtual paramval getParam(const paramkey& key) const;
00253
00254 virtual
bool setParam(const paramkey& key, paramval val);
00255
00256 protected:
00257
00258 virtual
Primitive* getMainPrimitive()
const {
00259
if(!
objects.empty()){
00260
00261
00262
return (
objects[1]);
00263 }
else return 0;
00264 }
00265
00266
00267
private:
00268
00269
00270
00271
00272
virtual void create(
const osg::Matrix& pose);
00273
00274
00275
00276
virtual void destroy();
00277
00278
static void mycallback(
void *data, dGeomID o1, dGeomID o2);
00279
00280 bool created;
00281
00282
protected:
00283
00284 HandConf conf;
00285 std::vector <Primitive*>
objects;
00286 std::vector <OSGPrimitive*>
osg_objects;
00287 std::vector <IRSensor*>
ir_sensors;
00288 bool contact_joint_created;
00289
00290
00291
00292
00293 std::vector <Joint*>
joints;
00294
00295 std::vector <AngularMotor*>
frictionmotors;
00296 std::vector <HingeServo*>
servos;
00297 RaySensorBank irSensorBank;
00298
00299
00300 Primitive*
p;
00301 Joint*
j;
00302
00303
00304 dSpaceID
hand_space;
00305
00306
00307
00308
00309
00310 AngularMotor*
palm_motor_joint;
00311 AngularMotor*
thumb_motor_joint;
00312
00313 Joint*
fix_forearm_joint;
00314
00315
00316
00317 double thumb1,
thumb2,
thumb3;
00318
00319 GripMode gripmode;
00320
00321
00322
00323
00324 Position initial_pos;
00325
00326 int NUM;
00327 double MASS;
00328 double RADIUS;
00329
00330
00331
00332
00333 Pos oldp;
00334
00335 int sensorno;
00336 int motorno;
00337 int sensor_number;
00338 paramval
factorForce;
00339 paramval
frictionGround;
00340
00341 double velocity;
00342 double power;
00343
public:
00344
00345
00346 static double palm_torque;
00347 static double finger_force;
00348
00349 };
00350
00351 }
00352
00353
#endif
00354