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

Generated on Mon Aug 7 16:40:14 2006 for Robotsystem of the Robot Group Leipzig by  doxygen 1.4.7