forcedsphere.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  ***************************************************************************
00023  *                                                                         *
00024  * Spherical Robot magically driven                                        *
00025  *                                                                         *
00026  *   $Log: forcedsphere.h,v $
00027  *   Revision 1.2.4.5  2006/03/30 12:34:56  martius
00028  *   documentation updated
00029  *
00030  *   Revision 1.2.4.4  2006/01/10 22:25:09  martius
00031  *   moved to osg
00032  *
00033  *
00034  *                                                                 *
00035  ***************************************************************************/
00036 
00037 #ifndef __FORCESSPHERE_H
00038 #define __FORCESSPHERE_H
00039 
00040 #include "oderobot.h"
00041 
00042 namespace lpzrobots {
00043 
00044   class Primitive;
00045 
00046   class ForcedSphere : public OdeRobot
00047   {
00048   protected:
00049     Primitive* object[1];
00050     double radius;
00051     double max_force;
00052     bool created;
00053 
00054   public:
00055   
00056     /**
00057      *constructor
00058      **/ 
00059     ForcedSphere ( const OdeHandle& odeHandle, const OsgHandle& osgHandle,
00060                    const char* name, double radius=1, double max_force=1);
00061   
00062     virtual ~ForcedSphere();
00063         
00064     /// update all primitives and joints
00065     virtual void update();
00066 
00067     /** sets the pose of the vehicle
00068         @param pose desired 4x4 pose matrix
00069     */
00070     virtual void place(const osg::Matrix& pose);
00071   
00072     /**
00073      *This is the collision handling function for snake robots.
00074      *This overwrides the function collisionCallback of the class robot.
00075      *@param data
00076      *@param o1 first geometrical object, which has taken part in the collision
00077      *@param o2 second geometrical object, which has taken part in the collision
00078      *@return true if the collision was threated  by the robot, false if not
00079      **/
00080     virtual bool collisionCallback(void *data, dGeomID o1, dGeomID o2);
00081     /** this function is called in each timestep. It should perform robot-internal checks, 
00082         like space-internal collision detection, sensor resets/update etc.
00083         @param globalData structure that contains global data from the simulation environment
00084     */
00085     virtual void doInternalStuff(const GlobalData& globalData);
00086         
00087     /**
00088      *Writes the sensor values to an array in the memory.
00089      *@param sensors pointer to the array
00090      *@param sensornumber length of the sensor array
00091      *@return number of actually written sensors
00092      **/
00093     virtual int getSensors ( sensor* sensors, int sensornumber );
00094         
00095     /**
00096      *Reads the actual motor commands from an array, an sets all motors of the snake to this values.
00097      *It is an linear allocation.
00098      *@param motors pointer to the array, motor values are scaled to [-1,1] 
00099      *@param motornumber length of the motor array
00100      **/
00101     virtual void setMotors ( const motor* motors, int motornumber );
00102         
00103     /**
00104      *Returns the number of motors used by the snake.
00105      *@return number of motors
00106      **/
00107     virtual int getMotorNumber();
00108   
00109     /**
00110      *Returns the number of sensors used by the robot.
00111      *@return number of sensors
00112      **/
00113     virtual int getSensorNumber();
00114         
00115  
00116   protected:
00117     /** the main object of the robot, which is used for position and speed tracking */
00118     virtual Primitive* getMainPrimitive() const { return object[0]; }
00119 
00120     /** creates vehicle at desired pose
00121         @param pose 4x4 pose matrix
00122     */
00123     virtual void create(const osg::Matrix& pose); 
00124     virtual void destroy(); 
00125 
00126 
00127   };
00128 
00129 }
00130 
00131 #endif

Generated on Tue Apr 4 19:05:03 2006 for Robotsystem from Robot Group Leipzig by  doxygen 1.4.5