nimm4.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: nimm4.h,v $
00023  *   Revision 1.6  2006/07/14 12:23:41  martius
00024  *   selforg becomes HEAD
00025  *
00026  *   Revision 1.5.4.13  2006/06/25 16:57:14  martius
00027  *   abstractrobot is configureable
00028  *   name and revision
00029  *
00030  *   Revision 1.5.4.12  2006/04/04 14:13:24  fhesse
00031  *   documentation improved
00032  *
00033  *   Revision 1.5.4.11  2006/03/31 16:20:28  fhesse
00034  *   class Joint; changed to: class Hinge2Joint;
00035  *
00036  *   Revision 1.5.4.10  2006/03/30 12:34:56  martius
00037  *   documentation updated
00038  *
00039  *   Revision 1.5.4.9  2005/12/15 17:04:08  martius
00040  *   Primitives are not longer inherited from OSGPrimitive, moreover
00041  *   they aggregate them.
00042  *   Joint have better getter and setter
00043  *
00044  *   Revision 1.5.4.8  2005/12/14 15:37:09  martius
00045  *   robots are working with osg
00046  *
00047  *   Revision 1.5.4.7  2005/12/13 18:11:40  martius
00048  *   still trying to port robots
00049  *
00050  *   Revision 1.5.4.6  2005/12/12 23:41:19  martius
00051  *   added Joint wrapper
00052  *
00053  *   Revision 1.5.4.5  2005/12/11 23:35:08  martius
00054  *   *** empty log message ***
00055  *
00056  *   Revision 1.5.4.4  2005/12/06 10:13:25  martius
00057  *   openscenegraph integration started
00058  *
00059  *   Revision 1.5.4.3  2005/11/16 11:26:52  martius
00060  *   moved to selforg
00061  *
00062  *   Revision 1.5.4.2  2005/11/15 12:29:26  martius
00063  *   new selforg structure and OdeAgent, OdeRobot ...
00064  *
00065  *   Revision 1.5.4.1  2005/11/14 17:37:18  martius
00066  *   moved to selforg
00067  *
00068  *   Revision 1.5  2005/10/27 16:10:41  fhesse
00069  *   nimm4 as example
00070  *
00071  *   Revision 1.4  2005/09/22 12:24:37  martius
00072  *   removed global variables
00073  *   OdeHandle and GlobalData are used instead
00074  *   sensor prepared
00075  *
00076  *   Revision 1.3  2005/08/31 11:14:06  martius
00077  *   removed unused vars
00078  *
00079  *   Revision 1.2  2005/08/03 20:38:56  martius
00080  *   added textures and correct placement
00081  *
00082  *   Revision 1.1  2005/07/29 15:13:11  martius
00083  *   a robot with 4 independent wheels
00084  *
00085  *                                                                 *
00086  ***************************************************************************/
00087 #ifndef __NIMM4_H
00088 #define __NIMM4_H
00089 
00090 #include "oderobot.h"
00091 
00092 namespace lpzrobots {
00093 
00094   class Primitive; 
00095   class Hinge2Joint; 
00096 
00097   /** Robot that looks like a Nimm 2 Bonbon :-)
00098       4 wheels and a capsule like body   
00099   */
00100   class Nimm4 : public OdeRobot{
00101   public:
00102   
00103     /**
00104      * constructor of nimm4 robot
00105      * @param odeHandle data structure for accessing ODE
00106      * @param osgHandle ata structure for accessing OSG
00107      * @param size scaling of robot
00108      * @param force maximal used force to realize motorcommand
00109      * @param speed factor for changing speed of robot
00110      * @param sphereWheels switches between spheres and  'normal' wheels 
00111      */
00112     Nimm4(const OdeHandle& odeHandle, const OsgHandle& osgHandle, const std::string& name,
00113           double size=1, double force=3, double speed=15, bool sphereWheels=true);
00114 
00115     virtual ~Nimm4(){};
00116 
00117     /**
00118      * updates the OSG nodes of the vehicle
00119      */
00120     virtual void update();
00121 
00122 
00123     /** sets the pose of the vehicle
00124         @param pose desired pose matrix
00125     */
00126     virtual void place(const osg::Matrix& pose);
00127 
00128     /** returns actual sensorvalues
00129         @param sensors sensors scaled to [-1,1] 
00130         @param sensornumber length of the sensor array
00131         @return number of actually written sensors
00132     */
00133     virtual int getSensors(sensor* sensors, int sensornumber);
00134 
00135     /** sets actual motorcommands
00136         @param motors motors scaled to [-1,1] 
00137         @param motornumber length of the motor array
00138     */
00139     virtual void setMotors(const motor* motors, int motornumber);
00140 
00141     /** returns number of sensors
00142      */
00143     virtual int getSensorNumber(){
00144       return sensorno;
00145     };
00146 
00147     /** returns number of motors
00148      */
00149     virtual int getMotorNumber(){
00150       return motorno;
00151     };
00152 
00153     /** checks for internal collisions and treats them. 
00154      *  In case of a treatment return true (collision will be ignored by other objects 
00155      *  and the default routine)  else false (collision is passed to other objects and 
00156      *  (if not treated) to the default routine).
00157      */
00158     virtual bool collisionCallback(void *data, dGeomID o1, dGeomID o2);
00159 
00160     /** this function is called in each timestep. It should perform robot-internal checks, 
00161         like space-internal collision detection, sensor resets/update etc.
00162         @param globalData structure that contains global data from the simulation environment
00163     */
00164     virtual void doInternalStuff(const GlobalData& globalData);
00165 
00166 
00167   protected:
00168     /** the main object of the robot, which is used for position and speed tracking */
00169     virtual Primitive* getMainPrimitive() const { return object[0]; }
00170 
00171     /** creates vehicle at desired pose
00172         @param pose 4x4 pose matrix
00173     */
00174     virtual void create(const osg::Matrix& pose); 
00175 
00176     /** destroys vehicle and space
00177      */
00178     virtual void destroy();
00179 
00180     /** additional things for collision handling can be done here
00181      */
00182     static void mycallback(void *data, dGeomID o1, dGeomID o2);
00183 
00184     double length;     // chassis length
00185     double width;      // chassis width
00186     double height;     // chassis height
00187     double radius;     // wheel radius
00188     double wheelthickness; // thickness of the wheels  
00189     bool sphereWheels; // draw spherical wheels?
00190     double cmass;      // chassis mass
00191     double wmass;      // wheel mass
00192     int sensorno;      // number of sensors
00193     int motorno;       // number of motors
00194     int segmentsno;    // number of motorsvehicle segments
00195     double speed;      // factor for adjusting speed of robot
00196 
00197     double max_force;  // maximal force for motors
00198 
00199     bool created;      // true if robot was created
00200 
00201     Primitive* object[5];  // 1 capsule, 4 wheels
00202     Hinge2Joint* joint[4]; // joints between cylinder and each wheel
00203 
00204   };
00205 
00206 }
00207 
00208 #endif

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