Robot Simulator of the Robotics Group for Self-Organization of Control: sliderwheelie.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages
- Examples

- Search for |

- File List
- File Members

# 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.13  2009/08/10 07:48:55  guettler
    00025  *   removed typedef to avoid compiler warnings
    00026  *
    00027  *   Revision 1.12  2009/03/27 20:45:03  martius
    00028  *   motor type can be selected
    00029  *
    00030  *   Revision 1.11  2009/03/26 18:01:59  martius
    00031  *   angular motors possible
    00032  *   sliders can be switched off -> defaultwheelie is obsolete
    00033  *   better drawing of joints
    00034  *   all motors are set (was a bug before)
    00035  *
    00036  *   Revision 1.10  2008/09/16 14:53:24  martius
    00037  *   provide a virtual center of the robot as main primitive
    00038  *
    00039  *   Revision 1.9  2007/11/07 13:21:16  martius
    00040  *   doInternal stuff changed signature
    00041  *
    00042  *   Revision 1.8  2007/01/26 12:05:04  martius
    00043  *   servos combinied into OneAxisServo
    00044  *
    00045  *   Revision 1.7  2006/12/21 11:43:05  martius
    00046  *   commenting style for doxygen //< -> ///<
    00047  *   new sensors for spherical robots
    00048  *
    00049  *   Revision 1.6  2006/09/21 22:09:58  martius
    00050  *   collision for mesh
    00051  *
    00052  *   Revision 1.5  2006/09/21 16:17:18  der
    00053  *   *** empty log message ***
    00054  *
    00055  *   Revision 1.4  2006/09/21 08:15:15  martius
    00056  *   with sliders inside a segment
    00057  *
    00058  *   Revision 1.3  2006/07/20 17:19:44  martius
    00059  *   removed using namespace std from matrix.h
    00060  *
    00061  *   Revision 1.2  2006/07/14 12:23:42  martius
    00062  *   selforg becomes HEAD
    00063  *
    00064  *   Revision 1.1.2.3  2006/06/25 21:57:20  martius
    00065  *   abstractrobot is configureable
    00066  *   name and revision
    00067  *
    00068  *   Revision 1.1.2.2  2006/06/20 07:18:29  robot3
    00069  *   -added cvs log
    00070  *   -changed some behaviour of wheelie
    00071  *
    00072  *                                                                         *
    00073  ***************************************************************************/
    00074 #ifndef __SLIDERWHEELIE_H
    00075 #define __SLIDERWHEELIE_H
    00076
    00077 #include<vector>
    00078 #include<assert.h>
    00079
    00080 #include "oderobot.h"
    00081 #include"primitive.h"
    00082 #include "joint.h"
    00083 #include "angularmotor.h"
    00084
    00085 #include "oneaxisservo.h"
    00086
    00087
    00088 namespace lpzrobots {
    00089
    00090   typedef struct {
    00091   public:
    00092     /* typedef */ enum MotorType {Servo, CenteredServo, AngularMotor };
    00093
    00094     int    segmNumber;    ///<  number of snake elements
    00095     double segmLength;    ///< length of one snake element
    00096     double segmDia;       ///<  diameter of a snake element
    00097     double segmMass;      ///<  mass of one snake element
    00098     double motorPower;    ///<  power of the motors / servos
    00099     double motorDamp;     ///<  damping of motors
    00100     double powerRatio;    ///< ratio of motorpower for hinge vs. slider
    00101     double sensorFactor;  ///<  scale for sensors
    00102     double frictionGround;///< friction with ground
    00103     double frictionJoint; ///< friction within joint
    00104     double jointLimitIn;  ///< maximal angle for the joints to the inside (M_PI/2 = 90 degree)
    00105     double jointLimitOut; ///< maximal angle for the joints to the outside
    00106     double sliderLength;  ///< length of the slider in segmLength (0 for no sliders)
    00107     MotorType motorType;  ///< whether to use servos or angular motors
    00108   } SliderWheelieConf;
    00109
    00110
    00111   /**
    00112    * This is a class, which models an annular robot.
    00113    * It consists of a number of equal elements, each linked
    00114    * by a joint powered by 1 servo
    00115    **/
    00116   class SliderWheelie : public OdeRobot
    00117   {
    00118   private:
    00119     bool created;
    00120
    00121
    00122     std::vector <Primitive*> objects;
    00123     std::vector <Joint*> joints;
    00124     std::vector <AngularMotor*> angularMotors;
    00125     SliderWheelieConf conf;
    00126
    00127     std::vector <HingeServo*> hingeServos;
    00128     std::vector <SliderServo*> sliderServos;
    00129
    00130     Primitive* center; // virtual center object (position updated on setMotors)
    00131   public:
    00132     SliderWheelie(const OdeHandle& odeHandle, const OsgHandle& osgHandle,
    00133                   const SliderWheelieConf& conf, const std::string& name,
    00134                   const std::string& revision = "");
    00135
    00136     virtual ~SliderWheelie();
    00137
    00138     static SliderWheelieConf getDefaultConf(){
    00139       SliderWheelieConf conf;
    00140       conf.segmNumber = 8;       //  number of snake elements
    00141       conf.segmLength = 0.4;     // length of one snake element
    00142       conf.segmDia    = 0.2;     //  diameter of a snake element
    00143       conf.segmMass   = 0.4;     //  mass of one snake element
    00144       conf.motorPower = 5;       //  power of the servos
    00145       conf.motorDamp  = 0.01;    //  damping of servos
    00146       conf.powerRatio = 2;       //  power of the servos
    00147       conf.sensorFactor    = 1;   //  scale for sensors
    00148       conf.frictionGround  = 0.8; // friction with ground
    00149       conf.frictionJoint   = 0.0; // friction within joint
    00150       conf.jointLimitIn    =  M_PI/3;
    00151       conf.jointLimitOut   =  -1; // automatically set to 2*M_PI/segm_num
    00152       conf.sliderLength    =  1;
    00153       conf.motorType       = SliderWheelieConf::CenteredServo; // use centered servos
    00154       return conf;
    00155     }
    00156
    00157     virtual void place(const osg::Matrix& pose);
    00158
    00159     virtual void update();
    00160
    00161     void doInternalStuff(GlobalData& global);
    00162
    00163     bool collisionCallback(void *data, dGeomID o1, dGeomID o2);
    00164
    00165     virtual void setMotors ( const motor* motors, int motornumber );
    00166
    00167     virtual int getSensors ( sensor* sensors, int sensornumber );
    00168
    00169     virtual int getSensorNumber() { assert(created);
    00170       return hingeServos.size()+angularMotors.size()+sliderServos.size(); }
    00171
    00172     virtual int getMotorNumber(){ assert(created);
    00173       return hingeServos.size()+angularMotors.size()+sliderServos.size(); }
    00174
    00175     virtual Primitive* getMainPrimitive() const {
    00176       if(center) return center;
    00177       else if(!objects.empty()){
    00178         return (objects[0]);
    00179       }else return 0;
    00180     }
    00181
    00182     virtual paramlist getParamList() const;
    00183
    00184     virtual paramval getParam(const paramkey& key) const;
    00185
    00186     virtual bool setParam(const paramkey& key, paramval val);
    00187
    00188   private:
    00189     static void mycallback(void *data, dGeomID o1, dGeomID o2);
    00190
    00191     virtual void create(const osg::Matrix& pose);
    00192     virtual void destroy();
    00193   };
    00194
    00195 }
    00196
    00197 #endif