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
truckmesh.h
Go to the documentation of this file.
1 /***************************************************************************
2  * *
3  * TruckMesh robot, an example for using Meshes for robot bodies *
4  * basic code taken from the nimm4 robot *
5  * *
6  **************************************************************************/
7 /***************************************************************************
8  * Copyright (C) 2005-2011 LpzRobots development team *
9  * Georg Martius <georg dot martius at web dot de> *
10  * Frank Guettler <guettler at informatik dot uni-leipzig dot de *
11  * Frank Hesse <frank at nld dot ds dot mpg dot de> *
12  * Ralf Der <ralfder at mis dot mpg dot de> *
13  * *
14  * This program is free software; you can redistribute it and/or modify *
15  * it under the terms of the GNU General Public License as published by *
16  * the Free Software Foundation; either version 2 of the License, or *
17  * (at your option) any later version. *
18  * *
19  * This program is distributed in the hope that it will be useful, *
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22  * GNU General Public License for more details. *
23  * *
24  * You should have received a copy of the GNU General Public License *
25  * along with this program; if not, write to the *
26  * Free Software Foundation, Inc., *
27  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
28  * *
29  ***************************************************************************/
30 #ifndef __TRUCKMESH_H
31 #define __TRUCKMESH_H
32 
33 #include "oderobot.h"
34 
35 namespace lpzrobots {
36 
37  class Primitive;
38  class Hinge2Joint;
39 
40  /** Robot that looks like a Nimm 2 Bonbon :-)
41  4 wheels and a truck mesh like body
42  */
43  class TruckMesh : public OdeRobot{
44  public:
45 
46  /**
47  * constructor of TruckMesh robot
48  * @param odeHandle data structure for accessing ODE
49  * @param osgHandle ata structure for accessing OSG
50  * @param size scaling of robot
51  * @param force maximal used force to realize motorcommand
52  * @param speed factor for changing speed of robot
53  */
54  TruckMesh(const OdeHandle& odeHandle, const OsgHandle& osgHandle, const std::string& name,
55  double size=1, double force=3, double speed=15, double mass=1);
56 
57 
58  virtual ~TruckMesh(){ destroy(); };
59 
60  /**
61  * updates the OSG nodes of the vehicle
62  */
63  virtual void update();
64 
65 
66  /** sets the pose of the vehicle
67  @param pose desired pose matrix
68  */
69  virtual void placeIntern(const osg::Matrix& pose);
70 
71  /** returns actual sensorvalues
72  @param sensors sensors scaled to [-1,1]
73  @param sensornumber length of the sensor array
74  @return number of actually written sensors
75  */
76  virtual int getSensorsIntern(sensor* sensors, int sensornumber);
77 
78  /** sets actual motorcommands
79  @param motors motors scaled to [-1,1]
80  @param motornumber length of the motor array
81  */
82  virtual void setMotorsIntern(const double* motors, int motornumber);
83 
84  /** returns number of sensors
85  */
86  virtual int getSensorNumberIntern(){
87  return sensorno;
88  };
89 
90  /** returns number of motors
91  */
92  virtual int getMotorNumberIntern(){
93  return motorno;
94  };
95 
96  /** this function is called in each timestep. It should perform robot-internal checks,
97  like space-internal collision detection, sensor resets/update etc.
98  @param globalData structure that contains global data from the simulation environment
99  */
100  virtual void doInternalStuff(GlobalData& globalData);
101 
102 
103  protected:
104  /** creates vehicle at desired pose
105  @param pose 4x4 pose matrix
106  */
107  virtual void create(const osg::Matrix& pose);
108 
109  /** destroys vehicle and space
110  */
111  virtual void destroy();
112 
113  /** additional things for collision handling can be done here
114  */
115  static void mycallback(void *data, dGeomID o1, dGeomID o2);
116 
117  double length; // chassis length
118  double width; // chassis width
119  double middlewidth; // chassis middle position of width
120  double middlelength; // chassis middle position of length
121  double height; // chassis height
122  double radius; // wheel radius
123  double wheelthickness; // thickness of the wheels
124  double cmass; // chassis mass
125  double wmass; // wheel mass
126  int sensorno; // number of sensors
127  int motorno; // number of motors
128  int segmentsno; // number of motorsvehicle segments
129  double speed; // factor for adjusting speed of robot
130 
131  bool drawBoundings; // if bounding shapes of the body are drawed
132  double max_force; // maximal force for motors
133 
134  bool created; // true if robot was created
135 
136  };
137 
138 }
139 
140 #endif
double radius
Definition: truckmesh.h:122
bool created
Definition: truckmesh.h:134
double speed
Definition: truckmesh.h:129
Data structure for accessing the ODE.
Definition: odehandle.h:44
virtual void destroy()
destroys vehicle and space
Definition: truckmesh.cpp:268
virtual void placeIntern(const osg::Matrix &pose)
sets the pose of the vehicle
Definition: truckmesh.cpp:141
Matrixd Matrix
Definition: osgforwarddecl.h:47
static void mycallback(void *data, dGeomID o1, dGeomID o2)
additional things for collision handling can be done here
Definition: truckmesh.cpp:169
double wheelthickness
Definition: truckmesh.h:123
double sensor
Definition: types.h:29
virtual void create(const osg::Matrix &pose)
creates vehicle at desired pose
Definition: truckmesh.cpp:194
virtual int getSensorNumberIntern()
returns number of sensors
Definition: truckmesh.h:86
double width
Definition: truckmesh.h:118
virtual int getMotorNumberIntern()
returns number of motors
Definition: truckmesh.h:92
Data structure for accessing the OpenSceneGraph.
Definition: osghandle.h:79
TruckMesh(const OdeHandle &odeHandle, const OsgHandle &osgHandle, const std::string &name, double size=1, double force=3, double speed=15, double mass=1)
constructor of TruckMesh robot
Definition: truckmesh.cpp:51
int motorno
Definition: truckmesh.h:127
double cmass
Definition: truckmesh.h:124
double middlelength
Definition: truckmesh.h:120
double middlewidth
Definition: truckmesh.h:119
int segmentsno
Definition: truckmesh.h:128
Data structure holding all essential global information.
Definition: globaldata.h:57
std::list< SensorAttachment > sensors
Definition: oderobot.h:269
virtual void update()
updates the OSG nodes of the vehicle
Definition: truckmesh.cpp:154
virtual void doInternalStuff(GlobalData &globalData)
this function is called in each timestep.
Definition: truckmesh.cpp:188
virtual int getSensorsIntern(sensor *sensors, int sensornumber)
returns actual sensorvalues
Definition: truckmesh.cpp:123
OsgHandle osgHandle
Definition: oderobot.h:278
OdeHandle odeHandle
Definition: oderobot.h:277
virtual ~TruckMesh()
Definition: truckmesh.h:58
double wmass
Definition: truckmesh.h:125
Abstract class for ODE robots.
Definition: oderobot.h:64
double height
Definition: truckmesh.h:121
double max_force
Definition: truckmesh.h:132
bool drawBoundings
Definition: truckmesh.h:131
int sensorno
Definition: truckmesh.h:126
Robot that looks like a Nimm 2 Bonbon :-) 4 wheels and a truck mesh like body.
Definition: truckmesh.h:43
std::list< MotorAttachment > motors
Definition: oderobot.h:270
double length
Definition: truckmesh.h:117
virtual void setMotorsIntern(const double *motors, int motornumber)
sets actual motorcommands
Definition: truckmesh.cpp:91