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
camerasensor.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 __CAMERASENSOR_H
25 #define __CAMERASENSOR_H
26 
27 #include "camera.h"
28 #include "sensor.h"
29 
30 namespace lpzrobots {
31 
32 
33  /** Class to connect a Camera as a sensor to a robot.
34  Essentially it implements the conversion from the 2D image
35  to a list of double sensor values.
36  The initialization is a bit confusing: use the contructor (of a inherited class)
37  to provide custom parameter; setInitData sets the handles and the camera
38  which has to be called before the normal initialization of the Sensor (via init()).
39  A subclass has to overload intern_init() to initialize intern structures
40  (e.g. number of channels), sense() and get().
41 
42  */
43  class CameraSensor : public Sensor {
44  public:
45 
46  /** Creates a camera sensor. Use setInitData() to make it useable.
47  */
48  CameraSensor();
49 
50  virtual ~CameraSensor();
51 
52  /** sets the initial data structures like the camera.
53  The camera will be initialized in init() (don't initialize it before).
54  @param pose position and orientation of camera wrt.
55  the primitive that is given at init()
56  */
57  virtual void setInitData(Camera* camera, const OdeHandle& odeHandle,
58  const OsgHandle& osgHandle, const osg::Matrix& pose);
59 
60  /// changes the relative pose of the camera
61  virtual void setPose(const osg::Matrix& pose);
62 
63  /// relative pose of the camera
64  virtual osg::Matrix getPose();
65 
66  /// this function initialized the camera (no need to overload) (Sensor interface)
67  virtual void init(Primitive* own, Joint* joint = 0);
68 
69  /// overload this function an process the image (use camera->getImage())
70  virtual bool sense(const GlobalData& globaldata) = 0;
71 
72  /// overload this function and return the number of sensor values
73  virtual int getSensorNumber() const = 0;
74 
75  /// overload this function and return the sensor values
76  virtual int get(sensor* sensors, int length) const = 0;
77 
78  /// we update the camera's visual appearance
79  virtual void update();
80 
81  /// this is implemented based on get(sensor*,int)
82  virtual std::list<sensor> getList() const;
83 
84  protected:
85  /** overload this function to initialized you data structures.
86  Use camera->getImage() to get the image from the camera
87  */
88  virtual void intern_init() = 0;
89 
90 
96  };
97 
98 }
99 
100 #endif
OsgHandle osgHandle
Definition: camerasensor.h:93
Data structure for accessing the ODE.
Definition: odehandle.h:44
Matrixd Matrix
Definition: osgforwarddecl.h:47
A Robot Camera.
Definition: camera.h:69
Definition: joint.h:41
virtual void update()
we update the camera's visual appearance
Definition: camerasensor.cpp:76
double sensor
Definition: types.h:29
virtual ~CameraSensor()
Definition: camerasensor.cpp:47
Data structure for accessing the OpenSceneGraph.
Definition: osghandle.h:79
Abstract class for sensors that can be plugged into a robot.
Definition: sensor.h:43
bool isInitDataSet
Definition: camerasensor.h:95
osg::Matrix pose
Definition: camerasensor.h:94
CameraSensor()
Creates a camera sensor.
Definition: camerasensor.cpp:30
virtual std::list< sensor > getList() const
this is implemented based on get(sensor*,int)
virtual bool sense(const GlobalData &globaldata)=0
overload this function an process the image (use camera->getImage())
virtual osg::Matrix getPose()
relative pose of the camera
Definition: camerasensor.cpp:58
virtual void intern_init()=0
overload this function to initialized you data structures.
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
Camera * camera
Definition: camerasensor.h:91
virtual void setPose(const osg::Matrix &pose)
changes the relative pose of the camera
Definition: camerasensor.cpp:52
virtual void setInitData(Camera *camera, const OdeHandle &odeHandle, const OsgHandle &osgHandle, const osg::Matrix &pose)
sets the initial data structures like the camera.
Definition: camerasensor.cpp:36
OdeHandle odeHandle
Definition: camerasensor.h:92
Class to connect a Camera as a sensor to a robot.
Definition: camerasensor.h:43
virtual void init(Primitive *own, Joint *joint=0)
this function initialized the camera (no need to overload) (Sensor interface)
Definition: camerasensor.cpp:69
virtual int getSensorNumber() const =0
overload this function and return the number of sensor values