Robotsystem from Robot Group Leipzig: nimm2.h Source File

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# nimm2.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: nimm2.h,v $
    00023  *   Revision 1.17.4.9  2006/03/30 12:34:56  martius
    00024  *   documentation updated
    00025  *
    00026  *   Revision 1.17.4.8  2006/01/31 15:36:14  martius
    00027  *   irRange in config
    00028  *
    00029  *   Revision 1.17.4.7  2006/01/17 17:02:19  martius
    00030  *   faster, stronger, more friction
    00031  *
    00032  *   Revision 1.17.4.6  2005/12/15 17:04:08  martius
    00033  *   Primitives are not longer inherited from OSGPrimitive, moreover
    00034  *   they aggregate them.
    00035  *   Joint have better getter and setter
    00036  *
    00037  *   Revision 1.17.4.5  2005/12/14 15:37:09  martius
    00038  *   robots are working with osg
    00039  *
    00040  *   Revision 1.17.4.4  2005/12/13 18:11:39  martius
    00041  *   still trying to port robots
    00042  *
    00043  *   Revision 1.17.4.3  2005/11/16 11:26:52  martius
    00044  *   moved to selforg
    00045  *
    00046  *   Revision 1.17.4.2  2005/11/15 12:29:26  martius
    00047  *   new selforg structure and OdeAgent, OdeRobot ...
    00048  *
    00049  *   Revision 1.17.4.1  2005/11/14 17:37:17  martius
    00050  *   moved to selforg
    00051  *
    00052  *   Revision 1.17  2005/09/27 14:11:37  martius
    00053  *   changed to use of Nimm2Conf
    00054  *   IR sensors at front
    00055  *
    00056  *   Revision 1.16  2005/09/22 12:24:37  martius
    00057  *   removed global variables
    00058  *   OdeHandle and GlobalData are used instead
    00059  *   sensor prepared
    00060  *
    00061  *   Revision 1.15  2005/09/22 11:22:15  martius
    00062  *   removed global variables
    00063  *   OdeHandle and GlobalData are used instead
    00064  *   sensor prepared
    00065  *
    00066  *   Revision 1.14  2005/08/31 11:12:46  martius
    00067  *   removed unused vars
    00068  *
    00069  *   Revision 1.13  2005/08/03 11:43:03  fhesse
    00070  *   wheels moved out of center in cigarMode
    00071  *
    00072  *   Revision 1.12  2005/08/02 13:35:53  fhesse
    00073  *   cigarMode added
    00074  *
    00075  *   Revision 1.11  2005/08/02 13:17:10  fhesse
    00076  *   bumper added
    00077  *
    00078  *   Revision 1.10  2005/07/31 22:31:15  martius
    00079  *   textures
    00080  *
    00081  *   Revision 1.9  2005/07/29 15:12:51  martius
    00082  *   color modified
    00083  *   spherical wheels are standart but adjustable
    00084  *
    00085  *   Revision 1.8  2005/07/26 17:03:25  martius
    00086  *   resizeable
    00087  *   forces and collisions fixed
    00088  *
    00089  *   Revision 1.7  2005/07/18 14:47:41  martius
    00090  *   world, space, contactgroup are not pointers anymore.
    00091  *
    00092  *   Revision 1.6  2005/07/08 09:33:28  martius
    00093  *   speed and force as optional constuctor parameter
    00094  *
    00095  *   Revision 1.5  2005/07/07 09:27:40  martius
    00096  *   proper collision detection in car_space
    00097  *
    00098  *   Revision 1.4  2005/07/06 16:04:39  martius
    00099  *   added collisioncallback to robot to perform smoother collisions of wheels with ground
    00100  *
    00101  *   Revision 1.3  2005/06/23 13:31:15  fhesse
    00102  *   Vehicle changed to Nimm2
    00103  *
    00104  *                                                                 *
    00105  ***************************************************************************/
    00106 #ifndef __NIMM2_H
    00107 #define __NIMM2_H
    00108
    00109 #include "oderobot.h"
    00110 #include "raysensorbank.h"
    00111
    00112 #include "primitive.h"
    00113 #include "joint.h"
    00114
    00115 namespace lpzrobots {
    00116
    00117 typedef struct Bumper{
    00118   Bumper() { trans = 0; bump = 0;}
    00119   Primitive* trans;
    00120   Primitive* bump;
    00121 } Bumper;
    00122
    00123 typedef struct {
    00124   double size;
    00125   double force;
    00126   double speed;
    00127   bool sphereWheels;
    00128   bool bumper;
    00129   bool cigarMode;
    00130   bool irFront;
    00131   bool irBack;
    00132   bool irSide;
    00133   double irRange;
    00134   bool singleMotor;
    00135 } Nimm2Conf;
    00136
    00137 /** Robot that looks like a Nimm 2 Bonbon :-)
    00138     2 wheels and a cylinder like body
    00139 */
    00140 class Nimm2 : public OdeRobot{
    00141 public:
    00142
    00143   Nimm2(const OdeHandle& odehandle, const OsgHandle& osgHandle, const Nimm2Conf& conf);
    00144
    00145   static Nimm2Conf getDefaultConf(){
    00146     Nimm2Conf conf;
    00147     conf.size=1;
    00148     conf.force=8;
    00149     conf.speed=12;
    00150     conf.sphereWheels=true;
    00151     conf.bumper=false;
    00152     conf.cigarMode=false;
    00153     conf.irFront=false;
    00154     conf.irBack=false;
    00155     conf.irSide=false;
    00156     conf.irRange=3;
    00157     conf.singleMotor=false;
    00158     return conf;
    00159   }
    00160
    00161   virtual ~Nimm2(){};
    00162
    00163   /**
    00164    * updates the OSG nodes of the vehicle
    00165    */
    00166   virtual void update();
    00167
    00168   /** sets the pose of the vehicle
    00169       @param pose desired 4x4 pose matrix
    00170   */
    00171   virtual void place(const osg::Matrix& pose);
    00172
    00173   /** returns actual sensorvalues
    00174       @param sensors sensors scaled to [-1,1]
    00175       @param sensornumber length of the sensor array
    00176       @return number of actually written sensors
    00177   */
    00178   virtual int getSensors(sensor* sensors, int sensornumber);
    00179
    00180   /** sets actual motorcommands
    00181       @param motors motors scaled to [-1,1]
    00182       @param motornumber length of the motor array
    00183   */
    00184   virtual void setMotors(const motor* motors, int motornumber);
    00185
    00186   /** returns number of sensors
    00187    */
    00188   virtual int getSensorNumber(){
    00189     return sensorno;
    00190   };
    00191
    00192   /** returns number of motors
    00193    */
    00194   virtual int getMotorNumber(){
    00195     return motorno;
    00196   };
    00197
    00198   /** returns a vector with the positions of all segments of the robot
    00199       @param poslist vector of positions (of all robot segments)
    00200       @return length of the list
    00201   */
    00202   virtual int getSegmentsPosition(vector<Position> &poslist);
    00203
    00204   virtual bool collisionCallback(void *data, dGeomID o1, dGeomID o2);
    00205
    00206     /** this function is called in each timestep. It should perform robot-internal checks,
    00207       like space-internal collision detection, sensor resets/update etc.
    00208       @param globalData structure that contains global data from the simulation environment
    00209    */
    00210   virtual void doInternalStuff(const GlobalData& globalData);
    00211
    00212 protected:
    00213   /** the main object of the robot, which is used for position and speed tracking */
    00214   virtual Primitive* getMainPrimitive() const { return object[0]; }
    00215
    00216   /** creates vehicle at desired pose
    00217       @param pose 4x4 pose matrix
    00218   */
    00219   virtual void create(const osg::Matrix& pose);
    00220
    00221   /** destroys vehicle and space
    00222    */
    00223   virtual void destroy();
    00224   static void mycallback(void *data, dGeomID o1, dGeomID o2);
    00225
    00226   Nimm2Conf conf;
    00227
    00228   double length;  // chassis length
    00229   double width;  // chassis width
    00230   double height;   // chassis height
    00231   double radius;  // wheel radius
    00232   double wheelthickness; // thickness of the wheels
    00233   double cmass;    // chassis mass
    00234   double wmass;    // wheel mass
    00235   int sensorno;      //number of sensors
    00236   int motorno;       // number of motors
    00237
    00238   bool created;      // true if robot was created
    00239   double max_force;
    00240
    00241   Primitive* object[3];  // 1 cylinder, 2 wheels
    00242   double  wheeloffset; // offset from center when in cigarMode
    00243   int number_bumpers;  // number of bumpers (1 -> bumpers at one side, 2 -> bumpers at 2 sides)
    00244   Bumper bumper[2];
    00245   Hinge2Joint* joint[2]; // joints between cylinder and each wheel
    00246
    00247   RaySensorBank irSensorBank; // a collection of ir sensors
    00248 };
    00249
    00250 }
    00251
    00252 #endif