Robotsystem of the Robot Group Leipzig: nimm2.h Source File

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

- Search for |

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