Robotsystem of the Robot Group Leipzig: defaultSliderWheelie.h Source File

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

- Search for |

- File List
- File Members

# defaultSliderWheelie.h

Go to the documentation of this file.

    00001 /************************************************************************/
    00002 /* originally from:                                                     */
    00003 /* schlange.h                                                           */
    00004 /* Abstract class for Snakes                                            */
    00005 /* @author Georg Martius                                                */
    00006 /************************************************************************/
    00007 /* here:                                                                */
    00008 /* defaultSliderWheelie.h                                               */
    00009 /* Abstract class for SliderWheelies                                    */
    00010 /* @author Frank Guettler                                               */
    00011 /************************************************************************/
    00012 /***************************************************************************
    00013  *   Copyright (C) 2005 by Robot Group Leipzig                             *
    00014  *    martius@informatik.uni-leipzig.de                                    *
    00015  *    fhesse@informatik.uni-leipzig.de                                     *
    00016  *    der@informatik.uni-leipzig.de                                        *
    00017  *    frankguettler@gmx.de                                                 *
    00018  *                                                                         *
    00019  *   This program is free software; you can redistribute it and/or modify  *
    00020  *   it under the terms of the GNU General Public License as published by  *
    00021  *   the Free Software Foundation; either version 2 of the License, or     *
    00022  *   (at your option) any later version.                                   *
    00023  *                                                                         *
    00024  *   This program is distributed in the hope that it will be useful,       *
    00025  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
    00026  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
    00027  *   GNU General Public License for more details.                          *
    00028  *                                                                         *
    00029  *   You should have received a copy of the GNU General Public License     *
    00030  *   along with this program; if not, write to the                         *
    00031  *   Free Software Foundation, Inc.,                                       *
    00032  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
    00033  *                                                                         *
    00034  *   $Log: defaultSliderWheelie.h,v $
    00035  *   Revision 1.3  2006/07/20 17:19:44  martius
    00036  *   removed using namespace std from matrix.h
    00037  *
    00038  *   Revision 1.2  2006/07/14 12:23:39  martius
    00039  *   selforg becomes HEAD
    00040  *
    00041  *   Revision 1.1.2.4  2006/06/26 20:33:50  robot5
    00042  *   Joint adjustments.
    00043  *
    00044  *   Revision 1.1.2.3  2006/06/25 16:57:12  martius
    00045  *   abstractrobot is configureable
    00046  *   name and revision
    00047  *
    00048  *   Revision 1.1.2.2  2006/06/20 07:18:29  robot3
    00049  *   -added cvs log
    00050  *   -changed some behaviour of wheelie
    00051  *
    00052  *                                                                         *
    00053  ***************************************************************************/
    00054 #ifndef __DEFAULTSLIDERWHEELIE_H
    00055 #define __DEFAULTSLIDERWHEELIE_H
    00056
    00057 #include<vector>
    00058 #include<assert.h>
    00059
    00060 #include"primitive.h"
    00061 #include "joint.h"
    00062 #include "angularmotor.h"
    00063
    00064 #include "oderobot.h"
    00065 #include <selforg/configurable.h>
    00066
    00067 namespace lpzrobots {
    00068
    00069 typedef struct {
    00070 public:
    00071   int    segmNumber;  //<  number of snake elements
    00072   double segmLength;  //< length of one snake element
    00073   double segmDia;     //<  diameter of a snake element
    00074   double segmMass;    //<  mass of one snake element
    00075   double motorPower;  //<  power of the motors / servos
    00076   double sensorFactor;    //<  scale for sensors
    00077   double frictionGround;  //< friction with ground
    00078   double frictionJoint;   //< friction within joint
    00079   double jointLimit;      //< maximal angle for the joints (M_PI/2 = 90 degree)
    00080 } SliderWheelieConf;
    00081
    00082
    00083 /**
    00084  * This is a class, which models a snake like robot.
    00085  * It consists of a number of equal elements, each linked
    00086  * by a joint
    00087  **/
    00088 class DefaultSliderWheelie: public OdeRobot
    00089 {
    00090 protected:
    00091
    00092   bool created;
    00093
    00094   std::vector <Primitive*> objects;
    00095   std::vector <Joint*> joints;
    00096   std::vector <AngularMotor*> frictionmotors;
    00097   SliderWheelieConf conf;
    00098
    00099 public:
    00100   DefaultSliderWheelie(const OdeHandle& odeHandle, const OsgHandle& osgHandle,
    00101              const SliderWheelieConf& conf, const std::string& name, const std::string& revision);
    00102
    00103   static SliderWheelieConf getDefaultConf(){
    00104     SliderWheelieConf conf;
    00105     conf.segmNumber = 8;    //  number of snake elements
    00106     conf.segmLength = 0.4;   // length of one snake element
    00107     conf.segmDia    = 0.2;   //  diameter of a snake element
    00108     conf.segmMass   = 0.4;   //  mass of one snake element
    00109     conf.motorPower = 0.2;    //  power of the servos
    00110     conf.sensorFactor = 1;    //  scale for sensors
    00111     conf.frictionGround = 1.0; // friction with ground
    00112     conf.frictionJoint = 0.1; // friction within joint
    00113     conf.jointLimit =  M_PI/8;
    00114     return conf;
    00115   }
    00116
    00117   virtual ~DefaultSliderWheelie();
    00118
    00119
    00120   /** sets the pose of the vehicle
    00121       @param pose desired 4x4 pose matrix
    00122   */
    00123   virtual void place(const osg::Matrix& pose);
    00124
    00125   /// update all primitives and joints
    00126   virtual void update();
    00127
    00128   /**
    00129    *This is the collision handling function for snake robots.
    00130    *This overwrides the function collisionCallback of the class robot.
    00131    *@param data
    00132    *@param o1 first geometrical object, which has taken part in the collision
    00133    *@param o2 second geometrical object, which has taken part in the collision
    00134    *@return true if the collision was threated  by the robot, false if not
    00135    **/
    00136   virtual bool collisionCallback(void *data, dGeomID o1, dGeomID o2);
    00137
    00138   static void mycallback(void *data, dGeomID o1, dGeomID o2);
    00139
    00140   virtual void doInternalStuff(const GlobalData& global);
    00141
    00142   /**
    00143    *Reads the actual motor commands from an array,
    00144    *an sets all motors of the snake to this values.
    00145    *It is an linear allocation.
    00146    *@param motors pointer to the array, motor values are scaled to [-1,1]
    00147    *@param motornumber length of the motor array
    00148    **/
    00149   virtual void setMotors ( const motor* motors, int motornumber ) = 0;
    00150
    00151   /**
    00152    *Writes the sensor values to an array in the memory.
    00153    *@param sensors pointer to the array
    00154    *@param sensornumber length of the sensor array
    00155    *@return number of actually written sensors
    00156    **/
    00157   virtual int getSensors ( sensor* sensors, int sensornumber ) = 0;
    00158
    00159   /** returns number of sensors
    00160    */
    00161   virtual int getSensorNumber() = 0;
    00162
    00163   /** returns number of motors
    00164    */
    00165   virtual int getMotorNumber() = 0;
    00166
    00167   /** returns a vector with the positions of all segments of the robot
    00168       @param poslist vector of positions (of all robot segments)
    00169       @return length of the list
    00170   */
    00171   virtual int getSegmentsPosition(std::vector<Position> &poslist);
    00172
    00173   /** The list of all parameters with there value as allocated lists.
    00174   */
    00175   virtual paramlist getParamList() const;
    00176
    00177   virtual paramval getParam(const paramkey& key) const;;
    00178
    00179   virtual bool setParam(const paramkey& key, paramval val);
    00180
    00181   /** the main object of the robot, which is used for position and speed tracking */
    00182   virtual Primitive* getMainPrimitive() const {
    00183     if(!objects.empty()){
    00184       //      int half = objects.size()/2;
    00185       //      return (objects[half]);
    00186       return (objects[0]);
    00187     }else return 0;
    00188   }
    00189 protected:
    00190
    00191   /** creates vehicle at desired pose
    00192       @param pose 4x4 pose matrix
    00193   */
    00194   virtual void create(const osg::Matrix& pose);
    00195   virtual void destroy();
    00196 };
    00197
    00198 }
    00199
    00200 #endif