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
robotchain.h
Go to the documentation of this file.
1 
2 /***************************************************************************
3  * Copyright (C) 2005-2012 LpzRobots development team *
4  * Georg Martius <georg dot martius at web dot de> *
5  * Frank Guettler <guettler at informatik dot uni-leipzig dot de *
6  * Frank Hesse <frank at nld dot ds dot mpg dot de> *
7  * Ralf Der <ralfder at mis dot mpg dot de> *
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  * This program is distributed in the hope that it will be useful, *
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17  * GNU General Public License for more details. *
18  * *
19  * You should have received a copy of the GNU General Public License *
20  * along with this program; if not, write to the *
21  * Free Software Foundation, Inc., *
22  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
23  * *
24  ***************************************************************************/
25 #ifndef __ROBOTCHAIN_H
26 #define __ROBOTCHAIN_H
27 
28 #include <ode_robots/oderobot.h>
29 
30 namespace lpzrobots {
31 
32  typedef struct {
33  public:
34  double size; ///< scaling factor for robot (size of one robot)
35  double distance; ///< distance between robots
36  double force; ///< @see Nimm2Conf
37  double speed; ///< @see Nimm2Conf
38  int numRobots; ///< number of robots in the chain
39  double massFactor; ///< @see Nimm2Conf
40  double wheelSlip; ///< @see Nimm2Conf
41  std::string color; ///< color of robots
42  bool useIR; ///< use infrared sensors?
43  int mainRobot; ///< robot index that is returned by getMainPrimitive() (-1 for middle robot, then massFactorMain and forceMain is ignored)
44  double massFactorMain; ///< massfactor of main robot @see Nimm2Conf
45  double forceMain; ///< factor of main robot @see Nimm2Conf
47 
48 
49  /** Chain of robots
50  */
51  class RobotChain : public OdeRobot {
52  public:
53 
54  /**
55  * constructor of uwo robot
56  * @param odeHandle data structure for accessing ODE
57  * @param osgHandle ata structure for accessing OSG
58  * @param size scaling of robot
59  * @param force maximal used force to realize motorcommand
60  * @param radialLegs switches between cartensian and radial leg joints
61  */
63  const RobotChainConf& conf, const std::string& name);
64 
65  virtual ~RobotChain(){ destroy(); };
66 
69  c.numRobots = 5;
70  c.size = 0.6;
71  c.distance = 0.95;
72  c.force = 2;
73  c.speed = 45;
74  c.massFactor = 0.5;
75  c.wheelSlip = 0.02;
76  c.color = "robot3";
77  c.useIR = false;
78  c.mainRobot = -1;
80  c.forceMain = c.force;
81  return c;
82  }
83 
84  /**
85  * updates the OSG nodes of the vehicle
86  */
87  virtual void update();
88 
89 
90  /** sets the pose of the vehicle
91  @param pose desired pose matrix
92  */
93  virtual void placeIntern(const osg::Matrix& pose);
94 
95  virtual int getSensorsIntern(sensor* sensors, int sensornumber);
96 
97  virtual void setMotorsIntern(const double* motors, int motornumber);
98 
99  virtual int getSensorNumberIntern();
100 
101  virtual int getMotorNumberIntern();
102 
103  virtual void doInternalStuff(GlobalData& globalData);
104 
105  /******** CONFIGURABLE ***********/
106  virtual void notifyOnChange(const paramkey& key);
107 
108 
109  virtual int getIRSensorNum();
110 
111  protected:
112  virtual Primitive* getMainPrimitive() const;
113 
114  virtual void create(const osg::Matrix& pose);
115 
116  virtual void destroy();
117 
119 
120  bool created;
121 
122  std::vector <OdeRobot*> robots;
123  };
124 
125 }
126 
127 #endif
virtual Primitive * getMainPrimitive() const
return the primitive of the robot that is used for tracking and camera following
Definition: robotchain.cpp:197
Data structure for accessing the ODE.
Definition: odehandle.h:44
bool useIR
use infrared sensors?
Definition: robotchain.h:42
Matrixd Matrix
Definition: osgforwarddecl.h:47
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: robotchain.cpp:54
charArray paramkey
Definition: avrtypes.h:36
virtual int getMotorNumberIntern()
overload this function in a subclass to specific the number of custom sensors
Definition: robotchain.cpp:46
double size
scaling factor for robot (size of one robot)
Definition: robotchain.h:34
int numRobots
number of robots in the chain
Definition: robotchain.h:38
std::string color
color of robots
Definition: robotchain.h:41
double sensor
Definition: types.h:29
virtual void create(const osg::Matrix &pose)
Definition: robotchain.cpp:130
RobotChainConf conf
Definition: robotchain.h:118
double speed
Definition: robotchain.h:37
RobotChain(const OdeHandle &odeHandle, const OsgHandle &osgHandle, const RobotChainConf &conf, const std::string &name)
constructor of uwo robot
Definition: robotchain.cpp:39
double wheelSlip
Definition: robotchain.h:40
Data structure for accessing the OpenSceneGraph.
Definition: osghandle.h:79
virtual void notifyOnChange(const paramkey &key)
Is called when a parameter was changes via setParam().
Definition: robotchain.cpp:206
virtual void placeIntern(const osg::Matrix &pose)
sets the pose of the vehicle
Definition: robotchain.cpp:109
double distance
distance between robots
Definition: robotchain.h:35
virtual void doInternalStuff(GlobalData &globalData)
this function is called in each simulation timestep (always after control).
Definition: robotchain.cpp:123
virtual int getSensorNumberIntern()
overload this function in a subclass to specific the number of custom sensors
Definition: robotchain.cpp:66
std::vector< OdeRobot * > robots
Definition: robotchain.h:122
Interface class for primitives represented in the physical and graphical world.
Definition: primitive.h:80
Data structure holding all essential global information.
Definition: globaldata.h:57
double massFactorMain
massfactor of main robot
Definition: robotchain.h:44
std::list< SensorAttachment > sensors
Definition: oderobot.h:269
int mainRobot
robot index that is returned by getMainPrimitive() (-1 for middle robot, then massFactorMain and forc...
Definition: robotchain.h:43
double force
Definition: robotchain.h:36
OsgHandle osgHandle
Definition: oderobot.h:278
OdeHandle odeHandle
Definition: oderobot.h:277
virtual void destroy()
destroys vehicle and space
Definition: robotchain.cpp:186
static RobotChainConf getDefaultConf()
Definition: robotchain.h:67
Abstract class for ODE robots.
Definition: oderobot.h:64
virtual int getSensorsIntern(sensor *sensors, int sensornumber)
overload this function in a subclass to do specific sensor handling, not needed for generic sensors ...
Definition: robotchain.cpp:74
Definition: robotchain.h:32
double forceMain
factor of main robot
Definition: robotchain.h:45
Chain of robots.
Definition: robotchain.h:51
virtual int getIRSensorNum()
Definition: robotchain.cpp:179
bool created
Definition: robotchain.h:120
virtual ~RobotChain()
Definition: robotchain.h:65
virtual void update()
updates the OSG nodes of the vehicle
Definition: robotchain.cpp:114
std::list< MotorAttachment > motors
Definition: oderobot.h:270
int c
Definition: hexapod.cpp:56
double massFactor
Definition: robotchain.h:39