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
hurlingsnake.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 __HURLINGSNAKE_H
25 #define __HURLINGSNAKE_H
26 
27 #include "oderobot.h"
28 #include <selforg/configurable.h>
29 #include "primitive.h"
30 #include "joint.h"
31 
32 namespace lpzrobots {
33 
34  /**
35  * Hurling snake is a string a beats.
36  *
37  */
38  class HurlingSnake : public OdeRobot{
39  public:
40  /**
41  * Constructor
42  */
43  HurlingSnake(const OdeHandle& odeHandle, const OsgHandle& osgHandle, const std::string& name);
44 
45  ~HurlingSnake();
46 
47  /** sets the pose of the vehicle
48  @param pose desired 4x4 pose matrix
49  */
50  virtual void placeIntern(const osg::Matrix& pose);
51 
52  /** this function is called in each timestep. It should perform robot-internal checks,
53  like sensor resets/update etc.
54  @param globalData structure that contains global data from the simulation environment
55  */
56  virtual void doInternalStuff(GlobalData& globalData);
57 
58 
59  /** returns actual sensorvalues
60  @param sensors sensors scaled to [-1,1]
61  @param sensornumber length of the sensor array
62  @return number of actually written sensors
63  */
64  virtual int getSensorsIntern(sensor* sensors, int sensornumber);
65 
66  /** sets actual motorcommands
67  @param motors motors scaled to [-1,1]
68  @param motornumber length of the motor array
69  */
70  virtual void setMotorsIntern(const double* motors, int motornumber);
71 
72  /** returns number of sensors
73  */
74  virtual int getSensorNumberIntern();
75 
76  /** returns number of motors
77  */
78  virtual int getMotorNumberIntern();
79 
80  /** returns a vector with the positions of all segments of the robot
81  @param poslist vector of positions (of all robot segments)
82  @return length of the list
83  */
84  virtual int getSegmentsPosition(std::vector<Position> &poslist);
85 
86  /******** CONFIGURABLE ***********/
87  virtual void notifyOnChange(const paramkey& key);
88 
89  protected:
90  /** the main object of the robot, which is used for position and speed tracking */
91  virtual Primitive* getMainPrimitive() const { return objects[(NUM-1)/2] /*(center)*/; }
92  //virtual Primitive* getMainPrimitive() const { return object[NUM-1] /*(head element)*/; }
93 
94 
95  private:
96 
97  /** creates vehicle at desired pose
98  @param pose 4x4 pose matrix
99  */
100  virtual void create(const osg::Matrix& pose);
101 
102  /** destroys robot and space
103  */
104  virtual void destroy();
105 
106  bool created; // true if robot was created
107 
108 
109  Position initial_pos; // initial position of robot
110 
111  int NUM; /* number of beats */
112  double MASS; /* mass of a beats */
113  double RADIUS; /* sphere radius */
114 
115  // std::list<AngularMotor*> frictionMotors;
116 
117  Pos oldp;
118 
119  int sensorno;
120  int motorno;
121 
122  paramval factorForce;
123  paramval frictionGround;
124  paramval frictionRoll;
125  paramval factorSensor;
126  parambool placedummy;
127 
128  };
129 
130 }
131 
132 #endif
133 
bool parambool
Definition: configurable.h:93
virtual void placeIntern(const osg::Matrix &pose)
sets the pose of the vehicle
Definition: hurlingsnake.cpp:93
Data structure for accessing the ODE.
Definition: odehandle.h:44
std::string paramkey
Definition: configurable.h:85
virtual void setMotorsIntern(const double *motors, int motornumber)
sets actual motorcommands
Definition: hurlingsnake.cpp:132
Matrixd Matrix
Definition: osgforwarddecl.h:47
~HurlingSnake()
Definition: hurlingsnake.cpp:88
Definition: pos.h:36
Data structure for accessing the OpenSceneGraph.
Definition: osghandle.h:79
virtual void doInternalStuff(GlobalData &globalData)
this function is called in each timestep.
Definition: hurlingsnake.cpp:101
Definition: position.h:30
Interface class for primitives represented in the physical and graphical world.
Definition: primitive.h:80
virtual int getSensorNumberIntern()
returns number of sensors
Definition: hurlingsnake.cpp:143
Hurling snake is a string a beats.
Definition: hurlingsnake.h:38
Data structure holding all essential global information.
Definition: globaldata.h:57
HurlingSnake(const OdeHandle &odeHandle, const OsgHandle &osgHandle, const std::string &name)
Constructor.
Definition: hurlingsnake.cpp:38
std::list< SensorAttachment > sensors
Definition: oderobot.h:269
double paramval
Definition: avrtypes.h:37
virtual void notifyOnChange(const paramkey &key)
Is called when a parameter was changes via setParam().
Definition: hurlingsnake.cpp:216
virtual int getSegmentsPosition(std::vector< Position > &poslist)
returns a vector with the positions of all segments of the robot
Definition: hurlingsnake.cpp:158
OsgHandle osgHandle
Definition: oderobot.h:278
OdeHandle odeHandle
Definition: oderobot.h:277
Abstract class for ODE robots.
Definition: oderobot.h:64
double sensor
Definition: abstractrobot.h:43
Primitives objects
list of objects (should be populated by subclasses)
Definition: oderobot.h:265
virtual int getSensorsIntern(sensor *sensors, int sensornumber)
returns actual sensorvalues
Definition: hurlingsnake.cpp:115
std::list< MotorAttachment > motors
Definition: oderobot.h:270
virtual Primitive * getMainPrimitive() const
the main object of the robot, which is used for position and speed tracking
Definition: hurlingsnake.h:91
virtual int getMotorNumberIntern()
returns number of motors
Definition: hurlingsnake.cpp:149