Robotsystem from Robot Group Leipzig: hurlingsnake.h Source File

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

- File List
- File Members

# hurlingsnake.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: hurlingsnake.h,v $
    00023  *   Revision 1.6.4.8  2006/03/30 12:34:56  martius
    00024  *   documentation updated
    00025  *
    00026  *   Revision 1.6.4.7  2006/03/30 08:43:05  fhesse
    00027  *   getTracePrimitive removed
    00028  *
    00029  *   Revision 1.6.4.6  2006/03/28 14:20:28  fhesse
    00030  *   getTracePrimitive() added
    00031  *
    00032  *   Revision 1.6.4.5  2005/12/30 22:54:38  martius
    00033  *   removed parentspace!
    00034  *
    00035  *   Revision 1.6.4.4  2005/12/21 17:35:09  martius
    00036  *   moved to osg
    00037  *
    00038  *   Revision 1.6.4.3  2005/11/16 11:26:52  martius
    00039  *   moved to selforg
    00040  *
    00041  *   Revision 1.6.4.2  2005/11/15 12:29:26  martius
    00042  *   new selforg structure and OdeAgent, OdeRobot ...
    00043  *
    00044  *   Revision 1.6.4.1  2005/11/14 17:37:17  martius
    00045  *   moved to selforg
    00046  *
    00047  *   Revision 1.6  2005/11/09 13:26:21  martius
    00048  *   added factorSensor
    00049  *
    00050  *   Revision 1.5  2005/10/06 17:14:24  martius
    00051  *   switched to stl lists
    00052  *
    00053  *   Revision 1.4  2005/09/22 12:24:37  martius
    00054  *   removed global variables
    00055  *   OdeHandle and GlobalData are used instead
    00056  *   sensor prepared
    00057  *
    00058  *   Revision 1.3  2005/08/31 17:18:15  fhesse
    00059  *   setTextures added, Mass is now sphere (not box anymore)
    00060  *
    00061  *   Revision 1.2  2005/07/26 17:04:21  martius
    00062  *   lives in its own space now
    00063  *
    00064  *   Revision 1.1  2005/07/21 12:17:04  fhesse
    00065  *   new hurling snake, todo: add collision space, clean up, comment
    00066  *
    00067  *
    00068  *                                                                 *
    00069  ***************************************************************************/
    00070 #ifndef __HURLINGSNAKE_H
    00071 #define __HURLINGSNAKE_H
    00072
    00073 #include "oderobot.h"
    00074 #include <selforg/configurable.h>
    00075 #include "primitive.h"
    00076 #include "joint.h"
    00077
    00078 namespace lpzrobots {
    00079
    00080   /**
    00081    * Hurling snake is a string a beats.
    00082    *
    00083    */
    00084   class HurlingSnake : public OdeRobot, public Configurable{
    00085   public:
    00086     /**
    00087      * Constructor
    00088      */
    00089     HurlingSnake(const OdeHandle& odeHandle, const OsgHandle& osgHandle);
    00090
    00091     /// update the subcomponents
    00092     virtual void update();
    00093
    00094     /** sets the pose of the vehicle
    00095         @param pose desired 4x4 pose matrix
    00096     */
    00097     virtual void place(const osg::Matrix& pose);
    00098
    00099     /** checks for internal collisions and treats them.
    00100      *  In case of a treatment return true (collision will be ignored by other objects and the default routine)
    00101      *  else false (collision is passed to other objects and (if not treated) to the default routine).
    00102      */
    00103     virtual bool collisionCallback(void *data, dGeomID o1, dGeomID o2);
    00104     /** this function is called in each timestep. It should perform robot-internal checks,
    00105         like space-internal collision detection, sensor resets/update etc.
    00106         @param globalData structure that contains global data from the simulation environment
    00107     */
    00108     virtual void doInternalStuff(const GlobalData& globalData);
    00109
    00110
    00111     /** returns actual sensorvalues
    00112         @param sensors sensors scaled to [-1,1]
    00113         @param sensornumber length of the sensor array
    00114         @return number of actually written sensors
    00115     */
    00116     virtual int getSensors(sensor* sensors, int sensornumber);
    00117
    00118     /** sets actual motorcommands
    00119         @param motors motors scaled to [-1,1]
    00120         @param motornumber length of the motor array
    00121     */
    00122     virtual void setMotors(const motor* motors, int motornumber);
    00123
    00124     /** returns number of sensors
    00125      */
    00126     virtual int getSensorNumber();
    00127
    00128     /** returns number of motors
    00129      */
    00130     virtual int getMotorNumber();
    00131
    00132     /** returns a vector with the positions of all segments of the robot
    00133         @param poslist vector of positions (of all robot segments)
    00134         @return length of the list
    00135     */
    00136     virtual int getSegmentsPosition(vector<Position> &poslist);
    00137
    00138     /// returns the name of the object (with version number)
    00139     virtual paramkey getName() const {return name; }
    00140
    00141     /** The list of all parameters with there value as allocated lists.
    00142     */
    00143     virtual paramlist getParamList() const;
    00144
    00145     virtual paramval getParam(const paramkey& key) const;
    00146
    00147     virtual bool setParam(const paramkey& key, paramval val);
    00148
    00149   protected:
    00150     /** the main object of the robot, which is used for position and speed tracking */
    00151     virtual Primitive* getMainPrimitive() const { return object[4] /*(center)*/; }
    00152     //virtual Primitive* getMainPrimitive() const { return object[NUM-1] /*(head element)*/; }
    00153
    00154
    00155   private:
    00156
    00157     /** creates vehicle at desired pose
    00158         @param pose 4x4 pose matrix
    00159     */
    00160     virtual void create(const osg::Matrix& pose);
    00161
    00162     /** destroys robot and space
    00163      */
    00164     virtual void destroy();
    00165
    00166     static void mycallback(void *data, dGeomID o1, dGeomID o2);
    00167
    00168     bool created;      // true if robot was created
    00169
    00170
    00171     Position initial_pos;    // initial position of robot
    00172
    00173     int NUM;       /* number of beats */
    00174     double MASS;           /* mass of a beats */
    00175     double RADIUS;   /* sphere radius */
    00176
    00177     Joint* joint[9];
    00178     Primitive* object[10];
    00179
    00180     Pos oldp;
    00181
    00182     int sensorno;
    00183     int motorno;
    00184
    00185     paramval factorForce;
    00186     paramval frictionGround;
    00187     paramval factorSensor;
    00188
    00189   };
    00190
    00191 }
    00192
    00193 #endif
    00194