Robot Simulator of the Robotics Group for Self-Organization of Control: uwo.h Source File

# uwo.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 __UWO_H
    00025 #define __UWO_H
    00026
    00027 #include "oderobot.h"
    00028 #include "twoaxisservo.h"
    00029
    00030 namespace lpzrobots {
    00031
    00032   class Primitive;
    00033   class Joint;
    00034
    00035   typedef struct {
    00036   public:
    00037     double size;       ///< scaling factor for robot (diameter of body)
    00038     double legLength;  ///< length of the legs in units of size
    00039     int    legNumber;  ///<  number of snake elements
    00040     bool   radialLegs; ///< joint orientation is radial instead of cartesian
    00041     double mass;       ///< chassis mass
    00042     double relLegmass; ///< relative overall leg mass
    00043     double jointLimit; ///< angle range for legs
    00044     double motorPower; ///< maximal force for motors
    00045     double frictionGround; ///< friction with the ground
    00046   } UwoConf;
    00047
    00048
    00049   /** UWO: Unknown Walk Object :-), looks like a plate with a lot of legs
    00050    */
    00051   class Uwo : public OdeRobot {
    00052   public:
    00053
    00054     /**
    00055      * constructor of uwo robot
    00056      * @param odeHandle data structure for accessing ODE
    00057      * @param osgHandle ata structure for accessing OSG
    00058      * @param size scaling of robot
    00059      * @param force maximal used force to realize motorcommand
    00060      * @param radialLegs switches between cartensian and radial leg joints
    00061      */
    00062     Uwo(const OdeHandle& odeHandle, const OsgHandle& osgHandle, const UwoConf& conf,
    00063         const std::string& name);
    00064
    00065     virtual ~Uwo(){ destroy(); };
    00066
    00067     static UwoConf getDefaultConf(){
    00068       UwoConf c;
    00069       c.size       = 1;
    00070       c.legNumber  = 8;
    00071       c.legLength  = 0.3;
    00072       c.mass       = 1;
    00073       c.relLegmass = 1;
    00074       c.motorPower = 0.5;
    00075       c.jointLimit = M_PI/12; // +- 15 degree
    00076       c.radialLegs = true;
    00077       c.frictionGround = 1;
    00078       return c;
    00079     }
    00080
    00081     /**
    00082      * updates the OSG nodes of the vehicle
    00083      */
    00084     virtual void update();
    00085
    00086
    00087     /** sets the pose of the vehicle
    00088         @param pose desired pose matrix
    00089     */
    00090     virtual void place(const osg::Matrix& pose);
    00091
    00092     /** returns actual sensorvalues
    00093         @param sensors sensors scaled to [-1,1]
    00094         @param sensornumber length of the sensor array
    00095         @return number of actually written sensors
    00096     */
    00097     virtual int getSensors(sensor* sensors, int sensornumber);
    00098
    00099     /** sets actual motorcommands
    00100         @param motors motors scaled to [-1,1]
    00101         @param motornumber length of the motor array
    00102     */
    00103     virtual void setMotors(const motor* motors, int motornumber);
    00104
    00105     /** returns number of sensors
    00106      */
    00107     virtual int getSensorNumber(){
    00108       return conf.legNumber*2;
    00109     };
    00110
    00111     /** returns number of motors
    00112      */
    00113     virtual int getMotorNumber(){
    00114       return conf.legNumber*2;
    00115     };
    00116
    00117     /** this function is called in each timestep. It should perform robot-internal checks,
    00118         like space-internal collision detection, sensor resets/update etc.
    00119         @param globalData structure that contains global data from the simulation environment
    00120     */
    00121     virtual void doInternalStuff(GlobalData& globalData);
    00122
    00123     /******** CONFIGURABLE ***********/
    00124     virtual void notifyOnChange(const paramkey& key);
    00125
    00126   protected:
    00127     /** the main object of the robot, which is used for position and speed tracking */
    00128     virtual Primitive* getMainPrimitive() const { return objects[0]; }
    00129
    00130     /** creates vehicle at desired pose
    00131         @param pose 4x4 pose matrix
    00132     */
    00133     virtual void create(const osg::Matrix& pose);
    00134
    00135     /** destroys vehicle and space
    00136      */
    00137     virtual void destroy();
    00138
    00139     UwoConf conf;
    00140     double legmass;    // leg mass
    00141
    00142     bool created;      // true if robot was created
    00143
    00144
    00145     std::vector <UniversalServo*> servos; // motors
    00146
    00147   };
    00148
    00149 }
    00150
    00151 #endif