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
nimm2.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 __NIMM2_H
25 #define __NIMM2_H
26 
27 #include "oderobot.h"
28 #include "raysensorbank.h"
29 
30 #include "primitive.h"
31 #include "joint.h"
32 #include <selforg/inspectable.h>
33 
34 
35 namespace lpzrobots {
36 
37 typedef struct Bumper{
38  Bumper() { trans = 0; bump = 0;}
41 } Bumper;
42 
43 typedef struct {
44  double size;
45  double force;
46  double speed;
47  double massFactor;
49  double wheelSize; ///< size of the wheels in body diameters
50  double wheelSlip;
51  double wheelOffset; ///< offset of the wheel position in body length (not size) (<0 automatic)
52  std::string wheelTexture;
53  bool bumper;
54  bool cigarMode;
55  double cigarLength;
56  bool irFront;
57  bool irBack;
58  bool irSide;
59  double irRange;
61  bool visForce;
62  bool boxMode;
63  double boxWidth;
64 } Nimm2Conf;
65 
66 /** Robot that looks like a Nimm 2 Bonbon :-)
67  2 wheels and a cylinder like body
68 
69  wheel order: left, right
70  IR order: front left, front right, right, right rear,
71  rear right, rear left, left rear, left
72 */
73 class Nimm2 : public OdeRobot /*, public Inspectable*/ {
74 public:
75 
76  Nimm2(const OdeHandle& odehandle, const OsgHandle& osgHandle,
77  const Nimm2Conf& conf, const std::string& name);
78 
81  conf.size=1;
82  conf.force=5;
83  conf.speed=12;
84  conf.massFactor=1;
85  conf.sphereWheels=true;
86  conf.wheelSize=1;
87  conf.wheelOffset=-1.0; // disabled
88  conf.wheelSlip=0;
89  conf.bumper=false;
90  conf.cigarMode=false;
91  conf.cigarLength=2.0;
92  conf.irFront=false;
93  conf.irBack=false;
94  conf.irSide=false;
95  conf.irRange=3;
96  conf.singleMotor=false;
97  conf.visForce=false;
98  conf.boxMode=false;
99  conf.boxWidth=1.0;
100  conf.wheelTexture="Images/tire.rgb";
101  return conf;
102  }
103 
104  virtual ~Nimm2();
105 
106  /**
107  * updates the OSG nodes of the vehicle
108  */
109  virtual void update();
110 
111  /** sets the pose of the vehicle
112  @param pose desired 4x4 pose matrix
113  */
114  virtual void placeIntern(const osg::Matrix& pose);
115 
116  /** returns actual sensorvalues
117  @param sensors sensors scaled to [-1,1]
118  @param sensornumber length of the sensor array
119  @return number of actually written sensors
120  */
121  virtual int getSensorsIntern(sensor* sensors, int sensornumber);
122 
123  /** sets actual motorcommands
124  @param motors motors scaled to [-1,1]
125  @param motornumber length of the motor array
126  */
127  virtual void setMotorsIntern(const double* motors, int motornumber);
128 
129  /** returns number of sensors
130  */
131  virtual int getSensorNumberIntern(){
132  return sensorno;
133  };
134 
135  /** returns number of motors
136  */
137  virtual int getMotorNumberIntern(){
138  return motorno;
139  };
140 
141  /** returns a vector with the positions of all segments of the robot
142  @param poslist vector of positions (of all robot segments)
143  @return length of the list
144  */
145  virtual int getSegmentsPosition(std::vector<Position> &poslist);
146 
147 
148  /** this function is called in each timestep. It should perform robot-internal checks,
149  like space-internal collision detection, sensor resets/update etc.
150  @param globalData structure that contains global data from the simulation environment
151  */
152  virtual void doInternalStuff(GlobalData& globalData);
153 
154  virtual double& getSumForce() { return sumForce; }
155 
156  virtual double& getContactPoints() { return contactPoints; }
157 
158 protected:
159 
161 
162 
163  /** creates vehicle at desired pose
164  @param pose 4x4 pose matrix
165  */
166  virtual void create(const osg::Matrix& pose);
167 
168 
169 
170  /** destroys vehicle and space
171  */
172  virtual void destroy();
173  static void mycallback(void *data, dGeomID o1, dGeomID o2);
174 
175  /**
176  * Inspectable interface
177  */
178  /*
179  virtual std::list<iparamkey> getInternalParamNames() const { return std::list<iparamkey>(); }
180 
181  virtual std::list<iparamval> getInternalParams() const { return std::list<iparamval>(); }*/
182  /*
183  virtual std::list<Inspectable::iparamkey> getInternalParamNames() const;
184 
185  virtual std::list<Inspectable::iparamval> getInternalParams() const;
186  */
187 
189 
190  double length; // chassis length
191  double width; // chassis width
192  double height; // chassis height
193  double radius; // wheel radius
194  double wheelthickness; // thickness of the wheels
195  double cmass; // chassis mass
196  double wmass; // wheel mass
197  int sensorno; //number of sensors
198  int motorno; // number of motors
199 
200  bool created; // true if robot was created
201  double max_force;
202 
203  double wheeloffset; // offset from center when in cigarMode
204  int number_bumpers; // number of bumpers (1 -> bumpers at one side, 2 -> bumpers at 2 sides)
206 
207  bool visForce; // decides if contact force is made visible in guilogger
208  double sumForce; // stores the contact force made by collisions with external objects
209 
210 };
211 
212 }
213 
214 #endif
bool irSide
Definition: nimm2.h:58
bool visForce
Definition: nimm2.h:207
double cmass
Definition: nimm2.h:195
Data structure for accessing the ODE.
Definition: odehandle.h:44
double sumForce
Definition: nimm2.h:208
virtual double & getSumForce()
Definition: nimm2.h:154
double boxWidth
Definition: nimm2.h:63
virtual int getSensorsIntern(sensor *sensors, int sensornumber)
returns actual sensorvalues
Definition: nimm2.cpp:140
Matrixd Matrix
Definition: osgforwarddecl.h:47
Primitive * trans
Definition: nimm2.h:39
Robot that looks like a Nimm 2 Bonbon :-) 2 wheels and a cylinder like body.
Definition: nimm2.h:73
static void mycallback(void *data, dGeomID o1, dGeomID o2)
double length
Definition: nimm2.h:190
double sensor
Definition: types.h:29
double max_force
Definition: nimm2.h:201
double wheelSlip
Definition: nimm2.h:50
double wheeloffset
Definition: nimm2.h:203
Data structure for accessing the OpenSceneGraph.
Definition: osghandle.h:79
Definition: nimm2.h:37
double wheelthickness
Definition: nimm2.h:194
bool irFront
Definition: nimm2.h:56
virtual int getSegmentsPosition(std::vector< Position > &poslist)
returns a vector with the positions of all segments of the robot
Definition: nimm2.cpp:169
double cigarLength
Definition: nimm2.h:55
bool singleMotor
Definition: nimm2.h:60
virtual void create(const osg::Matrix &pose)
creates vehicle at desired pose
Definition: nimm2.cpp:197
double wheelOffset
offset of the wheel position in body length (not size) (<0 automatic)
Definition: nimm2.h:51
double width
Definition: nimm2.h:191
int sensorno
Definition: nimm2.h:197
virtual int getSensorNumberIntern()
returns number of sensors
Definition: nimm2.h:131
double contactPoints
Definition: nimm2.h:160
Definition: nimm2.h:43
double wmass
Definition: nimm2.h:196
Primitive * bump
Definition: nimm2.h:40
struct lpzrobots::Bumper Bumper
Interface class for primitives represented in the physical and graphical world.
Definition: primitive.h:80
bool visForce
Definition: nimm2.h:61
Nimm2(const OdeHandle &odehandle, const OsgHandle &osgHandle, const Nimm2Conf &conf, const std::string &name)
Definition: nimm2.cpp:42
Nimm2Conf conf
Inspectable interface.
Definition: nimm2.h:188
Data structure holding all essential global information.
Definition: globaldata.h:57
std::list< SensorAttachment > sensors
Definition: oderobot.h:269
int motorno
Definition: nimm2.h:198
double wheelSize
size of the wheels in body diameters
Definition: nimm2.h:49
virtual ~Nimm2()
Definition: nimm2.cpp:110
double irRange
Definition: nimm2.h:59
bool irBack
Definition: nimm2.h:57
virtual void update()
updates the OSG nodes of the vehicle
Definition: nimm2.cpp:180
OsgHandle osgHandle
Definition: oderobot.h:278
bool cigarMode
Definition: nimm2.h:54
bool created
Definition: nimm2.h:200
static Nimm2Conf getDefaultConf()
Definition: nimm2.h:79
virtual void setMotorsIntern(const double *motors, int motornumber)
sets actual motorcommands
Definition: nimm2.cpp:119
Abstract class for ODE robots.
Definition: oderobot.h:64
virtual int getMotorNumberIntern()
returns number of motors
Definition: nimm2.h:137
std::string wheelTexture
Definition: nimm2.h:52
bool boxMode
Definition: nimm2.h:62
double force
Definition: nimm2.h:45
virtual void destroy()
destroys vehicle and space
Definition: nimm2.cpp:392
virtual void placeIntern(const osg::Matrix &pose)
sets the pose of the vehicle
Definition: nimm2.cpp:155
Bumper bumper[2]
Definition: nimm2.h:205
double massFactor
Definition: nimm2.h:47
double height
Definition: nimm2.h:192
double size
Definition: nimm2.h:44
int number_bumpers
Definition: nimm2.h:204
double radius
Definition: nimm2.h:193
bool bumper
Definition: nimm2.h:53
double speed
Definition: nimm2.h:46
bool sphereWheels
Definition: nimm2.h:48
virtual void doInternalStuff(GlobalData &globalData)
this function is called in each timestep.
Definition: nimm2.cpp:186
std::list< MotorAttachment > motors
Definition: oderobot.h:270
virtual double & getContactPoints()
Definition: nimm2.h:156
Bumper()
Definition: nimm2.h:38