sliderwheelie.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  *    frankguettler@gmx.de                                                 *
00007  *                                                                         *
00008  *   This program is free software; you can redistribute it and/or modify  *
00009  *   it under the terms of the GNU General Public License as published by  *
00010  *   the Free Software Foundation; either version 2 of the License, or     *
00011  *   (at your option) any later version.                                   *
00012  *                                                                         *
00013  *   This program is distributed in the hope that it will be useful,       *
00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00016  *   GNU General Public License for more details.                          *
00017  *                                                                         *
00018  *   You should have received a copy of the GNU General Public License     *
00019  *   along with this program; if not, write to the                         *
00020  *   Free Software Foundation, Inc.,                                       *
00021  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00022  *                                                                         *
00023  *   $Log: sliderwheelie.h,v $
00024  *   Revision 1.10  2008/09/16 14:53:24  martius
00025  *   provide a virtual center of the robot as main primitive
00026  *
00027  *   Revision 1.9  2007/11/07 13:21:16  martius
00028  *   doInternal stuff changed signature
00029  *
00030  *   Revision 1.8  2007/01/26 12:05:04  martius
00031  *   servos combinied into OneAxisServo
00032  *
00033  *   Revision 1.7  2006/12/21 11:43:05  martius
00034  *   commenting style for doxygen //< -> ///<
00035  *   new sensors for spherical robots
00036  *
00037  *   Revision 1.6  2006/09/21 22:09:58  martius
00038  *   collision for mesh
00039  *
00040  *   Revision 1.5  2006/09/21 16:17:18  der
00041  *   *** empty log message ***
00042  *
00043  *   Revision 1.4  2006/09/21 08:15:15  martius
00044  *   with sliders inside a segment
00045  *
00046  *   Revision 1.3  2006/07/20 17:19:44  martius
00047  *   removed using namespace std from matrix.h
00048  *
00049  *   Revision 1.2  2006/07/14 12:23:42  martius
00050  *   selforg becomes HEAD
00051  *
00052  *   Revision 1.1.2.3  2006/06/25 21:57:20  martius
00053  *   abstractrobot is configureable
00054  *   name and revision
00055  *
00056  *   Revision 1.1.2.2  2006/06/20 07:18:29  robot3
00057  *   -added cvs log
00058  *   -changed some behaviour of wheelie
00059  *
00060  *                                                                         *
00061  ***************************************************************************/
00062 #ifndef __SLIDERWHEELIE_H
00063 #define __SLIDERWHEELIE_H
00064 
00065 #include<vector>
00066 #include<assert.h>
00067 
00068 #include "oderobot.h"
00069 #include"primitive.h"
00070 #include "joint.h"
00071 #include "angularmotor.h"
00072 
00073 #include "oneaxisservo.h"
00074 
00075 
00076 namespace lpzrobots {
00077 
00078   typedef struct {
00079   public:
00080     int    segmNumber;  ///<  number of snake elements
00081     double segmLength;  ///< length of one snake element
00082     double segmDia;     ///<  diameter of a snake element
00083     double segmMass;    ///<  mass of one snake element
00084     double motorPower;  ///<  power of the motors / servos
00085     double powerRatio;   ///< ratio of motorpower for hinge vs. slider
00086     double sensorFactor;    ///<  scale for sensors
00087     double frictionGround;  ///< friction with ground
00088     double frictionJoint;   ///< friction within joint
00089     double jointLimitIn;      ///< maximal angle for the joints to the inside (M_PI/2 = 90 degree)
00090     double jointLimitOut;      ///< maximal angle for the joints to the outside
00091     double sliderLength;  ///< length of the slider in segmLength
00092   } SliderWheelieConf;
00093   
00094 
00095   /**
00096    * This is a class, which models an annular robot. 
00097    * It consists of a number of equal elements, each linked 
00098    * by a joint powered by 1 servo
00099    **/
00100   class SliderWheelie : public OdeRobot
00101   {
00102   private:
00103     bool created;
00104       
00105     std::vector <Primitive*> objects;
00106     std::vector <Joint*> joints;
00107     std::vector <AngularMotor*> frictionmotors;
00108     SliderWheelieConf conf;
00109 
00110     std::vector <HingeServo*> hingeServos;
00111     std::vector <SliderServo*> sliderServos;
00112 
00113     Primitive* center; // virtual center object (position updated on setMotors)
00114   public:
00115     SliderWheelie(const OdeHandle& odeHandle, const OsgHandle& osgHandle,
00116                   const SliderWheelieConf& conf, const std::string& name, 
00117                   const std::string& revision = "");
00118     
00119     virtual ~SliderWheelie();
00120         
00121     static SliderWheelieConf getDefaultConf(){
00122       SliderWheelieConf conf;
00123       conf.segmNumber = 8;    //  number of snake elements
00124       conf.segmLength = 0.4;   // length of one snake element
00125       conf.segmDia    = 0.2;   //  diameter of a snake element
00126       conf.segmMass   = 0.4;   //  mass of one snake element
00127       conf.motorPower = 0.2;    //  power of the servos
00128       conf.powerRatio = 2;    //  power of the servos
00129       conf.sensorFactor = 1;    //  scale for sensors
00130       conf.frictionGround = 0.8; // friction with ground
00131       conf.frictionJoint = 0.0; // friction within joint
00132       conf.jointLimitIn    =  M_PI/2;
00133       conf.jointLimitOut   =  -1; // automatically set to 2*M_PI/segm_num
00134       conf.sliderLength  =  1; 
00135       return conf;
00136     }
00137 
00138     virtual void place(const osg::Matrix& pose);
00139     
00140     virtual void update();
00141 
00142     void doInternalStuff(GlobalData& global);
00143 
00144     bool collisionCallback(void *data, dGeomID o1, dGeomID o2);
00145 
00146     virtual void setMotors ( const motor* motors, int motornumber );
00147 
00148     virtual int getSensors ( sensor* sensors, int sensornumber );
00149         
00150     virtual int getSensorNumber() { assert(created); return hingeServos.size()+sliderServos.size(); }
00151 
00152     virtual int getMotorNumber(){ assert(created); return hingeServos.size()+sliderServos.size(); }
00153 
00154     virtual Primitive* getMainPrimitive() const {
00155       if(center) return center;
00156       else if(!objects.empty()){
00157         return (objects[0]);
00158       }else return 0;
00159     }
00160     
00161     virtual paramlist getParamList() const;
00162     
00163     virtual paramval getParam(const paramkey& key) const;
00164     
00165     virtual bool setParam(const paramkey& key, paramval val);
00166 
00167   private:
00168     static void mycallback(void *data, dGeomID o1, dGeomID o2);
00169 
00170     virtual void create(const osg::Matrix& pose);
00171     virtual void destroy();
00172   };
00173 
00174 }
00175 
00176 #endif

Generated on Tue Sep 16 22:00:22 2008 for Robotsystem of the Robot Group Leipzig by  doxygen 1.4.7