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
sphererobot3masses.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 __SPHEREROBOT3MASSES_H
26 #define __SPHEREROBOT3MASSES_H
27 
28 #include "primitive.h"
29 #include "joint.h"
30 #include "oneaxisservo.h"
31 #include "oderobot.h"
32 #include "sensor.h"
33 #include "raysensorbank.h"
34 
35 namespace lpzrobots {
36 
37  /// configuration object for the Sphererobot3Masses robot.
38 typedef struct {
39 public:
40  double diameter;
41  double spheremass;
42  double pendulardiameter; ///< automatically set
43  double pendularmass;
44  double motorpowerfactor; ///< power factor for servos w.r.t. pendularmass
45  double pendularrange; ///< fraction of the diameter the pendular masses can move to one side
46  bool motorsensor; ///< motor values as sensors
47  bool irAxis1;
48  bool irAxis2;
49  bool irAxis3;
50  bool irRing; ///< IR sensors in a ring in x,z plane (collides with irAxis1 and irAxis3)
51  bool irSide; ///< 4 IR senors to both side in y direction (collides with irAxis2)
53  double irsensorscale; ///< range of the ir sensors in units of diameter
54  double irCharacter; ///< characteristics of sensor (\f[ x^c \f] where x is the range-distance)
55  RaySensor* irSensorTempl; ///< template for creation of the other ir sensors (if 0 then IRSensor(irCharacter))
56  double motor_ir_before_sensors; ///< if true motor sensors and ir sensors are given before additional sensors
57  double brake; ///< if nonzero the robot brakes (deaccelerates actively/magically)
58  double axesShift; ///< defines how much the axes are shifted from the center
59 
60  /// function that deletes sensors
61  void destroy();
62  /// list of sensors that are mounted at the robot. (e.g.\ AxisOrientationSensor)
63  std::list<Sensor*> sensors;
64  /// adds a sensor to the list of sensors
65  void addSensor(Sensor* s) { sensors.push_back(s); }
66 } Sphererobot3MassesConf;
67 
68 /**
69  A spherical robot with 3 internal masses, which can slide on their orthogonal axes.
70  This robot was inspired by Julius Popp (http://sphericalrobots.com)
71 */
73 {
74 public:
75  /// enum for the objects of the robot
77 
78 protected:
79  static const int servono=3;
80  unsigned int numberaxis;
81 
84 
86  RaySensorBank irSensorBank; ///< a collection of ir sensors
87  double transparency;
88  bool created;
89 
90 public:
91 
92  /**
93  *constructor
94  **/
96  const Sphererobot3MassesConf& conf, const std::string& name, double transparency=0.5 );
97 
98 protected:
99  /**
100  *constructor for children
101  **/
104  const std::string& name, const std::string& revision, double transparency);
105  /// initialises some internal variables
106  void init();
107 public:
108  virtual ~Sphererobot3Masses();
109 
110 
111  /// default configuration
114  c.diameter = 1;
115  c.spheremass = .3;// 0.1
116  c.pendularmass = 1.0;
117  c.pendularrange = 0.20; // range of the slider from center in multiple of diameter [-range,range]
118  c.motorpowerfactor = 100;
119  c.motorsensor = true;
120  c.irAxis1=false;
121  c.irAxis2=false;
122  c.irAxis3=false;
123  c.irRing=false;
124  c.irSide=false;
126  c.irsensorscale=1.5;
127  c.irCharacter=1;
128  c.irSensorTempl=0;
129  c.motor_ir_before_sensors=false;
130  c.axesShift=0;
131  c.brake=0;
132  c.axesShift=0;
133  return c;
134  }
135 
136  virtual void update();
137 
138  virtual void placeIntern(const osg::Matrix& pose);
139 
140  virtual void doInternalStuff(GlobalData& globalData);
141 
142  virtual void sense(GlobalData& globalData) override;
143 
144  virtual int getSensorsIntern( sensor* sensors, int sensornumber );
145 
146  virtual void setMotorsIntern( const double* motors, int motornumber );
147 
148  virtual int getMotorNumberIntern();
149 
150  virtual int getSensorNumberIntern();
151 
152  /******** CONFIGURABLE ***********/
153  virtual void notifyOnChange(const paramkey& key);
154 
155 
156 protected:
157 
158  virtual void create(const osg::Matrix& pose);
159  virtual void destroy();
160 
161 
162 };
163 
164 }
165 
166 #endif
Class for a bank (collection) of ray sensors.
Definition: raysensorbank.h:36
double irsensorscale
range of the ir sensors in units of diameter
Definition: sphererobot3masses.h:53
Data structure for accessing the ODE.
Definition: odehandle.h:44
double brake
if nonzero the robot brakes (deaccelerates actively/magically)
Definition: sphererobot3masses.h:57
bool irAxis3
Definition: sphererobot3masses.h:49
bool motorsensor
motor values as sensors
Definition: sphererobot3masses.h:46
RaySensor::rayDrawMode drawIRs
Definition: sphererobot3masses.h:52
std::list< Sensor * > sensors
list of sensors that are mounted at the robot. (e.g. AxisOrientationSensor)
Definition: sphererobot3masses.h:63
virtual void sense(GlobalData &globalData) override
this function is called each controlstep before control.
Definition: sphererobot3masses.cpp:173
double spheremass
Definition: sphererobot3masses.h:41
double pendulardiameter
automatically set
Definition: sphererobot3masses.h:42
Matrixd Matrix
Definition: osgforwarddecl.h:47
Interface class for graphic primitives like spheres, boxes, and meshes, which can be drawn by OSG...
Definition: osgprimitive.h:62
charArray paramkey
Definition: avrtypes.h:36
SliderServo * servo[servono]
Definition: sphererobot3masses.h:82
Sphererobot3MassesConf conf
Definition: sphererobot3masses.h:85
OSGPrimitive * axis[servono]
Definition: sphererobot3masses.h:83
double motor_ir_before_sensors
if true motor sensors and ir sensors are given before additional sensors
Definition: sphererobot3masses.h:56
Definition: raysensor.h:56
unsigned int numberaxis
Definition: sphererobot3masses.h:80
Definition: sphererobot3masses.h:76
rayDrawMode
Definition: raysensor.h:56
double sensor
Definition: types.h:29
parts
enum for the objects of the robot
Definition: sphererobot3masses.h:76
Data structure for accessing the OpenSceneGraph.
Definition: osghandle.h:79
Definition: sphererobot3masses.h:76
virtual ~Sphererobot3Masses()
Definition: sphererobot3masses.cpp:95
bool irAxis1
Definition: sphererobot3masses.h:47
virtual void destroy()
destroys vehicle and space
Definition: sphererobot3masses.cpp:336
Abstract class for sensors that can be plugged into a robot.
Definition: sensor.h:43
double irCharacter
characteristics of sensor ( where x is the range-distance)
Definition: sphererobot3masses.h:54
virtual int getSensorsIntern(sensor *sensors, int sensornumber)
Writes the sensor values to an array in the memory.
Definition: sphererobot3masses.cpp:127
virtual void notifyOnChange(const paramkey &key)
Is called when a parameter was changes via setParam().
Definition: sphererobot3masses.cpp:348
bool irSide
4 IR senors to both side in y direction (collides with irAxis2)
Definition: sphererobot3masses.h:51
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: sphererobot3masses.cpp:159
static Sphererobot3MassesConf getDefaultConf()
default configuration
Definition: sphererobot3masses.h:112
bool irRing
IR sensors in a ring in x,z plane (collides with irAxis1 and irAxis3)
Definition: sphererobot3masses.h:50
double pendularrange
fraction of the diameter the pendular masses can move to one side
Definition: sphererobot3masses.h:45
bool created
Definition: sphererobot3masses.h:88
A spherical robot with 3 internal masses, which can slide on their orthogonal axes.
Definition: sphererobot3masses.h:72
Data structure holding all essential global information.
Definition: globaldata.h:57
std::list< SensorAttachment > sensors
Definition: oderobot.h:269
RaySensorBank irSensorBank
a collection of ir sensors
Definition: sphererobot3masses.h:86
configuration object for the Sphererobot3Masses robot.
Definition: sphererobot3masses.h:38
bool irAxis2
Definition: sphererobot3masses.h:48
virtual int getSensorNumberIntern()
overload this function in a subclass to specific the number of custom sensors
Definition: sphererobot3masses.cpp:204
void addSensor(Sensor *s)
adds a sensor to the list of sensors
Definition: sphererobot3masses.h:65
Sphererobot3Masses(const OdeHandle &odeHandle, const OsgHandle &osgHandle, const Sphererobot3MassesConf &conf, const std::string &name, double transparency=0.5)
constructor
Definition: sphererobot3masses.cpp:53
virtual void doInternalStuff(GlobalData &globalData)
this function is called in each simulation timestep (always after control).
Definition: sphererobot3masses.cpp:180
OsgHandle osgHandle
Definition: oderobot.h:278
double axesShift
defines how much the axes are shifted from the center
Definition: sphererobot3masses.h:58
OdeHandle odeHandle
Definition: oderobot.h:277
Definition: sphererobot3masses.h:76
virtual void create(const osg::Matrix &pose)
creates vehicle at desired position and orientation
Definition: sphererobot3masses.cpp:215
virtual void update()
update the OSG notes here, if overwritten, call OdeRobot::update()!
Definition: sphererobot3masses.cpp:104
double diameter
Definition: sphererobot3masses.h:40
double motorpowerfactor
power factor for servos w.r.t. pendularmass
Definition: sphererobot3masses.h:44
Abstract class for ODE robots.
Definition: oderobot.h:64
double pendularmass
Definition: sphererobot3masses.h:43
static const int servono
Definition: sphererobot3masses.h:79
void init()
initialises some internal variables
Definition: sphererobot3masses.cpp:85
double transparency
Definition: sphererobot3masses.h:87
RaySensor * irSensorTempl
template for creation of the other ir sensors (if 0 then IRSensor(irCharacter))
Definition: sphererobot3masses.h:55
Definition: sphererobot3masses.h:76
Definition: sphererobot3masses.h:76
virtual void placeIntern(const osg::Matrix &pose)
wrapper to for
Definition: sphererobot3masses.cpp:167
general servo motor to achieve position control
Definition: oneaxisservo.h:38
std::list< MotorAttachment > motors
Definition: oderobot.h:270
virtual int getMotorNumberIntern()
overload this function in a subclass to specific the number of custom sensors
Definition: sphererobot3masses.cpp:200
Class for Ray-based sensors.
Definition: raysensor.h:54
int c
Definition: hexapod.cpp:56