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
muscledarm.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 
25 
26 #ifndef __MUSCLEDARM_H
27 #define __MUSCLEDARM_H
28 
29 #include "oderobot.h"
30 #include <selforg/configurable.h>
31 #include "primitive.h"
32 #include "joint.h"
33 
34 namespace lpzrobots{
35 
36 
37 
38 #define SIDE (0.2) /* side length of a box */
39 #define MASS (1.0) /* mass of a capped cylinder */
40 #define includeMusclesGraphics false
41 
42 
43  typedef struct {
44  bool jointAngleSensors; // choose sensors, all combinations are possible
47  bool jointActuator; // if true, two motors at the joints are used
48  // if false, six muscles are used
49 
51 
52  class MuscledArm : public OdeRobot{
53  public:
54 
55  /* Enumeration of different parts and joints */
56  // left, right up and down correspond to view from top, when base is on the bottom
58  mainMuscle11, //left mainMuscle bottom part
59  mainMuscle12, //left mainMuscle top part
60  mainMuscle21, //right mainMuscle lower part
61  mainMuscle22, //right mainMuscle upper part
72 
73  enum joints {HJ_BuA, // hinge joint between base and upperArm
74  HJ_uAlA, // hinge joint between upperArm and lowerArm
75 
76  HJ_BmM11, // hinge joint between base and mainMuscle11
77  HJ_lAmM12, // hinge joint between lowerArm and mainMuscle12
78  HJ_BmM21, // hinge joint between base and mainMuscle21
79  HJ_lAmM22, // hinge joint between lowerArm and mainMuscle22
80 
81  HJ_BsM11, // hinge joint between base and smallMuscle11
82  HJ_uAsM12, // hinge joint between upperArm and smallMuscle12
83  HJ_BsM21, // hinge joint between base and smallMuscle21
84  HJ_uAsM22, // hinge joint between upperArm and smallMuscle22
85  HJ_lAsM31, // hinge joint between lowerArm and smallMuscle31
86  HJ_uAsM32, // hinge joint between upperArm and smallMuscle32
87  HJ_lAsM41, // hinge joint between lowerArm and smallMuscle41
88  HJ_uAsM42, // hinge joint between upperArm and smallMuscle42
89 
90  SJ_mM1, // sliderJoint between mainMuscle11 and mainMuscle12
91  SJ_mM2, // sliderJoint between mainMuscle21 and mainMuscle22
92 
93  SJ_sM1, // slider Joint between smallMuscle11 ans smallMuscle12
94  SJ_sM2, // slider Joint between smallMuscle21 ans smallMuscle22
95  SJ_sM3, // slider Joint between smallMuscle31 ans smallMuscle32
96  SJ_sM4, // slider Joint between smallMuscle41 ans smallMuscle42
97 
98  FJ_lAH, // fixed joint between lowerArm and hand
100 
101 
102 
103  double force_[6];
104 
106  const std::string& name);
107 
110  conf.jointAngleSensors=false;
111  conf.jointAngleRateSensors=true;
112  conf.muscleLengthSensors=false;
113  conf.jointActuator=false;
114  return conf;
115  }
116 
117  virtual ~MuscledArm(){};
118 
119 
120  /** sets the pose of the vehicle
121  @param pose desired 4x4 pose matrix
122  */
123  virtual void placeIntern(const osg::Matrix& pose);
124 
125 
126  /** returns actual sensorvalues
127  @param sensors sensors scaled to [-1,1]
128  @param sensornumber length of the sensor array
129  @return number of actually written sensors
130  */
131  virtual int getSensorsIntern(double* sensors, int sensornumber);
132 
133  /** sets actual motorcommands
134  @param motors motors scaled to [-1,1]
135  @param motornumber length of the motor array
136  */
137  virtual void setMotorsIntern(const double* motors, int motornumber);
138 
139  /** returns number of sensors
140  */
141  virtual int getSensorNumberIntern(){
142  return sensorno;
143  };
144 
145  /** returns number of motors
146  */
147  virtual int getMotorNumberIntern(){
148  return motorno;
149  };
150 
151 /* /\** returns position of hand (=sphere at the end of lower arm) */
152 /* @return position robot position in struct Position */
153 /* *\/ */
154 /* virtual osg::Vec3 MuscledArm::getPosition(); */
155 
156  /** returns a vector with the positions of all segments of the robot
157  @param poslist vector of positions (of all robot segments)
158  @return length of the list
159  */
160  virtual int getSegmentsPosition(std::vector<Position> &poslist);
161 
162  /** this function is called in each timestep. It should perform robot-internal checks,
163  like space-internal collision detection, sensor resets/update etc.
164  @param globalData structure that contains global data from the simulation environment
165  */
166  virtual void doInternalStuff(GlobalData& globalData);
167 
168 
169  virtual Primitive* getMainObject() const;
170 
171  protected:
172  /** the main object of the robot, which is used for position and speed tracking */
173  //virtual Primitive* getMainPrimitive() const { return object[lowerArm]; }
174  virtual Primitive* getMainPrimitive() const { return object[hand]; }
175 
176  /** creates vehicle at desired pose
177  @param pose 4x4 pose matrix
178  */
179  virtual void create(const osg::Matrix& pose);
180 
181  /** destroys vehicle and space
182  */
183  virtual void destroy();
184 
185  static void mycallback(void *data, dGeomID o1, dGeomID o2);
186 
187  double dBodyGetPositionAll ( dBodyID basis , int para );
188  double dGeomGetPositionAll ( dGeomID basis , int para );
189 
190  void BodyCreate(int n, dMass m, dReal x, dReal y, dReal z,
191  dReal qx, dReal qy, dReal qz, dReal qangle);
192 
194 
195  static const int armanzahl= 3;
196 
197 
198  Primitive* object[NUMParts];
200 
201  Position old_dist[NUMParts]; // used for damping
202 
207 
208  int segmentsno; // number of motorsvehicle segments
209 
210 
211 
215  double SOCKEL_HOEHE;
216  double SOCKEL_MASSE;
217 
218  int sensorno; //number of sensors
219  int motorno; // number of motors
220 
221  bool created; // true if robot was created
222 
223 
224 
225  dSpaceID parentspace;
226 
227  int printed;
228 
229  double max_l;
230  double max_r, min_l, min_r;
231 
232  double base_width;
233  double base_length;
238  double joint_offset;
243 
244  };
245 
246 }
247 #endif
virtual void setMotorsIntern(const double *motors, int motornumber)
sets actual motorcommands
Definition: muscledarm.cpp:101
Definition: muscledarm.h:67
double upperArm_width
Definition: muscledarm.h:234
double mainMuscle_width
Definition: muscledarm.h:239
static MuscledArmConf getDefaultConf()
Definition: muscledarm.h:108
Data structure for accessing the ODE.
Definition: odehandle.h:44
Definition: muscledarm.h:60
Definition: muscledarm.h:79
double force_[6]
Definition: muscledarm.h:103
void BodyCreate(int n, dMass m, dReal x, dReal y, dReal z, dReal qx, dReal qy, dReal qz, dReal qangle)
double max_r
Definition: muscledarm.h:230
virtual void placeIntern(const osg::Matrix &pose)
sets the pose of the vehicle
Definition: muscledarm.cpp:162
Definition: muscledarm.h:83
Definition: muscledarm.h:91
Matrixd Matrix
Definition: osgforwarddecl.h:47
Definition: muscledarm.h:57
double mainMuscle_length
Definition: muscledarm.h:240
virtual void doInternalStuff(GlobalData &globalData)
this function is called in each timestep.
Definition: muscledarm.cpp:186
Definition: joint.h:41
double max_l
Definition: muscledarm.h:229
bool jointActuator
Definition: muscledarm.h:47
Definition: muscledarm.h:71
Definition: muscledarm.h:57
virtual int getSegmentsPosition(std::vector< Position > &poslist)
returns a vector with the positions of all segments of the robot
Definition: muscledarm.cpp:176
double joint_offset
Definition: muscledarm.h:238
double dGeomGetPositionAll(dGeomID basis, int para)
Joint * joint[NUMJoints]
Definition: muscledarm.h:199
virtual Primitive * getMainPrimitive() const
the main object of the robot, which is used for position and speed tracking
Definition: muscledarm.h:174
bool muscleLengthSensors
Definition: muscledarm.h:46
double dBodyGetPositionAll(dBodyID basis, int para)
double base_length
Definition: muscledarm.h:233
Definition: muscledarm.h:58
Data structure for accessing the OpenSceneGraph.
Definition: osghandle.h:79
double lowerArm_width
Definition: muscledarm.h:236
Definition: muscledarm.h:69
Definition: muscledarm.h:70
Definition: muscledarm.h:84
Definition: muscledarm.h:95
double SOCKEL_HOEHE
Definition: muscledarm.h:215
double smallMuscle_width
Definition: muscledarm.h:241
int sensorno
Definition: muscledarm.h:218
double SOCKEL_MASSE
Definition: muscledarm.h:216
Definition: position.h:30
Definition: muscledarm.h:96
bool jointAngleRateSensors
Definition: muscledarm.h:45
double paramval
Definition: configurable.h:88
virtual int getSensorsIntern(double *sensors, int sensornumber)
returns actual sensorvalues
Definition: muscledarm.cpp:128
Definition: muscledarm.h:93
Definition: muscledarm.h:78
Definition: muscledarm.h:90
MuscledArm(const OdeHandle &odeHandle, const OsgHandle &osgHandle, const MuscledArmConf &conf, const std::string &name)
Definition: muscledarm.cpp:35
virtual int getSensorNumberIntern()
returns number of sensors
Definition: muscledarm.h:141
static const int armanzahl
Definition: muscledarm.h:195
Definition: muscledarm.h:62
Definition: muscledarm.h:85
Definition: muscledarm.h:74
Definition: muscledarm.h:81
Definition: muscledarm.h:87
double base_width
Definition: muscledarm.h:232
Interface class for primitives represented in the physical and graphical world.
Definition: primitive.h:80
bool jointAngleSensors
Definition: muscledarm.h:44
Data structure holding all essential global information.
Definition: globaldata.h:57
int motorno
Definition: muscledarm.h:219
joints
Definition: muscledarm.h:73
std::list< SensorAttachment > sensors
Definition: oderobot.h:269
virtual int getMotorNumberIntern()
returns number of motors
Definition: muscledarm.h:147
virtual ~MuscledArm()
Definition: muscledarm.h:117
double smallMuscle_length
Definition: muscledarm.h:242
MuscledArmConf conf
Definition: muscledarm.h:193
dSpaceID parentspace
Definition: muscledarm.h:225
double upperArm_length
Definition: muscledarm.h:235
double SOCKEL_LAENGE
Definition: muscledarm.h:213
static void mycallback(void *data, dGeomID o1, dGeomID o2)
Definition: muscledarm.cpp:240
Definition: muscledarm.h:61
OsgHandle osgHandle
Definition: oderobot.h:278
OdeHandle odeHandle
Definition: oderobot.h:277
Definition: muscledarm.h:86
paramval print
Definition: muscledarm.h:206
virtual void create(const osg::Matrix &pose)
creates vehicle at desired pose
Definition: muscledarm.cpp:273
Definition: muscledarm.h:59
Definition: muscledarm.h:94
Definition: muscledarm.h:77
Definition: muscledarm.h:98
Definition: muscledarm.h:63
Abstract class for ODE robots.
Definition: oderobot.h:64
int segmentsno
Definition: muscledarm.h:208
Definition: muscledarm.h:88
Definition: muscledarm.h:66
double SOCKEL_BREITE
Definition: muscledarm.h:214
Definition: muscledarm.h:73
Definition: muscledarm.h:52
Definition: muscledarm.h:68
paramval factorSensors
Definition: muscledarm.h:204
Definition: muscledarm.h:43
double min_l
Definition: muscledarm.h:230
virtual void destroy()
destroys vehicle and space
Definition: muscledarm.cpp:615
bool created
Definition: muscledarm.h:221
parts
Definition: muscledarm.h:57
Definition: muscledarm.h:99
int printed
Definition: muscledarm.h:227
paramval factorMotors
Definition: muscledarm.h:203
Definition: muscledarm.h:82
Definition: muscledarm.h:76
double lowerArm_length
Definition: muscledarm.h:237
Definition: muscledarm.h:65
Definition: muscledarm.h:57
virtual Primitive * getMainObject() const
Definition: muscledarm.cpp:630
double gelenkabstand
Definition: muscledarm.h:212
std::list< MotorAttachment > motors
Definition: oderobot.h:270
double min_r
Definition: muscledarm.h:230
paramval damping
Definition: muscledarm.h:205
Position old_dist[NUMParts]
Definition: muscledarm.h:201
Definition: muscledarm.h:64