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
forcedsphere.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 __FORCESSPHERE_H
26 #define __FORCESSPHERE_H
27 
28 #include "oderobot.h"
29 #include "sensor.h"
30 #include "motor.h"
31 
32 namespace lpzrobots {
33 
34  class Primitive;
35 
37  public:
40  /// deletes sensors
41  void destroy();
42 
43  double radius; //< radius of the sphere
44  double maxForce; ///< maximal force applied to the sphere
45  /// if true, the robot is powered to reach the given speed (force is calculated)
47  double maxSpeed; ///< maximum speed of the robot when in speedDriven mode
48 
49  /// bit mask for selecting the dimensions for the forces (see ForcedSphere::Dimensions)
51  /// whether to use a cylinder as body (like a puck) or the normal sphere
53  /// list of sensors that are mounted at the robot. (e.g.\ AxisOrientationSensor)
54  std::list<Sensor*> sensors;
55  /// adds a sensor to the list of sensors
56  void addSensor(Sensor* s) { sensors.push_back(s); }
57  /// list of motors that are mounted at the robot. (e.g.\ Speaker)
58  std::list<Motor*> motors;
59  /// adds a motor to the list of motors
60  void addMotor(Motor* m) { motors.push_back(m); }
61 
62  };
63 
64  class ForcedSphere : public OdeRobot
65  {
66  protected:
67  Primitive* object[1];
68  bool created;
70 
71  public:
72 
73  enum Dimensions { X = 1, Y = 2, Z = 4 };
74 
75  /**
76  * constructor
77  *
78  * use getDefaultConf() to obtain a configuration with default values, which can be altered
79  * to personal needs.
80  **/
82  const ForcedSphereConf& ForcedSphereConf, const std::string& name);
83 
84  virtual ~ForcedSphere();
85 
88  c.radius = 1;
89  c.maxForce = 1;
90  c.drivenDimensions = X | Y;
91  c.cylinderBody = false;
92  c.speedDriven=false;
93  c.maxSpeed = 5;
94  return c;
95  }
96 
97  virtual void update();
98 
99  virtual void placeIntern(const osg::Matrix& pose);
100 
101  virtual void doInternalStuff(GlobalData& globalData);
102 
103  virtual int getSensorsIntern( sensor* sensors, int sensornumber );
104  virtual void setMotorsIntern( const double* motors, int motornumber );
105  virtual int getMotorNumberIntern();
106  virtual int getSensorNumberIntern();
107 
108  virtual Primitive* getMainPrimitive() const { return object[0]; }
109 
110  protected:
111 
112  virtual void create(const osg::Matrix& pose);
113  virtual void destroy();
114 
115 
116  };
117 
118 }
119 
120 #endif
void destroy()
deletes sensors
Definition: forcedsphere.cpp:41
Definition: forcedsphere.h:73
Definition: forcedsphere.h:36
Definition: forcedsphere.h:73
Data structure for accessing the ODE.
Definition: odehandle.h:44
short drivenDimensions
bit mask for selecting the dimensions for the forces (see ForcedSphere::Dimensions) ...
Definition: forcedsphere.h:50
ForcedSphereConf()
Definition: forcedsphere.cpp:37
virtual void update()
update the OSG notes here, if overwritten, call OdeRobot::update()!
Definition: forcedsphere.cpp:65
ForcedSphere(const OdeHandle &odeHandle, const OsgHandle &osgHandle, const ForcedSphereConf &ForcedSphereConf, const std::string &name)
constructor
Definition: forcedsphere.cpp:50
Matrixd Matrix
Definition: osgforwarddecl.h:47
virtual int getSensorsIntern(sensor *sensors, int sensornumber)
overload this function in a subclass to do specific sensor handling, not needed for generic sensors ...
Definition: forcedsphere.cpp:70
double radius
Definition: forcedsphere.h:43
virtual void placeIntern(const osg::Matrix &pose)
wrapper to for
Definition: forcedsphere.cpp:107
void addMotor(Motor *m)
adds a motor to the list of motors
Definition: forcedsphere.h:60
Dimensions
Definition: forcedsphere.h:73
Definition: forcedsphere.h:64
double sensor
Definition: types.h:29
virtual Primitive * getMainPrimitive() const
return the primitive of the robot that is used for tracking and camera following
Definition: forcedsphere.h:108
Data structure for accessing the OpenSceneGraph.
Definition: osghandle.h:79
static ForcedSphereConf getDefaultConf()
Definition: forcedsphere.h:86
double maxSpeed
maximum speed of the robot when in speedDriven mode
Definition: forcedsphere.h:47
Definition: forcedsphere.h:73
Abstract class for sensors that can be plugged into a robot.
Definition: sensor.h:43
virtual void setMotorsIntern(const double *motors, int motornumber)
overload this function in a subclass to do specific sensor handling, not needed for generic motors ...
Definition: forcedsphere.cpp:80
double maxForce
maximal force applied to the sphere
Definition: forcedsphere.h:44
virtual void destroy()
Definition: forcedsphere.cpp:182
bool created
Definition: forcedsphere.h:68
Abstact base class for attachable motors.
Definition: motor.h:35
Interface class for primitives represented in the physical and graphical world.
Definition: primitive.h:80
virtual int getSensorNumberIntern()
overload this function in a subclass to specific the number of custom sensors
Definition: forcedsphere.cpp:145
Data structure holding all essential global information.
Definition: globaldata.h:57
std::list< SensorAttachment > sensors
Definition: oderobot.h:269
bool cylinderBody
whether to use a cylinder as body (like a puck) or the normal sphere
Definition: forcedsphere.h:52
OsgHandle osgHandle
Definition: oderobot.h:278
OdeHandle odeHandle
Definition: oderobot.h:277
virtual ~ForcedSphere()
Definition: forcedsphere.cpp:59
Abstract class for ODE robots.
Definition: oderobot.h:64
std::list< Motor * > motors
list of motors that are mounted at the robot. (e.g. Speaker)
Definition: forcedsphere.h:58
virtual void doInternalStuff(GlobalData &globalData)
this function is called in each simulation timestep (always after control).
Definition: forcedsphere.cpp:114
virtual void create(const osg::Matrix &pose)
Definition: forcedsphere.cpp:154
bool speedDriven
if true, the robot is powered to reach the given speed (force is calculated)
Definition: forcedsphere.h:46
std::list< Sensor * > sensors
list of sensors that are mounted at the robot. (e.g. AxisOrientationSensor)
Definition: forcedsphere.h:54
~ForcedSphereConf()
Definition: forcedsphere.cpp:39
std::list< MotorAttachment > motors
Definition: oderobot.h:270
ForcedSphereConf conf
Definition: forcedsphere.h:69
int c
Definition: hexapod.cpp:56
void addSensor(Sensor *s)
adds a sensor to the list of sensors
Definition: forcedsphere.h:56
virtual int getMotorNumberIntern()
overload this function in a subclass to specific the number of custom sensors
Definition: forcedsphere.cpp:136