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

Generated on Fri Oct 30 16:29:01 2009 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.4.7