Home
FAQ
Player
Utilities
Stage
Gazebo
Contrib
Documentation
Publications
Contributors
Users

Project
Download
Bugs/Feedback
Mailing lists

Radish

Old news
Old stuff

Pioneer2Gripper.hh

Go to the documentation of this file.
00001 /*
00002  *  Gazebo - Outdoor Multi-Robot Simulator
00003  *  Copyright (C) 2003  
00004  *     Nate Koenig & Andrew Howard
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 /* Desc: Model for Pioneer2 Gripper
00022  *
00023  * This model reproduce Pionner2 gripper's main behaviors according to 
00024  * Player's gripper interface. 
00025  *
00026  * Each model that needs to be gripped must contain the following tags in
00027  * its model description (in the .world file) : <canBeGrip></canBeGrip> and
00028  * the value  should be either 'yes' or 'no'. If tag is not present, it will
00029  * be considered to be not available for gripper. This have been implemented
00030  * to avoid considering every object as grippable, which enhances simulation
00031  * performances when a lot of objects can be present in simulated world.
00032  *
00033  * For now, gripping is emulated which means that when grasping, ODE's
00034  * physical friction is not used to lift an object. Gripped object is just
00035  * repositionned to lift's height. Using ODE's friction model have been
00036  * tried but with no good results. Many bugs and glitches were observed
00037  * leading to an unusable model :-(
00038  * 
00039  * Author: Carle Cote 
00040  *            (Laborius - Universite de Sherbrooke - Sherbrooke, Quebec, Canada)
00041  * Date: 23 february 2004
00042  * 
00043  * TODOs: 
00044  *  - Change grips emulated friction for ODE's physical friction model.
00045  *  - Avoid using rays proximity sensor's geoms to draw rays
00046  * 
00047  * WARNINGS:
00048  *  - pionner2DX (and probably AT) mass modelisation can lead to problem 
00049  *    lifting heavy objects (can create weird behaviors). Recommended object 
00050  *    mass should be around 0.1.
00051  * 
00052  * CVS: $Id: Pioneer2Gripper.hh,v 1.7 2005/04/13 16:32:31 natepak Exp $
00053  * 
00054  * Modification description :
00055  * 
00056  * Author: Carle Cote 
00057  *           (Laborius - Universite de Sherbrooke - Sherbrooke, Quebec, Canada)
00058  * Date: 21 march 2004 
00059  * Desc.: Patch the shaking bug. This should be a temporary patch until using 
00060  *        ODE's physic model for friction
00061  *
00062  * Author: Carle Cote 
00063  *           (Laborius - Universite de Sherbrooke - Sherbrooke, Quebec, Canada)
00064  * Date: 26 may 2004 
00065  * Desc: Fix model with refactored core
00066  *          - Change collision detection mechanism
00067  *          - Change pressure pads to a no collision geoms with their own spaceID
00068  *          - Move pressure pads a little bit inside the grips to help detect gripped state  
00069  */
00070 
00071 #ifndef GAZEBO_P2GRIPPER_HH
00072 #define GAZEBO_P2GRIPPER_HH
00073 
00074 #include "Model.hh"
00075 
00076 // Forward declarations
00077 class Body;
00078 class Geom;
00079 class RayGeom;
00080 class GeomData;
00081 class SliderJoint;
00082 class RayProximity;
00083 
00084 typedef struct gz_gripper gz_gripper_t;
00085 
00086 class Pioneer2Gripper : public Model
00087 {
00088   // Constructor, destructor
00089   public: Pioneer2Gripper( World *world );
00090   public: virtual ~Pioneer2Gripper();
00091 
00092   // Load the model
00093   public: virtual int Load( WorldFile *file, WorldFileNode *node );
00094 
00095   // Initialize the model
00096   public: virtual int Init( WorldFile *file, WorldFileNode *node );
00097 
00098   // Finalize the model
00099   public: virtual int Fini();
00100 
00101   // Update the model state
00102   public: virtual void Update( double step );
00103 
00104   // Grips-intersection callback
00105   private: static void UpdateGripCallback( void *data, dGeomID o1, dGeomID o2 );
00106 
00107   // Load ODE stuff
00108   private: int OdeLoad( WorldFile *file, WorldFileNode *node );
00109 
00110   // Initialize ODE
00111   private: int OdeInit( WorldFile *file, WorldFileNode *node );
00112 
00113   // Finalize ODE
00114   private: int OdeFini();
00115 
00116   // Initialize the external interface
00117   private: int IfaceInit();
00118 
00119   // Finalize the external interface
00120   private: int IfaceFini();
00121 
00122   // Get commands from the external interface
00123   private: void IfaceGetCmd();
00124 
00125   // Update the data in the external interface
00126   private: void IfacePutData();  
00127   
00128   // Grip command functions
00129   public: void OpenGrip();
00130   public: void CloseGrip();
00131   public: void StopGrip();
00132   
00133   // Lift command functions
00134   public: void StopLift();
00135   public: void LiftUp();
00136   public: void LiftDown();
00137   
00138   // adds model in the list of grippable models 
00139   public: void AddGrippableModel( Model *model);
00140 
00141   // Gripper's mode
00142   public: enum GripperMode{ GRIPPER_STOP_MODE = 0, GRIPPER_OPEN_MODE, GRIPPER_CLOSE_MODE };
00143   // Lift's mode
00144   public: enum LiftMode{ LIFT_STOP_MODE = 0, LIFT_UP_MODE, LIFT_DOWN_MODE };
00145   
00146   // Gripper's parameters
00147   private: dReal gripMaxSpeed;
00148   private: dReal liftMaxSpeed;
00149   
00150   private: dReal fixedbarLength;
00151   private: dReal fixedbarWidth;
00152   private: dReal fixedbarHeight;
00153   private: dReal fixedbarMass;
00154 
00155   private: dReal basebarLength;
00156   private: dReal basebarWidth;
00157   private: dReal basebarHeight;
00158   private: dReal basebarZPos; // Use to set the gripper fully down position
00159   private: dReal basebarMass;
00160 
00161   private: dReal gripLength;
00162   private: dReal gripWidth;
00163   private: dReal gripHeight;
00164   private: dReal gripMass;
00165   private: dReal gripsOpenWidth;
00166   private: dReal gripsCloseWidth;
00167   private: dReal gripMinPosLimit;
00168   private: dReal gripMaxPosLimit; 
00169   private: dReal gripMaxForce;
00170 
00171   private: dReal liftHeight;
00172   private: dReal liftMinPosLimit;
00173   private: dReal liftMaxPosLimit;
00174   private: dReal liftMaxForce;
00175   
00176   private: dReal ffTolerance; // used instead of FudgeFactor param to counter ODE bug with joints limit
00177   private: dReal simFrictionTolerance; // used to avoid gripped model contact with grips for emulating friction.
00178                                        // If not used, ODE's friction model generates unwanted forces.
00179                                        
00180   // These boolean variables indicate the state of the gripper
00181   //(same nomenclature found on Player side)
00182   private: bool lift_limit_reach;   //Unused
00183   private: bool grip_limit_reach;   //Unused
00184   private: bool outer_beam_obstruct;
00185   private: bool inner_beam_obstruct;
00186   private: bool left_paddle_open;   //Unused
00187   private: bool right_paddle_open;  //Unused
00188   private: bool paddles_opened;
00189   private: bool paddles_closed;
00190   private: bool paddles_moving;
00191   private: bool paddles_error;      //Unused
00192   private: bool lift_up;
00193   private: bool lift_down;
00194   private: bool lift_moving;
00195   private: bool lift_error;         //Unused
00196 
00197   // data and state
00198   private: unsigned char state;
00199   private: unsigned char beams;
00200 
00201   private: GripperMode gripperMode;
00202   private: LiftMode liftMode;
00203 
00204   private: bool isGripping;
00205 
00206   // ODE objects
00207   private: Body *body;
00208   private: Body *baseBarBody;
00209   private: Body *leftGripperBody;
00210   private: Body *rightGripperBody;
00211   
00212   private: Geom *fixedBarGeom;
00213   private: Geom *baseBarGeom;
00214   private: Geom *leftGripGeom;
00215   private: Geom *rightGripGeom;
00216   private: Geom *leftPressureSensorGeom;
00217   private: Geom *rightPressureSensorGeom;
00218 
00219   private: RayProximity *innerBreakbeam;
00220   private: RayProximity *outerBreakbeam;
00221 
00222   private: SliderJoint *leftGripperJoint;
00223   private: SliderJoint *rightGripperJoint;
00224   private: SliderJoint *baseJoint;
00225   
00226   private: dSpaceID leftGripSpaceId;
00227   private: dSpaceID rightGripSpaceId;
00228   
00229   // External interface
00230   private: gz_gripper_t *gripper_iface;
00231 
00232 };
00233 
00234 #endif


Last updated $Date: 2004/12/21 01:49:15 $
Generated on Sun May 22 18:39:08 2005 for Gazebo by doxygen 1.4.2