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

# schlangeservo.h

Go to the documentation of this file.

    00001 /************************************************************************/
    00002 /*schlangeservo.h                                                       */
    00003 /*Snake with PID Servo motors (just one motor per joint)                */
    00004 /*@author Georg Martius                                                 */
    00005 /*                                                                      */
    00006 /************************************************************************/
    00007 /***************************************************************************
    00008  *   Copyright (C) 2005-2011 LpzRobots development team                    *
    00009  *    Georg Martius  <georg dot martius at web dot de>                     *
    00010  *    Frank Guettler <guettler at informatik dot uni-leipzig dot de        *
    00011  *    Frank Hesse    <frank at nld dot ds dot mpg dot de>                  *
    00012  *    Ralf Der       <ralfder at mis dot mpg dot de>                       *
    00013  *                                                                         *
    00014  *   This program is free software; you can redistribute it and/or modify  *
    00015  *   it under the terms of the GNU General Public License as published by  *
    00016  *   the Free Software Foundation; either version 2 of the License, or     *
    00017  *   (at your option) any later version.                                   *
    00018  *                                                                         *
    00019  *   This program is distributed in the hope that it will be useful,       *
    00020  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
    00021  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
    00022  *   GNU General Public License for more details.                          *
    00023  *                                                                         *
    00024  *   You should have received a copy of the GNU General Public License     *
    00025  *   along with this program; if not, write to the                         *
    00026  *   Free Software Foundation, Inc.,                                       *
    00027  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
    00028  *                                                                         *
    00029  ***************************************************************************/
    00030 #ifndef __SCHLANGESERVO_H
    00031 #define __SCHLANGESERVO_H
    00032
    00033
    00034 #include "schlange.h"
    00035 #include "oneaxisservo.h"
    00036
    00037 namespace lpzrobots {
    00038
    00039   /**
    00040    * This is a class, which models a snake like robot.
    00041    * It consists of a number of equal elements, each linked
    00042    * by a joint hinge powered by 1 servos
    00043    **/
    00044   class SchlangeServo: public Schlange
    00045   {
    00046   private:
    00047     std::vector <HingeServo*> servos;
    00048
    00049   public:
    00050     SchlangeServo ( const OdeHandle& odeHandle, const OsgHandle& osgHandle,
    00051                     const SchlangeConf& conf,
    00052                     const std::string& name, const std::string& revision="");
    00053
    00054
    00055     virtual ~SchlangeServo();
    00056
    00057     /**
    00058      *Reads the actual motor commands from an array,
    00059      *an sets all motors of the snake to this values.
    00060      *It is an linear allocation.
    00061      *@param motors pointer to the array, motor values are scaled to [-1,1]
    00062      *@param motornumber length of the motor array
    00063      **/
    00064     virtual void setMotors ( const motor* motors, int motornumber );
    00065
    00066     /**
    00067      *Writes the sensor values to an array in the memory.
    00068      *@param sensors pointer to the array
    00069      *@param sensornumber length of the sensor array
    00070      *@return number of actually written sensors
    00071      **/
    00072     virtual int getSensors ( sensor* sensors, int sensornumber );
    00073
    00074     /** returns number of sensors
    00075      */
    00076     virtual int getSensorNumber() { assert(created); return servos.size(); }
    00077
    00078     /** returns number of motors
    00079      */
    00080     virtual int getMotorNumber(){ assert(created); return servos.size(); }
    00081
    00082     /******** CONFIGURABLE ***********/
    00083     virtual void notifyOnChange(const paramkey& key);
    00084
    00085   private:
    00086     virtual void create(const osg::Matrix& pose);
    00087     virtual void destroy();
    00088   };
    00089
    00090 }
    00091
    00092 /*
    00093 Parameters for invertmotornstep controller:
    00094 motorpower=5
    00095 sensorfactor=5
    00096
    00097 controller->setParam("adaptrate", 0.000);
    00098 controller->setParam("epsC", 0.01);
    00099 controller->setParam("epsA", 0.01);
    00100 controller->setParam("dampA", 0.0001);
    00101 controller->setParam("rootE", 1);
    00102 controller->setParam("steps", 1);
    00103 controller->setParam("s4avg", 1);
    00104 controller->setParam("s4del", 5);
    00105 global.odeConfig.setParam("controlinterval",4);
    00106
    00107
    00108 High frequency modes and then low-dim modes occur with
    00109 controller->setParam("adaptrate", 0.0001);
    00110 controller->setParam("nomupdate", 0.0007);
    00111 controller->setParam("epsC", 0.01);
    00112 controller->setParam("epsA", 0.01);
    00113 controller->setParam("dampA", 0.0001);
    00114 controller->setParam("rootE", 1);
    00115 controller->setParam("steps", 1);
    00116 controller->setParam("s4avg", 1);
    00117 controller->setParam("s4del", 1);
    00118 global.odeConfig.setParam("controlinterval",1);
    00119
    00120
    00121 */
    00122
    00123
    00124 #endif
    00125