hand.h

Go to the documentation of this file.
00001 /*************************************************************************** 00002 * Copyright (C) 2005 by Robot Group Leipzig * 00003 * martius@informatik.uni-leipzig.de * 00004 * fhesse@informatik.uni-leipzig.de * 00005 * der@informatik.uni-leipzig.de * 00006 * * 00007 * This program is free software; you can redistribute it and/or modify * 00008 * it under the terms of the GNU General Public License as published by * 00009 * the Free Software Foundation; either version 2 of the License, or * 00010 * (at your option) any later version. * 00011 * * 00012 * This program is distributed in the hope that it will be useful, * 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00015 * GNU General Public License for more details. * 00016 * * 00017 * You should have received a copy of the GNU General Public License * 00018 * along with this program; if not, write to the * 00019 * Free Software Foundation, Inc., * 00020 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00021 * * 00022 * $Log: hand.h,v $ 00023 * Revision 1.2 2006/09/21 16:15:57 der 00024 * *** empty log message *** 00025 * 00026 * Revision 1.6.4.9 2006/06/25 16:57:13 martius 00027 * abstractrobot is configureable 00028 * name and revision 00029 * 00030 * Revision 1.6.4.8 2006/03/30 12:34:56 martius 00031 * documentation updated 00032 * 00033 * Revision 1.6.4.7 2006/03/30 08:43:05 fhesse 00034 * getTracePrimitive removed 00035 * 00036 * Revision 1.6.4.6 2006/03/28 14:20:28 fhesse 00037 * getTracePrimitive() added 00038 * 00039 * Revision 1.6.4.5 2005/12/30 22:54:38 martius 00040 * removed parentspace! 00041 * 00042 * Revision 1.6.4.4 2005/12/21 17:35:09 martius 00043 * moved to osg 00044 * 00045 * Revision 1.6.4.3 2005/11/16 11:26:52 martius 00046 * moved to selforg 00047 * 00048 * Revision 1.6.4.2 2005/11/15 12:29:26 martius 00049 * new selforg structure and OdeAgent, OdeRobot ... 00050 * 00051 * Revision 1.6.4.1 2005/11/14 17:37:17 martius 00052 * moved to selforg 00053 * 00054 * Revision 1.6 2005/11/09 13:26:21 martius 00055 * added factorSensor 00056 * 00057 * Revision 1.5 2005/10/06 17:14:24 martius 00058 * switched to stl lists 00059 * 00060 * Revision 1.4 2005/09/22 12:24:37 martius 00061 * removed global variables 00062 * OdeHandle and GlobalData are used instead 00063 * sensor prepared 00064 * 00065 * Revision 1.3 2005/08/31 17:18:15 fhesse 00066 * setTextures added, Mass is now sphere (not box anymore) 00067 * 00068 * Revision 1.2 2005/07/26 17:04:21 martius 00069 * lives in its own space now 00070 * 00071 * Revision 1.1 2005/07/21 12:17:04 fhesse 00072 * new hurling snake, todo: add collision space, clean up, comment 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 // struct containing geom and body for each beam (= box, (cappped)cylinder, sphere) 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 //---------------InfrarRedSensor-------------------------- 00146 // enum IrSensor_Type set_irsensor_type; 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 * Artificial Hand 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 // Hand(const OdeHandle& odeHandle, const OsgHandle& osgHandle, const string& name); 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; // friction within joint 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 //conf.set_irsensor_type=irDrawAll; 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 * Constructor 00199 */ 00200 00201 /// update the subcomponents 00202 virtual void update(); 00203 00204 /** sets the pose of the vehicle 00205 @param pose desired 4x4 pose matrix 00206 */ 00207 virtual void place(const osg::Matrix& pose); 00208 00209 /** checks for internal collisions and treats them. 00210 * In case of a treatment return true (collision will be ignored by other objects and the default routine) 00211 * else false (collision is passed to other objects and (if not treated) to the default routine). 00212 */ 00213 virtual bool collisionCallback(void *data, dGeomID o1, dGeomID o2); 00214 /** this function is called in each timestep. It should perform robot-internal checks, 00215 like space-internal collision detection, sensor resets/update etc. 00216 @param globalData structure that contains global data from the simulation environment 00217 */ 00218 virtual void doInternalStuff(const GlobalData& globalData); 00219 00220 00221 /** returns actual sensorvalues 00222 @param sensors sensors scaled to [-1,1] 00223 @param sensornumber length of the sensor array 00224 @return number of actually written sensors 00225 */ 00226 virtual int getSensors(sensor* sensors, int sensornumber); 00227 00228 /** sets actual motorcommands 00229 @param motors motors scaled to [-1,1] 00230 @param motornumber length of the motor array 00231 */ 00232 virtual void setMotors(const motor* motors, int motornumber); 00233 00234 /** returns number of sensors 00235 */ 00236 virtual int getSensorNumber(); 00237 00238 /** returns number of motors 00239 */ 00240 virtual int getMotorNumber(); 00241 00242 /** returns a vector with the positions of all segments of the robot 00243 @param poslist vector of positions (of all robot segments) 00244 @return length of the list 00245 */ 00246 // virtual int getSegmentsPosition(vector<Position> &poslist); 00247 00248 /** The list of all parameters with there value as allocated lists. 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 /** the main object of the robot, which is used for position and speed tracking */ 00258 virtual Primitive* getMainPrimitive() const { 00259 if(!objects.empty()){ 00260 // int half = objects.size()/2; 00261 // return (objects[half]); 00262 return (objects[1]); 00263 }else return 0; 00264 } 00265 00266 00267 private: 00268 00269 /** creates vehicle at desired pose 00270 @param pose 4x4 pose matrix 00271 */ 00272 virtual void create(const osg::Matrix& pose); 00273 00274 /** destroys robot and space 00275 */ 00276 virtual void destroy(); 00277 00278 static void mycallback(void *data, dGeomID o1, dGeomID o2); 00279 00280 bool created; // true if robot was 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 //std::vector <HingeServo*> servos; 00291 //objects.reserve(number_beams); 00292 00293 std::vector <Joint*> joints; 00294 00295 std::vector <AngularMotor*> frictionmotors; 00296 std::vector <HingeServo*> servos; 00297 RaySensorBank irSensorBank; // a collection of ir sensors 00298 00299 00300 Primitive* p; 00301 Joint* j; 00302 00303 //Beam beam[number_beams]; // array of elements (rectangle and cylinders) 00304 dSpaceID hand_space; // space containing the hand 00305 //dJointID joint[number_joints]; // array containg "normal" joints for connecting the elementsconf 00306 00307 //dJointID fix_joint[number_fix_joints]; //joints for keeping index, middle, ring and little finger together to achieve mor prosthetic like motion 00308 00309 // two motorjoints for actuating the two ball joints (forearm_palm and palm_thumb) 00310 AngularMotor* palm_motor_joint; 00311 AngularMotor* thumb_motor_joint; 00312 00313 Joint* fix_forearm_joint; //joint connecting forearm with simulation environment 00314 00315 00316 00317 double thumb1, thumb2, thumb3; 00318 00319 GripMode gripmode; //for handling lateral and precision grip modes 00320 00321 00322 00323 00324 Position initial_pos; // initial position of robot 00325 00326 int NUM; /* number of beats */ 00327 double MASS; /* mass of a beats */ 00328 double RADIUS; /* sphere radius */ 00329 00330 // Joint* joint[10]; 00331 // Primitive* object[10]; 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

Generated on Tue Jan 16 02:14:35 2007 for Robotsystem of the Robot Group Leipzig by doxygen 1.3.8