Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
schlangevelocity.h
Go to the documentation of this file.
1 /************************************************************************/
2 /*schlangevelocity.h */
3 /*Snake with powered by setting angular velocities */
4 /* */
5 /************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2005-2011 LpzRobots development team *
8  * Georg Martius <georg dot martius at web dot de> *
9  * Frank Guettler <guettler at informatik dot uni-leipzig dot de *
10  * Frank Hesse <frank at nld dot ds dot mpg dot de> *
11  * Ralf Der <ralfder at mis dot mpg dot de> *
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  * This program is distributed in the hope that it will be useful, *
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21  * GNU General Public License for more details. *
22  * *
23  * You should have received a copy of the GNU General Public License *
24  * along with this program; if not, write to the *
25  * Free Software Foundation, Inc., *
26  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
27  * *
28  ***************************************************************************/
29 #ifndef __SCHLANGEVELOCITY_H
30 #define __SCHLANGEVELOCITY_H
31 
32 #include "schlange.h"
33 
34 namespace lpzrobots {
35 
36  /**
37  * This is a class, which models a snake like robot.
38  * It consists of a number of equal elements, each linked
39  * by a joint powered by directly setting the angular velocities of the joints
40  **/
41  class SchlangeVelocity: public Schlange
42  {
43  private:
44  paramval factor_motors;
45  paramval factor_sensors;
46  paramval friction_joint;
47 
48 
49  public:
51  const SchlangeConf& conf, const std::string& name);
52 
55  conf.segmNumber = 10; // number of snake elements
56  conf.segmLength = 0.8; // length of one snake element
57  conf.segmDia = 0.2; // diameter of a snake element
58  conf.segmMass = 0.4; // mass of one snake element
59  conf.motorPower = 0.3; // power of motors
60  conf.jointLimit = M_PI/4;
61  return conf;
62  }
63 
64  virtual ~SchlangeVelocity();
65 
66  /**
67  *Reads the actual motor commands from an array,
68  *an sets all motors of the snake to this values.
69  *It is an linear allocation.
70  *@param motors pointer to the array, motor values are scaled to [-1,1]
71  *@param motornumber length of the motor array
72  **/
73  virtual void setMotorsIntern( const double* motors, int motornumber );
74 
75  /**
76  *Writes the sensor values to an array in the memory.
77  *@param sensors pointer to the array
78  *@param sensornumber length of the sensor array
79  *@return number of actually written sensors
80  **/
81  virtual int getSensorsIntern( sensor* sensors, int sensornumber );
82 
83  /** returns number of sensors
84  */
85  virtual int getSensorNumberIntern() { assert(created); return joints.size() * 2; }
86 
87  /** returns number of motors
88  */
89  virtual int getMotorNumberIntern(){ assert(created); return joints.size() * 2; }
90 
91  private:
92  virtual void create(const osg::Matrix& pose);
93  virtual void destroy();
94  };
95 
96 }
97 
98 #endif
double jointLimit
maximal angle for the joints (M_PI/4 = 45 degree)
Definition: schlange.h:56
double segmMass
mass of one snake element
Definition: schlange.h:51
Data structure for accessing the ODE.
Definition: odehandle.h:44
virtual void setMotorsIntern(const double *motors, int motornumber)
Reads the actual motor commands from an array, an sets all motors of the snake to this values...
Definition: schlangevelocity.cpp:47
bool created
Definition: schlange.h:76
Matrixd Matrix
Definition: osgforwarddecl.h:47
virtual int getSensorNumberIntern()
returns number of sensors
Definition: schlangevelocity.h:85
virtual ~SchlangeVelocity()
Definition: schlangevelocity.cpp:38
double sensor
Definition: types.h:29
Definition: schlange.h:46
Data structure for accessing the OpenSceneGraph.
Definition: osghandle.h:79
Joints joints
list of joints (should be populated by subclasses)
Definition: oderobot.h:267
This is a class, which models a snake like robot.
Definition: schlange.h:72
double paramval
Definition: configurable.h:88
int segmNumber
number of snake elements
Definition: schlange.h:48
std::list< SensorAttachment > sensors
Definition: oderobot.h:269
virtual int getSensorsIntern(sensor *sensors, int sensornumber)
Writes the sensor values to an array in the memory.
Definition: schlangevelocity.cpp:71
double motorPower
power of the motors / servos
Definition: schlange.h:52
OsgHandle osgHandle
Definition: oderobot.h:278
OdeHandle odeHandle
Definition: oderobot.h:277
double segmLength
length of one snake element
Definition: schlange.h:49
SchlangeConf conf
Definition: schlange.h:79
SchlangeVelocity(const OdeHandle &odeHandle, const OsgHandle &osgHandle, const SchlangeConf &conf, const std::string &name)
Definition: schlangevelocity.cpp:31
static SchlangeConf getDefaultConf()
Definition: schlangevelocity.h:53
This is a class, which models a snake like robot.
Definition: schlangevelocity.h:41
double segmDia
diameter of a snake element
Definition: schlange.h:50
virtual int getMotorNumberIntern()
returns number of motors
Definition: schlangevelocity.h:89
std::list< MotorAttachment > motors
Definition: oderobot.h:270