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
twowheeled.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 __TWO_WHEELED__
25 #define __TWO_WHEELED__
26 
27 #include <ode_robots/nimm2.h>
28 #include <ode_robots/camera.h>
29 #include <ode_robots/camerasensor.h>
30 #include <ode_robots/imageprocessors.h>
31 #include <ode_robots/sensor.h>
32 
33 namespace lpzrobots {
34 
35  typedef struct {
36  Nimm2Conf n2cfg; ///< configuration for underlying nimm2 robot
37  CameraConf camcfg; ///< camera config. Allows to change the image processing
38  bool useCamera; ///< whether to use the camera
39  osg::Matrix camPos; ///< relative pose of the camera
40  /** camera sensor (converts image to sensor data)
41  (if NULL then DirectCameraSensor() is used) */
43  /// list of sensors that are mounted at the robot. (e.g.\ AxisOrientationSensor)
44  std::list<Sensor*> sensors;
45  /// adds a sensor to the list of sensors
46  void addSensor(Sensor* s) { sensors.push_back(s); }
47  } TwoWheeledConf;
48 
49  /** Robot is based on nimm2 with
50  a camera installed
51  */
52  class TwoWheeled : public Nimm2{
53  public:
54 
55  /**
56  * constructor of twowheeled robot
57  * @param odeHandle data structure for accessing ODE
58  * @param osgHandle ata structure for accessing OSG
59  * @param conf configuration structure
60  * @param name name of the robot
61  */
63  TwoWheeledConf conf, const std::string& name);
64 
69  conf.camcfg.width = 256;
70  conf.camcfg.height = 64;
71  conf.camcfg.fov = 90;
72  conf.camcfg.camSize = 0.08;
73  conf.camcfg.processors.push_back(new HSVImgProc(false,1));
74  // filter only Yellow color
75  conf.camcfg.processors.push_back(new ColorFilterImgProc(true, .5,
77  // only two sensors for left and right visual field
78  conf.camcfg.processors.push_back(new LineImgProc(true,20, 2));
79  conf.useCamera = true;
80  conf.camPos = osg::Matrix::rotate(M_PI/2,0,0,1)
81  * osg::Matrix::translate(-0.20,0,0.40);
82  conf.camSensor = 0;
83  return conf;
84  }
85 
86  virtual ~TwoWheeled();
87 
88  virtual void update();
89 
90  virtual int getSensorNumberIntern();
91 
92  virtual int getSensorsIntern(double* sensors, int sensornumber);
93 
94  virtual void sense(GlobalData& globalData);
95 
96 
97  protected:
98  /** creates vehicle at desired pose
99  @param pose 4x4 pose matrix
100  */
101  virtual void create(const osg::Matrix& pose);
102 
103  /** destroys vehicle and space
104  */
105  virtual void destroy();
106 
110  };
111 
112 }
113 
114 #endif
virtual int getSensorsIntern(double *sensors, int sensornumber)
returns actual sensorvalues
Definition: twowheeled.cpp:74
virtual void update()
updates the OSG nodes of the vehicle
Definition: twowheeled.cpp:82
Data structure for accessing the ODE.
Definition: odehandle.h:44
Definition: imageprocessors.h:124
std::list< Sensor * > sensors
list of sensors that are mounted at the robot. (e.g. AxisOrientationSensor)
Definition: twowheeled.h:44
virtual ~TwoWheeled()
Definition: twowheeled.cpp:58
Matrixd Matrix
Definition: osgforwarddecl.h:47
A Robot Camera.
Definition: camera.h:69
TwoWheeled(const OdeHandle &odeHandle, const OsgHandle &osgHandle, TwoWheeledConf conf, const std::string &name)
constructor of twowheeled robot
Definition: twowheeled.cpp:35
Robot that looks like a Nimm 2 Bonbon :-) 2 wheels and a cylinder like body.
Definition: nimm2.h:73
converts the image to a HSV coded image
Definition: imageprocessors.h:123
filters for a specific color (requires HSV, so use HSVImgProc before)
Definition: imageprocessors.h:199
Definition: imageprocessors.h:124
int width
horizontal resolution (power of 2)
Definition: camera.h:51
void addSensor(Sensor *s)
adds a sensor to the list of sensors
Definition: twowheeled.h:46
virtual void destroy()
destroys vehicle and space
Definition: twowheeled.cpp:110
Definition: camera.h:50
Data structure for accessing the OpenSceneGraph.
Definition: osghandle.h:79
CameraSensor * camSensor
camera sensor (converts image to sensor data) (if NULL then DirectCameraSensor() is used) ...
Definition: twowheeled.h:42
virtual void sense(GlobalData &globalData)
this function is called each controlstep before control.
Definition: twowheeled.cpp:89
Abstract class for sensors that can be plugged into a robot.
Definition: sensor.h:43
CameraSensor * camsensor
Definition: twowheeled.h:108
Definition: twowheeled.h:35
Definition: nimm2.h:43
float camSize
size of the physical camera object
Definition: camera.h:57
creates a lightsensitive sensorline.
Definition: imageprocessors.h:246
Data structure holding all essential global information.
Definition: globaldata.h:57
float fov
field of view in degree (opening angle of lenses)
Definition: camera.h:53
virtual void create(const osg::Matrix &pose)
creates vehicle at desired pose
Definition: twowheeled.cpp:99
std::list< SensorAttachment > sensors
Definition: oderobot.h:269
Robot is based on nimm2 with a camera installed.
Definition: twowheeled.h:52
static TwoWheeledConf getDefaultConf()
Definition: twowheeled.h:65
Camera * cam
Definition: twowheeled.h:109
virtual int getSensorNumberIntern()
returns number of sensors
Definition: twowheeled.cpp:66
static CameraConf getDefaultConf()
Definition: camera.h:102
OsgHandle osgHandle
Definition: oderobot.h:278
OdeHandle odeHandle
Definition: oderobot.h:277
Class to connect a Camera as a sensor to a robot.
Definition: camerasensor.h:43
bool useCamera
whether to use the camera
Definition: twowheeled.h:38
static Nimm2Conf getDefaultConf()
Definition: nimm2.h:79
ImageProcessors processors
list of image processors that filter the raw image
Definition: camera.h:61
CameraConf camcfg
camera config. Allows to change the image processing
Definition: twowheeled.h:37
TwoWheeledConf conf
Definition: twowheeled.h:107
osg::Matrix camPos
relative pose of the camera
Definition: twowheeled.h:39
Nimm2Conf n2cfg
configuration for underlying nimm2 robot
Definition: twowheeled.h:36
int height
vertical resolution (power of 2)
Definition: camera.h:52