Robot Simulator of the Robotics Group for Self-Organization of Control: formel1.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages
- Examples

- Search for |

- File List
- File Members

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