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
sphererobot.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 #ifndef __SPHEREROBOT_H
26 #define __SPHEREROBOT_H
27 
28 #include "oderobot.h"
29 #include "oneaxisservo.h"
30 
31 namespace lpzrobots {
32 
33  class Primitive;
34  class Joint;
35  class SliderJoint;
36 
37  typedef struct {
38  public:
39  double diameter;
40  double spheremass;
42  double pendularmass;
43  double slidermass;
44  double sliderrange;
45 
46  double force; // forcefactor of the servo power (1 is usual)
47  double hingeRange; //the angle (in rad) of the hinges that connect pendular with poles
49 
50 
51  /**
52  *This is a class, which models a snake like robot. It consists of a number of equal elements, each linked
53  *by a joint. This class is based upon the class roboter by the same author.
54  *@author Marcel Kretschmann
55  *@version beta
56  **/
57  class Sphererobot : public OdeRobot
58  {
59  public:
60  /* typedef */ enum objects { Base, Pendular, Pole1Bot, Pole2Bot, Pole3Bot,
62 
63  protected:
64  const static int sensorno = 9;
65 
67  bool created;
68 
69  public:
71  Primitive* object[Last];
73  Joint* joint[6];
74 
75  public:
76 
78  const SphererobotConf& conf, const std::string& name );
79 
80  virtual ~Sphererobot();
81 
84  c.diameter = 1;
85  c.spheremass = 0.2;
86  c.pendulardiameter = 0.2;
87  c.pendularmass = 1.0;
88  c.slidermass = 0.005;
89  c.sliderrange = 0.1; // range of the slider from center in multiple of diameter [-range,range]
90  c.force = 1;
91  c.hingeRange = M_PI/180*30;
92  return c;
93  }
94 
95  /// update the subcomponents
96  virtual void update();
97 
98  /** sets the pose of the vehicle
99  @param pose desired 4x4 pose matrix
100  */
101  virtual void placeIntern(const osg::Matrix& pose);
102 
103  /**
104  *Writes the sensor values to an array in the memory.
105  *@param sensors pointer to the array
106  *@param sensornumber length of the sensor array
107  *@return number of actually written sensors
108  **/
109  virtual int getSensorsIntern( double* sensors, int sensornumber );
110 
111  /**
112  *Reads the actual motor commands from an array, an sets all motors of the snake to this values.
113  *It is an linear allocation.
114  *@param motors pointer to the array, motor values are scaled to [-1,1]
115  *@param motornumber length of the motor array
116  **/
117  virtual void setMotorsIntern( const double* motors, int motornumber );
118 
119  /**
120  *Returns the number of motors used by the snake.
121  *@return number of motors
122  **/
123  virtual int getMotorNumberIntern();
124 
125  /**
126  *Returns the number of sensors used by the robot.
127  *@return number of sensors
128  **/
129  virtual int getSensorNumberIntern();
130 
131  /** returns a vector with the positions of all segments of the robot
132  */
133  virtual int getSegmentsPosition(std::vector<Position> &poslist);
134 
135  /** the main object of the robot, which is used for position and speed tracking */
136  virtual Primitive* getMainPrimitive() const { return object[Base]; }
137 
138  protected:
139  /** creates vehicle at desired pose
140  @param pose 4x4 pose matrix
141  */
142  virtual void create(const osg::Matrix& pose);
143  virtual void destroy();
144 
145 
146 
147  };
148 
149 }
150 
151 #endif
virtual ~Sphererobot()
Definition: sphererobot.cpp:51
virtual int getMotorNumberIntern()
Returns the number of motors used by the snake.
Definition: sphererobot.cpp:112
Data structure for accessing the ODE.
Definition: odehandle.h:44
Definition: sphererobot.h:61
virtual void update()
update the subcomponents
Definition: sphererobot.cpp:55
virtual void placeIntern(const osg::Matrix &pose)
sets the pose of the vehicle
Definition: sphererobot.cpp:96
virtual void destroy()
destroys vehicle and space
Definition: sphererobot.cpp:222
Matrixd Matrix
Definition: osgforwarddecl.h:47
double diameter
Definition: sphererobot.h:39
Definition: sphererobot.h:60
Definition: sphererobot.h:61
Definition: joint.h:41
Definition: sphererobot.h:60
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: sphererobot.cpp:88
virtual Primitive * getMainPrimitive() const
the main object of the robot, which is used for position and speed tracking
Definition: sphererobot.h:136
Data structure for accessing the OpenSceneGraph.
Definition: osghandle.h:79
virtual void create(const osg::Matrix &pose)
creates vehicle at desired pose
Definition: sphererobot.cpp:140
SliderServo * servo[3]
Definition: sphererobot.h:70
static SphererobotConf getDefaultConf()
Definition: sphererobot.h:82
SliderJoint * slider[3]
Definition: sphererobot.h:72
double slidermass
Definition: sphererobot.h:43
This is a class, which models a snake like robot.
Definition: sphererobot.h:57
virtual int getSensorsIntern(double *sensors, int sensornumber)
Writes the sensor values to an array in the memory.
Definition: sphererobot.cpp:71
Definition: sphererobot.h:60
Interface class for primitives represented in the physical and graphical world.
Definition: primitive.h:80
Definition: sphererobot.h:60
double hingeRange
Definition: sphererobot.h:47
Definition: sphererobot.h:61
std::list< SensorAttachment > sensors
Definition: oderobot.h:269
static const int sensorno
Definition: sphererobot.h:64
Definition: sphererobot.h:60
objects
Definition: sphererobot.h:60
OsgHandle osgHandle
Definition: oderobot.h:278
Definition: joint.h:304
OdeHandle odeHandle
Definition: oderobot.h:277
Abstract class for ODE robots.
Definition: oderobot.h:64
double force
Definition: sphererobot.h:46
Definition: sphererobot.h:61
virtual int getSegmentsPosition(std::vector< Position > &poslist)
returns a vector with the positions of all segments of the robot
Definition: sphererobot.cpp:130
double pendulardiameter
Definition: sphererobot.h:41
double spheremass
Definition: sphererobot.h:40
Sphererobot(const OdeHandle &odeHandle, const OsgHandle &osgHandle, const SphererobotConf &conf, const std::string &name)
Definition: sphererobot.cpp:40
SphererobotConf conf
Definition: sphererobot.h:66
bool created
Definition: sphererobot.h:67
double pendularmass
Definition: sphererobot.h:42
double sliderrange
Definition: sphererobot.h:44
general servo motor to achieve position control
Definition: oneaxisservo.h:38
std::list< MotorAttachment > motors
Definition: oderobot.h:270
virtual int getSensorNumberIntern()
Returns the number of sensors used by the robot.
Definition: sphererobot.cpp:122
int c
Definition: hexapod.cpp:56
Definition: sphererobot.h:37
Joint * joint[6]
Definition: sphererobot.h:73