uwo.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: uwo.h,v $
00023  *   Revision 1.5  2007/11/07 13:21:16  martius
00024  *   doInternal stuff changed signature
00025  *
00026  *   Revision 1.4  2007/02/13 19:32:13  martius
00027  *   twoaxisservo
00028  *
00029  *   Revision 1.3  2006/12/21 11:43:05  martius
00030  *   commenting style for doxygen //< -> ///<
00031  *   new sensors for spherical robots
00032  *
00033  *   Revision 1.2  2006/07/14 12:23:42  martius
00034  *   selforg becomes HEAD
00035  *
00036  *   Revision 1.1.2.2  2006/06/25 16:57:17  martius
00037  *   abstractrobot is configureable
00038  *   name and revision
00039  *
00040  *   Revision 1.1.2.1  2006/06/10 20:13:33  martius
00041  *   unknown walking object
00042  *
00043  *
00044  *                                                                 *
00045  ***************************************************************************/
00046 #ifndef __UWO_H
00047 #define __UWO_H
00048 
00049 #include "oderobot.h"
00050 #include "twoaxisservo.h"
00051 
00052 namespace lpzrobots {
00053 
00054   class Primitive; 
00055   class Joint;
00056 
00057   typedef struct {
00058   public:
00059     double size;       ///< scaling factor for robot (diameter of body)
00060     double legLength;  ///< length of the legs in units of size 
00061     int    legNumber;  ///<  number of snake elements
00062     bool   radialLegs; ///< joint orientation is radial instead of cartesian
00063     double mass;       ///< chassis mass
00064     double relLegmass; ///< relative overall leg mass
00065     double jointLimit; ///< angle range for legs
00066     double motorPower; ///< maximal force for motors
00067     double frictionGround; ///< friction with the ground
00068   } UwoConf;
00069 
00070 
00071   /** UWO: Unknown Walk Object :-), looks like a plate with a lot of legs 
00072    */
00073   class Uwo : public OdeRobot {
00074   public:
00075   
00076     /**
00077      * constructor of uwo robot
00078      * @param odeHandle data structure for accessing ODE
00079      * @param osgHandle ata structure for accessing OSG
00080      * @param size scaling of robot
00081      * @param force maximal used force to realize motorcommand
00082      * @param radialLegs switches between cartensian and radial leg joints 
00083      */
00084     Uwo(const OdeHandle& odeHandle, const OsgHandle& osgHandle, const UwoConf& conf, 
00085         const std::string& name);
00086 
00087     virtual ~Uwo(){};
00088 
00089     static UwoConf getDefaultConf(){
00090       UwoConf c;
00091       c.size       = 1;
00092       c.legNumber  = 8;
00093       c.legLength  = 0.3;
00094       c.mass       = 1;
00095       c.relLegmass = 1;
00096       c.motorPower = 0.5;
00097       c.jointLimit = M_PI/12; // +- 15 degree
00098       c.radialLegs = true;
00099       c.frictionGround = 1;
00100       return c;
00101     }
00102 
00103     /**
00104      * updates the OSG nodes of the vehicle
00105      */
00106     virtual void update();
00107 
00108 
00109     /** sets the pose of the vehicle
00110         @param pose desired 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 conf.legNumber*2;
00131     };
00132 
00133     /** returns number of motors
00134      */
00135     virtual int getMotorNumber(){
00136       return conf.legNumber*2;
00137     };
00138 
00139     /** checks for internal collisions and treats them. 
00140      *  In case of a treatment return true (collision will be ignored by other objects 
00141      *  and the default routine)  else false (collision is passed to other objects and 
00142      *  (if not treated) to the default routine).
00143      */
00144     virtual bool collisionCallback(void *data, dGeomID o1, dGeomID o2);
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     
00153     /** The list of all parameters with there value as allocated lists.
00154      */
00155     virtual paramlist getParamList() const;
00156     
00157     virtual paramval getParam(const paramkey& key) const;;
00158     
00159     virtual bool setParam(const paramkey& key, paramval val);
00160 
00161 
00162   protected:
00163     /** the main object of the robot, which is used for position and speed tracking */
00164     virtual Primitive* getMainPrimitive() const { return objects[0]; }
00165 
00166     /** creates vehicle at desired pose
00167         @param pose 4x4 pose matrix
00168     */
00169     virtual void create(const osg::Matrix& pose); 
00170 
00171     /** destroys vehicle and space
00172      */
00173     virtual void destroy();
00174 
00175     UwoConf conf; 
00176     double legmass;    // leg mass
00177 
00178     bool created;      // true if robot was created
00179 
00180     std::vector<Primitive*> objects;  // 1 body, legs
00181     std::vector<Joint*> joints; // joints between cylinder and each legs
00182     std::vector <UniversalServo*> servos; // motors
00183 
00184   };
00185 
00186 }
00187 
00188 #endif

Generated on Fri Oct 30 16:29:01 2009 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.4.7