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.2  2006/07/14 12:23:42  martius
00024  *   selforg becomes HEAD
00025  *
00026  *   Revision 1.1.2.2  2006/06/25 16:57:17  martius
00027  *   abstractrobot is configureable
00028  *   name and revision
00029  *
00030  *   Revision 1.1.2.1  2006/06/10 20:13:33  martius
00031  *   unknown walking object
00032  *
00033  *
00034  *                                                                 *
00035  ***************************************************************************/
00036 #ifndef __UWO_H
00037 #define __UWO_H
00038 
00039 #include "oderobot.h"
00040 
00041 namespace lpzrobots {
00042 
00043   class Primitive; 
00044   class Joint;
00045   class UniversalServo;
00046 
00047   typedef struct {
00048   public:
00049     double size;       //< scaling factor for robot (diameter of body)
00050     double legLength;  //< length of the legs in units of size 
00051     int    legNumber;  //<  number of snake elements
00052     bool   radialLegs; //< joint orientation is radial instead of cartesian
00053     double mass;       //< chassis mass
00054     double relLegmass; //< relative overall leg mass
00055     double jointLimit; //< angle range for legs
00056     double motorPower; //< maximal force for motors
00057     double frictionGround; //< friction with the ground
00058   } UwoConf;
00059 
00060 
00061   /** UWO: Unknown Walk Object :-), looks like a plate with a lot of legs 
00062    */
00063   class Uwo : public OdeRobot {
00064   public:
00065   
00066     /**
00067      * constructor of uwo robot
00068      * @param odeHandle data structure for accessing ODE
00069      * @param osgHandle ata structure for accessing OSG
00070      * @param size scaling of robot
00071      * @param force maximal used force to realize motorcommand
00072      * @param radialLegs switches between cartensian and radial leg joints 
00073      */
00074     Uwo(const OdeHandle& odeHandle, const OsgHandle& osgHandle, const UwoConf& conf, 
00075         const std::string& name);
00076 
00077     virtual ~Uwo(){};
00078 
00079     static UwoConf getDefaultConf(){
00080       UwoConf c;
00081       c.size       = 1;
00082       c.legNumber  = 8;
00083       c.legLength  = 0.3;
00084       c.mass       = 1;
00085       c.relLegmass = 1;
00086       c.motorPower = 0.5;
00087       c.jointLimit = M_PI/12; // +- 15 degree
00088       c.radialLegs = true;
00089       c.frictionGround = 1;
00090       return c;
00091     }
00092 
00093     /**
00094      * updates the OSG nodes of the vehicle
00095      */
00096     virtual void update();
00097 
00098 
00099     /** sets the pose of the vehicle
00100         @param pose desired pose matrix
00101     */
00102     virtual void place(const osg::Matrix& pose);
00103 
00104     /** returns actual sensorvalues
00105         @param sensors sensors scaled to [-1,1] 
00106         @param sensornumber length of the sensor array
00107         @return number of actually written sensors
00108     */
00109     virtual int getSensors(sensor* sensors, int sensornumber);
00110 
00111     /** sets actual motorcommands
00112         @param motors motors scaled to [-1,1] 
00113         @param motornumber length of the motor array
00114     */
00115     virtual void setMotors(const motor* motors, int motornumber);
00116 
00117     /** returns number of sensors
00118      */
00119     virtual int getSensorNumber(){
00120       return conf.legNumber*2;
00121     };
00122 
00123     /** returns number of motors
00124      */
00125     virtual int getMotorNumber(){
00126       return conf.legNumber*2;
00127     };
00128 
00129     /** checks for internal collisions and treats them. 
00130      *  In case of a treatment return true (collision will be ignored by other objects 
00131      *  and the default routine)  else false (collision is passed to other objects and 
00132      *  (if not treated) to the default routine).
00133      */
00134     virtual bool collisionCallback(void *data, dGeomID o1, dGeomID o2);
00135 
00136     /** this function is called in each timestep. It should perform robot-internal checks, 
00137         like space-internal collision detection, sensor resets/update etc.
00138         @param globalData structure that contains global data from the simulation environment
00139     */
00140     virtual void doInternalStuff(const GlobalData& globalData);
00141 
00142     
00143     /** The list of all parameters with there value as allocated lists.
00144      */
00145     virtual paramlist getParamList() const;
00146     
00147     virtual paramval getParam(const paramkey& key) const;;
00148     
00149     virtual bool setParam(const paramkey& key, paramval val);
00150 
00151 
00152   protected:
00153     /** the main object of the robot, which is used for position and speed tracking */
00154     virtual Primitive* getMainPrimitive() const { return objects[0]; }
00155 
00156     /** creates vehicle at desired pose
00157         @param pose 4x4 pose matrix
00158     */
00159     virtual void create(const osg::Matrix& pose); 
00160 
00161     /** destroys vehicle and space
00162      */
00163     virtual void destroy();
00164 
00165     UwoConf conf; 
00166     double legmass;    // leg mass
00167 
00168     bool created;      // true if robot was created
00169 
00170     std::vector<Primitive*> objects;  // 1 body, legs
00171     std::vector<Joint*> joints; // joints between cylinder and each legs
00172     std::vector <UniversalServo*> servos; // motors
00173 
00174   };
00175 
00176 }
00177 
00178 #endif

Generated on Mon Aug 7 16:40:14 2006 for Robotsystem of the Robot Group Leipzig by  doxygen 1.4.7