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

# hurlingsnake.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 __HURLINGSNAKE_H
    00025 #define __HURLINGSNAKE_H
    00026
    00027 #include "oderobot.h"
    00028 #include <selforg/configurable.h>
    00029 #include "primitive.h"
    00030 #include "joint.h"
    00031
    00032 namespace lpzrobots {
    00033
    00034   /**
    00035    * Hurling snake is a string a beats.
    00036    *
    00037    */
    00038   class HurlingSnake : public OdeRobot{
    00039   public:
    00040     /**
    00041      * Constructor
    00042      */
    00043     HurlingSnake(const OdeHandle& odeHandle, const OsgHandle& osgHandle, const std::string& name);
    00044
    00045     ~HurlingSnake();
    00046
    00047     /// update the subcomponents
    00048     virtual void update();
    00049
    00050     /** sets the pose of the vehicle
    00051         @param pose desired 4x4 pose matrix
    00052     */
    00053     virtual void place(const osg::Matrix& pose);
    00054
    00055     /** this function is called in each timestep. It should perform robot-internal checks,
    00056         like sensor resets/update etc.
    00057         @param globalData structure that contains global data from the simulation environment
    00058     */
    00059     virtual void doInternalStuff(GlobalData& globalData);
    00060
    00061
    00062     /** returns actual sensorvalues
    00063         @param sensors sensors scaled to [-1,1]
    00064         @param sensornumber length of the sensor array
    00065         @return number of actually written sensors
    00066     */
    00067     virtual int getSensors(sensor* sensors, int sensornumber);
    00068
    00069     /** sets actual motorcommands
    00070         @param motors motors scaled to [-1,1]
    00071         @param motornumber length of the motor array
    00072     */
    00073     virtual void setMotors(const motor* motors, int motornumber);
    00074
    00075     /** returns number of sensors
    00076      */
    00077     virtual int getSensorNumber();
    00078
    00079     /** returns number of motors
    00080      */
    00081     virtual int getMotorNumber();
    00082
    00083     /** returns a vector with the positions of all segments of the robot
    00084         @param poslist vector of positions (of all robot segments)
    00085         @return length of the list
    00086     */
    00087     virtual int getSegmentsPosition(std::vector<Position> &poslist);
    00088
    00089     /******** CONFIGURABLE ***********/
    00090     virtual void notifyOnChange(const paramkey& key);
    00091
    00092   protected:
    00093     /** the main object of the robot, which is used for position and speed tracking */
    00094     virtual Primitive* getMainPrimitive() const { return objects[(NUM-1)/2] /*(center)*/; }
    00095     //virtual Primitive* getMainPrimitive() const { return object[NUM-1] /*(head element)*/; }
    00096
    00097
    00098   private:
    00099
    00100     /** creates vehicle at desired pose
    00101         @param pose 4x4 pose matrix
    00102     */
    00103     virtual void create(const osg::Matrix& pose);
    00104
    00105     /** destroys robot and space
    00106      */
    00107     virtual void destroy();
    00108
    00109     bool created;      // true if robot was created
    00110
    00111
    00112     Position initial_pos;    // initial position of robot
    00113
    00114     int NUM;       /* number of beats */
    00115     double MASS;           /* mass of a beats */
    00116     double RADIUS;   /* sphere radius */
    00117
    00118     //    std::list<AngularMotor*> frictionMotors;
    00119
    00120     Pos oldp;
    00121
    00122     int sensorno;
    00123     int motorno;
    00124
    00125     paramval factorForce;
    00126     paramval frictionGround;
    00127     paramval frictionRoll;
    00128     paramval factorSensor;
    00129     parambool placedummy;
    00130
    00131   };
    00132
    00133 }
    00134
    00135 #endif
    00136