robotchain.h

Go to the documentation of this file.
00001 
00002 /***************************************************************************
00003  *   Copyright (C) 2005-2012 LpzRobots development team                    *
00004  *    Georg Martius  <georg dot martius at web dot de>                     *
00005  *    Frank Guettler <guettler at informatik dot uni-leipzig dot de        *
00006  *    Frank Hesse    <frank at nld dot ds dot mpg dot de>                  *
00007  *    Ralf Der       <ralfder at mis dot mpg dot de>                       *
00008  *                                                                         *
00009  *   This program is free software; you can redistribute it and/or modify  *
00010  *   it under the terms of the GNU General Public License as published by  *
00011  *   the Free Software Foundation; either version 2 of the License, or     *
00012  *   (at your option) any later version.                                   *
00013  *                                                                         *
00014  *   This program is distributed in the hope that it will be useful,       *
00015  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00016  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00017  *   GNU General Public License for more details.                          *
00018  *                                                                         *
00019  *   You should have received a copy of the GNU General Public License     *
00020  *   along with this program; if not, write to the                         *
00021  *   Free Software Foundation, Inc.,                                       *
00022  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00023  *                                                                         *
00024  ***************************************************************************/
00025 #ifndef __ROBOTCHAIN_H
00026 #define __ROBOTCHAIN_H
00027 
00028 #include <ode_robots/oderobot.h>
00029 
00030 namespace lpzrobots {
00031 
00032   typedef struct {
00033   public:
00034     double      size;           ///< scaling factor for robot (size of one robot)
00035     double      distance;       ///< distance between robots
00036     double      force;          ///< @see Nimm2Conf
00037     double      speed;          ///< @see Nimm2Conf
00038     int         numRobots;      ///< number of robots in the chain
00039     double      massFactor;     ///< @see Nimm2Conf
00040     double      wheelSlip;      ///< @see Nimm2Conf
00041     std::string color;          ///< color of robots
00042     bool        useIR;          ///< use infrared sensors?
00043   } RobotChainConf;
00044 
00045 
00046   /** Chain of robots 
00047    */
00048   class RobotChain : public OdeRobot {
00049   public:
00050   
00051     /**
00052      * constructor of uwo robot
00053      * @param odeHandle data structure for accessing ODE
00054      * @param osgHandle ata structure for accessing OSG
00055      * @param size scaling of robot
00056      * @param force maximal used force to realize motorcommand
00057      * @param radialLegs switches between cartensian and radial leg joints 
00058      */
00059     RobotChain(const OdeHandle& odeHandle, const OsgHandle& osgHandle, 
00060                const RobotChainConf& conf, const std::string& name);
00061 
00062     virtual ~RobotChain(){ destroy(); };
00063 
00064     static RobotChainConf getDefaultConf(){
00065       RobotChainConf c;
00066       c.numRobots  = 5;
00067       c.size       = 0.6;
00068       c.distance   = 0.95;
00069       c.force      = 2;
00070       c.speed      = 45;
00071       c.massFactor = 0.5;
00072       c.wheelSlip  = 0.02;
00073       c.color      = "robot3";
00074       c.useIR      = false;
00075       return c;
00076     }
00077 
00078     /**
00079      * updates the OSG nodes of the vehicle
00080      */
00081     virtual void update();
00082 
00083 
00084     /** sets the pose of the vehicle
00085         @param pose desired pose matrix
00086     */
00087     virtual void place(const osg::Matrix& pose);
00088 
00089     virtual int getSensors(sensor* sensors, int sensornumber);
00090 
00091     virtual void setMotors(const motor* motors, int motornumber);
00092 
00093     virtual int getSensorNumber();
00094 
00095     virtual int getMotorNumber();
00096 
00097     virtual void doInternalStuff(GlobalData& globalData);
00098 
00099     /******** CONFIGURABLE ***********/
00100     virtual void notifyOnChange(const paramkey& key);
00101 
00102 
00103     virtual int getIRSensorNum();
00104 
00105   protected:
00106     virtual Primitive* getMainPrimitive() const;
00107 
00108     virtual void create(const osg::Matrix& pose); 
00109 
00110     virtual void destroy();
00111 
00112     RobotChainConf conf; 
00113     
00114     bool created;
00115        
00116     std::vector <OdeRobot*> robots;
00117   };
00118 
00119 }
00120 
00121 #endif
Generated on Thu Jun 28 14:45:37 2012 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.6.3