formel1.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: formel1.h,v $
00023  *   Revision 1.2.4.5  2006/03/30 12:34:56  martius
00024  *   documentation updated
00025  *
00026  *   Revision 1.2.4.4  2006/01/12 14:47:47  martius
00027  *   just taken from nimm4
00028  *
00029  *   Revision 1.2.4.3  2005/11/16 11:26:52  martius
00030  *   moved to selforg
00031  *
00032  *   Revision 1.2.4.2  2005/11/15 12:29:26  martius
00033  *   new selforg structure and OdeAgent, OdeRobot ...
00034  *
00035  *   Revision 1.2.4.1  2005/11/14 17:37:17  martius
00036  *   moved to selforg
00037  *
00038  *   Revision 1.2  2005/09/22 12:24:37  martius
00039  *   removed global variables
00040  *   OdeHandle and GlobalData are used instead
00041  *   sensor prepared
00042  *
00043  *   Revision 1.1  2005/08/09 10:44:54  robot1
00044  *   first vehicle for formel1 simulation
00045  *
00046  *
00047  *                                                                 *
00048  ***************************************************************************/
00049 #ifndef __FORMEL1_H
00050 #define __FORMEL1_H
00051 
00052 #include "oderobot.h"
00053 
00054 namespace lpzrobots {
00055 
00056   class Primitive;
00057   class Joint;
00058 
00059   /** Robot that looks like a Nimm 2 Bonbon :-)
00060       4 wheels and a capsule like body   
00061   */
00062   class Formel1 : public OdeRobot{
00063   public:
00064   
00065     Formel1(const OdeHandle& odeHandle, const OsgHandle& osgHandle, 
00066           double size=1, double force=3, double speed=15, bool sphereWheels=true);
00067 
00068     virtual ~Formel1(){};
00069 
00070     /**
00071      * updates the OSG nodes of the vehicle
00072      */
00073     virtual void update();
00074 
00075 
00076     /** sets the pose of the vehicle
00077         @param pose desired pose matrix
00078     */
00079     virtual void place(const osg::Matrix& pose);
00080 
00081     /** returns actual sensorvalues
00082         @param sensors sensors scaled to [-1,1] 
00083         @param sensornumber length of the sensor array
00084         @return number of actually written sensors
00085     */
00086     virtual int getSensors(sensor* sensors, int sensornumber);
00087 
00088     /** sets actual motorcommands
00089         @param motors motors scaled to [-1,1] 
00090         @param motornumber length of the motor array
00091     */
00092     virtual void setMotors(const motor* motors, int motornumber);
00093 
00094     /** returns number of sensors
00095      */
00096     virtual int getSensorNumber(){
00097       return sensorno;
00098     };
00099 
00100     /** returns number of motors
00101      */
00102     virtual int getMotorNumber(){
00103       return motorno;
00104     };
00105 
00106     /** checks for internal collisions and treats them. 
00107      *  In case of a treatment return true (collision will be ignored by other objects 
00108      *  and the default routine)  else false (collision is passed to other objects and 
00109      *  (if not treated) to the default routine).
00110      */
00111     virtual bool collisionCallback(void *data, dGeomID o1, dGeomID o2);
00112 
00113     /** this function is called in each timestep. It should perform robot-internal checks, 
00114         like space-internal collision detection, sensor resets/update etc.
00115         @param globalData structure that contains global data from the simulation environment
00116     */
00117     virtual void doInternalStuff(const GlobalData& globalData);
00118 
00119 
00120   protected:
00121     /** the main object of the robot, which is used for position and speed tracking */
00122     virtual Primitive* getMainPrimitive() const { return object[0]; }
00123 
00124     /** creates vehicle at desired pose
00125         @param pose 4x4 pose matrix
00126     */
00127     virtual void create(const osg::Matrix& pose); 
00128 
00129     /** destroys vehicle and space
00130      */
00131     virtual void destroy();
00132 
00133     /** additional things for collision handling can be done here
00134      */
00135     static void mycallback(void *data, dGeomID o1, dGeomID o2);
00136 
00137     double length;  // chassis length
00138     double width;  // chassis width
00139     double height;   // chassis height
00140     double radius;  // wheel radius
00141     double wheelthickness; // thickness of the wheels  
00142     bool sphereWheels; // draw spherical wheels?
00143     double cmass;    // chassis mass
00144     double wmass;    // wheel mass
00145     int sensorno;      //number of sensors
00146     int motorno;       // number of motors
00147     int segmentsno;    // number of motorsvehicle segments
00148     double speed;    // 
00149 
00150     double max_force;        // maximal force for motors
00151 
00152     bool created;      // true if robot was created
00153 
00154     Primitive* object[5];  // 1 capsule, 4 wheels
00155     Hinge2Joint* joint[4]; // joints between cylinder and each wheel
00156 
00157   };
00158 
00159 }
00160 
00161 #endif

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