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
vierbeiner.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2011 LpzRobots development team *
3  * Georg Martius <georg dot martius at web dot de> *
4  * Frank Guettler <guettler at informatik dot uni-leipzig dot de *
5  * Frank Hesse <frank at nld dot ds dot mpg dot de> *
6  * Ralf Der <ralfder at mis dot mpg dot de> *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the *
20  * Free Software Foundation, Inc., *
21  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22  * *
23  ***************************************************************************/
24 #ifndef __VIERBEINER_H
25 #define __VIERBEINER_H
26 
27 #include <ode_robots/oderobot.h>
28 
29 namespace lpzrobots {
30 
31  class Primitive;
32  class Joint;
33  class OneAxisServo;
34 
35  typedef struct {
36  public:
37  double size; ///< scaling factor for robot (diameter of body)
38  double legLength; ///< length of the legs in units of size
39  int legNumber; ///< number of snake elements
40  double mass; ///< chassis mass
41  double relLegmass; ///< relative overall leg mass
42  double powerFactor; ///< global factor for power parameters
43  double dampingFactor; ///< global factor for damping parameters
44  double hipPower; ///< maximal force for at hip joint motors
45  double hipDamping; ///< damping of hio joint servos
46  double hipJointLimit; ///< angle range for legs
47  double kneePower; ///< spring strength in the knees
48  double kneeJointLimit; ///< angle range for knees
49  double kneeDamping; ///< damping in the knees
50  double anklePower; ///< spring strength in the ankles
51  double ankleDamping; ///< damping in the ankles
52  bool hippo; ///< "dog" looks like a hippopotamus
54  bool useBigBox; ///< use big box on back or not
55  bool legBodyCollisions; ///< legs and body collide
57 
58 
59  /** robot that should look like a dog
60 
61  sensors/motors: 0: neck, 1: tail
62  2,3,4,5 : hip: rh, lh, rf, lf
63  6,7,8,9 : knee: rh, lh, rf, lf
64  10,11 : ankle rh, lh
65  */
66  class VierBeiner : public OdeRobot {
67  public:
68 
69  /**
70  * constructor of VierBeiner robot
71  * @param odeHandle data structure for accessing ODE
72  * @param osgHandle ata structure for accessing OSG
73  * @param conf configuration object
74  */
76  const std::string& name);
77 
78  virtual ~VierBeiner(){};
79 
82  c.size = 1;
83  c.legNumber = 4;
84  c.legLength = 0.6;
85  c.mass = 1;
86  c.relLegmass = 1;
87  c.powerFactor = 1;
88  c.dampingFactor = 1;
89  c.hipPower = 2; //3;
90  c.hipDamping = 0.1;
91  c.kneePower = 1; //2;
92  c.kneeDamping = 0.05;
93  c.anklePower = 0.1; //5;
94  c.ankleDamping = 0.02;
95  c.hipJointLimit = M_PI/3; // +- 60 degree
96  c.kneeJointLimit = M_PI/4; // +- 45 degree
97  // c.elasticity = 10;
98  c.hippo = false;
99  c.drawstupidface = 1;
100  c.useBigBox = true;
101  c.legBodyCollisions = false;
102  return c;
103  }
104 
105  /**
106  * updates the OSG nodes of the vehicle
107  */
108  virtual void update();
109 
110 
111  /** sets the pose of the vehicle
112  @param pose desired pose matrix
113  */
114  virtual void placeIntern(const osg::Matrix& pose);
115 
116  /** returns actual sensorvalues
117  @param sensors sensors scaled to [-1,1]
118  @param sensornumber length of the sensor array
119  @return number of actually written sensors
120  */
121  virtual int getSensorsIntern(sensor* sensors, int sensornumber);
122 
123  /** sets actual motorcommands
124  @param motors motors scaled to [-1,1]
125  @param motornumber length of the motor array
126  */
127  virtual void setMotorsIntern(const double* motors, int motornumber);
128 
129  /** returns number of sensors
130  */
131  virtual int getSensorNumberIntern();
132 
133  /** returns number of motors
134  */
135  virtual int getMotorNumberIntern();
136 
137  /** this function is called in each timestep. It should perform robot-internal checks,
138  like space-internal collision detection, sensor resets/update etc.
139  @param globalData structure that contains global data from the simulation environment
140  */
141  virtual void doInternalStuff(GlobalData& globalData);
142 
143 
144  /******** CONFIGURABLE ***********/
145  virtual void notifyOnChange(const paramkey& key);
146 
147  /** the main object of the robot, which is used for position and speed tracking */
148  virtual Primitive* getMainPrimitive() const { return objects[0]; }
149  protected:
150 
151  /** creates vehicle at desired pose
152  @param pose 4x4 pose matrix
153  */
154  virtual void create(const osg::Matrix& pose);
155 
156  /** destroys vehicle and space
157  */
158  virtual void destroy();
159 
161  double legmass; // leg mass
162 
163  bool created; // true if robot was created
164 
165 
166  // some objects explicitly needed for ignored collision pairs
168  // these ones are only need if a face is to be drawn
170 
171 
172  std::vector <OneAxisServo*> hipservos; // motors
173  std::vector <OneAxisServo*> kneeservos; // motors
174  std::vector <OneAxisServo*> ankleservos; // motors
175  std::vector <OneAxisServo*> headtailservos; // motors
176 
177  std::list <Primitive*> legparts; // lower leg parts (lower legs and feet) if collisions are ignored
178 
179  };
180 
181 }
182 
183 #endif
virtual void doInternalStuff(GlobalData &globalData)
this function is called in each timestep.
Definition: vierbeiner.cpp:174
double kneePower
spring strength in the knees
Definition: vierbeiner.h:47
bool legBodyCollisions
legs and body collide
Definition: vierbeiner.h:55
virtual ~VierBeiner()
Definition: vierbeiner.h:78
double hipJointLimit
angle range for legs
Definition: vierbeiner.h:46
Data structure for accessing the ODE.
Definition: odehandle.h:44
Primitive * trunk
Definition: vierbeiner.h:167
double legmass
Definition: vierbeiner.h:161
virtual void update()
updates the OSG nodes of the vehicle
Definition: vierbeiner.cpp:156
virtual void placeIntern(const osg::Matrix &pose)
sets the pose of the vehicle
Definition: vierbeiner.cpp:144
Matrixd Matrix
Definition: osgforwarddecl.h:47
virtual void create(const osg::Matrix &pose)
creates vehicle at desired pose
Definition: vierbeiner.cpp:180
bool created
Definition: vierbeiner.h:163
charArray paramkey
Definition: avrtypes.h:36
std::list< Primitive * > legparts
Definition: vierbeiner.h:177
VierBeiner(const OdeHandle &odeHandle, const OsgHandle &osgHandle, const VierBeinerConf &conf, const std::string &name)
constructor of VierBeiner robot
Definition: vierbeiner.cpp:44
Primitive * eye_r_trans
Definition: vierbeiner.h:169
bool drawstupidface
Definition: vierbeiner.h:53
double anklePower
spring strength in the ankles
Definition: vierbeiner.h:50
std::vector< OneAxisServo * > kneeservos
Definition: vierbeiner.h:173
double sensor
Definition: types.h:29
double kneeDamping
damping in the knees
Definition: vierbeiner.h:49
double hipPower
maximal force for at hip joint motors
Definition: vierbeiner.h:44
Primitive * ear_l_trans
Definition: vierbeiner.h:169
Data structure for accessing the OpenSceneGraph.
Definition: osghandle.h:79
static VierBeinerConf getDefaultConf()
Definition: vierbeiner.h:80
Primitive * tail
Definition: vierbeiner.h:167
double hipDamping
damping of hio joint servos
Definition: vierbeiner.h:45
double kneeJointLimit
angle range for knees
Definition: vierbeiner.h:48
Primitive * ear_r_trans
Definition: vierbeiner.h:169
double dampingFactor
global factor for damping parameters
Definition: vierbeiner.h:43
robot that should look like a dog
Definition: vierbeiner.h:66
double size
scaling factor for robot (diameter of body)
Definition: vierbeiner.h:37
virtual int getSensorsIntern(sensor *sensors, int sensornumber)
returns actual sensorvalues
Definition: vierbeiner.cpp:120
Interface class for primitives represented in the physical and graphical world.
Definition: primitive.h:80
bool useBigBox
use big box on back or not
Definition: vierbeiner.h:54
Data structure holding all essential global information.
Definition: globaldata.h:57
std::vector< OneAxisServo * > hipservos
Definition: vierbeiner.h:172
std::vector< OneAxisServo * > headtailservos
Definition: vierbeiner.h:175
virtual Primitive * getMainPrimitive() const
the main object of the robot, which is used for position and speed tracking
Definition: vierbeiner.h:148
std::list< SensorAttachment > sensors
Definition: oderobot.h:269
Primitive * headtrans
Definition: vierbeiner.h:167
Primitive * mouth_trans
Definition: vierbeiner.h:169
virtual void destroy()
destroys vehicle and space
Definition: vierbeiner.cpp:433
VierBeinerConf conf
Definition: vierbeiner.h:160
bool hippo
"dog" looks like a hippopotamus
Definition: vierbeiner.h:52
OsgHandle osgHandle
Definition: oderobot.h:278
OdeHandle odeHandle
Definition: oderobot.h:277
double mass
chassis mass
Definition: vierbeiner.h:40
virtual void notifyOnChange(const paramkey &key)
Is called when a parameter was changes via setParam().
Definition: vierbeiner.cpp:488
double powerFactor
global factor for power parameters
Definition: vierbeiner.h:42
Abstract class for ODE robots.
Definition: oderobot.h:64
Definition: vierbeiner.h:35
virtual int getMotorNumberIntern()
returns number of motors
Definition: vierbeiner.cpp:71
double legLength
length of the legs in units of size
Definition: vierbeiner.h:38
double relLegmass
relative overall leg mass
Definition: vierbeiner.h:41
std::vector< OneAxisServo * > ankleservos
Definition: vierbeiner.h:174
int legNumber
number of snake elements
Definition: vierbeiner.h:39
Primitive * bigboxtransform
Definition: vierbeiner.h:167
Primitives objects
list of objects (should be populated by subclasses)
Definition: oderobot.h:265
virtual int getSensorNumberIntern()
returns number of sensors
Definition: vierbeiner.cpp:111
virtual void setMotorsIntern(const double *motors, int motornumber)
sets actual motorcommands
Definition: vierbeiner.cpp:79
Primitive * eye_l_trans
Definition: vierbeiner.h:169
std::list< MotorAttachment > motors
Definition: oderobot.h:270
int c
Definition: hexapod.cpp:56
Primitive * neck
Definition: vierbeiner.h:167
double ankleDamping
damping in the ankles
Definition: vierbeiner.h:51