nimm2.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2011 LpzRobots development team                    *
00003  *    Georg Martius  <georg dot martius at web dot de>                     *
00004  *    Frank Guettler <guettler at informatik dot uni-leipzig dot de        *
00005  *    Frank Hesse    <frank at nld dot ds dot mpg dot de>                  *
00006  *    Ralf Der       <ralfder at mis dot mpg dot de>                       *
00007  *                                                                         *
00008  *   This program is free software; you can redistribute it and/or modify  *
00009  *   it under the terms of the GNU General Public License as published by  *
00010  *   the Free Software Foundation; either version 2 of the License, or     *
00011  *   (at your option) any later version.                                   *
00012  *                                                                         *
00013  *   This program is distributed in the hope that it will be useful,       *
00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00016  *   GNU General Public License for more details.                          *
00017  *                                                                         *
00018  *   You should have received a copy of the GNU General Public License     *
00019  *   along with this program; if not, write to the                         *
00020  *   Free Software Foundation, Inc.,                                       *
00021  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00022  *                                                                         *
00023  ***************************************************************************/
00024 #ifndef __NIMM2_H
00025 #define __NIMM2_H
00026 
00027 #include "oderobot.h"
00028 #include "raysensorbank.h"
00029 
00030 #include "primitive.h"
00031 #include "joint.h"
00032 #include <selforg/inspectable.h>
00033 
00034 
00035 namespace lpzrobots {
00036 
00037 typedef struct Bumper{
00038   Bumper() { trans = 0; bump = 0;}
00039   Primitive* trans;
00040   Primitive* bump;
00041 } Bumper;
00042 
00043 typedef struct {
00044   double size;
00045   double force;
00046   double speed;
00047   double massFactor;
00048   bool sphereWheels;
00049   double wheelSize; ///< size of the wheels in body diameters
00050   double wheelSlip; 
00051   std::string wheelTexture;
00052   bool bumper;
00053   bool cigarMode;
00054   double cigarLength;
00055   bool irFront;
00056   bool irBack;
00057   bool irSide;
00058   double irRange;
00059   bool singleMotor;
00060   bool visForce;
00061   bool boxMode;
00062   double  boxWidth;
00063 } Nimm2Conf;
00064 
00065 /** Robot that looks like a Nimm 2 Bonbon :-)
00066     2 wheels and a cylinder like body
00067 
00068     wheel order: left, right
00069     IR order: front left, front right, right, right rear, 
00070               rear right, rear left, left rear, left
00071 */
00072 class Nimm2 : public OdeRobot /*, public Inspectable*/ {
00073 public:
00074 
00075   Nimm2(const OdeHandle& odehandle, const OsgHandle& osgHandle,
00076         const Nimm2Conf& conf, const std::string& name);
00077 
00078   static Nimm2Conf getDefaultConf(){
00079     Nimm2Conf conf;
00080     conf.size=1;
00081     conf.force=5;
00082     conf.speed=12;
00083     conf.massFactor=1;
00084     conf.sphereWheels=true;
00085     conf.wheelSize=1;
00086     conf.wheelSlip=0;
00087     conf.bumper=false;
00088     conf.cigarMode=false;
00089     conf.cigarLength=2.0;
00090     conf.irFront=false;
00091     conf.irBack=false;
00092     conf.irSide=false;
00093     conf.irRange=3;
00094     conf.singleMotor=false;
00095     conf.visForce=false;
00096     conf.boxMode=false;
00097     conf.boxWidth=1.0;
00098     conf.wheelTexture="Images/tire.rgb";
00099     return conf;
00100   }
00101 
00102   virtual ~Nimm2();
00103 
00104   /**
00105    * updates the OSG nodes of the vehicle
00106    */
00107   virtual void update();
00108 
00109   /** sets the pose of the vehicle
00110       @param pose desired 4x4 pose matrix
00111   */
00112   virtual void place(const osg::Matrix& pose);
00113 
00114   /** returns actual sensorvalues
00115       @param sensors sensors scaled to [-1,1]
00116       @param sensornumber length of the sensor array
00117       @return number of actually written sensors
00118   */
00119   virtual int getSensors(sensor* sensors, int sensornumber);
00120 
00121   /** sets actual motorcommands
00122       @param motors motors scaled to [-1,1]
00123       @param motornumber length of the motor array
00124   */
00125   virtual void setMotors(const motor* motors, int motornumber);
00126 
00127   /** returns number of sensors
00128    */
00129   virtual int getSensorNumber(){
00130     return sensorno;
00131   };
00132 
00133   /** returns number of motors
00134    */
00135   virtual int getMotorNumber(){
00136     return motorno;
00137   };
00138 
00139   /** returns a vector with the positions of all segments of the robot
00140       @param poslist vector of positions (of all robot segments)
00141       @return length of the list
00142   */
00143   virtual int getSegmentsPosition(std::vector<Position> &poslist);
00144 
00145 
00146     /** this function is called in each timestep. It should perform robot-internal checks,
00147       like space-internal collision detection, sensor resets/update etc.
00148       @param globalData structure that contains global data from the simulation environment
00149    */
00150   virtual void doInternalStuff(GlobalData& globalData);
00151 
00152         virtual double& getSumForce() { return sumForce; }
00153 
00154         virtual double& getContactPoints() { return contactPoints; }
00155 
00156 protected:
00157 
00158   double contactPoints;
00159 
00160 
00161   /** creates vehicle at desired pose
00162       @param pose 4x4 pose matrix
00163   */
00164   virtual void create(const osg::Matrix& pose);
00165 
00166 
00167 
00168   /** destroys vehicle and space
00169    */
00170   virtual void destroy();
00171   static void mycallback(void *data, dGeomID o1, dGeomID o2);
00172 
00173         /**
00174          * Inspectable interface
00175          */
00176         /*
00177         virtual std::list<iparamkey> getInternalParamNames() const  { return std::list<iparamkey>(); }
00178 
00179         virtual std::list<iparamval> getInternalParams() const { return std::list<iparamval>(); }*/
00180         /*
00181         virtual std::list<Inspectable::iparamkey> getInternalParamNames() const;
00182 
00183         virtual std::list<Inspectable::iparamval> getInternalParams() const;
00184         */
00185 
00186   Nimm2Conf conf;
00187 
00188   double length;  // chassis length
00189   double width;  // chassis width
00190   double height;   // chassis height
00191   double radius;  // wheel radius
00192   double wheelthickness; // thickness of the wheels
00193   double cmass;    // chassis mass
00194   double wmass;    // wheel mass
00195   int sensorno;      //number of sensors
00196   int motorno;       // number of motors
00197 
00198   bool created;      // true if robot was created
00199   double max_force;
00200 
00201   double  wheeloffset; // offset from center when in cigarMode
00202   int number_bumpers;  // number of bumpers (1 -> bumpers at one side, 2 -> bumpers at 2 sides)
00203   Bumper bumper[2];
00204 
00205   RaySensorBank irSensorBank; // a collection of ir sensors
00206 
00207         bool visForce; // decides if contact force is made visible in guilogger
00208         double sumForce; // stores the contact force made by collisions with external objects
00209 
00210 };
00211 
00212 }
00213 
00214 #endif
Generated on Thu Jun 28 14:45:36 2012 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.6.3