camerasensor.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2011 LpzRobots development team                    *
00003  *    Georg Martius  <georg dot martius at web dot de>                     *
00004  *    Frank Guettler <guettler at informatik dot uni-leipzig dot de        *
00005  *    Frank Hesse    <frank at nld dot ds dot mpg dot de>                  *
00006  *    Ralf Der       <ralfder at mis dot mpg dot de>                       *
00007  *                                                                         *
00008  *   This program is free software; you can redistribute it and/or modify  *
00009  *   it under the terms of the GNU General Public License as published by  *
00010  *   the Free Software Foundation; either version 2 of the License, or     *
00011  *   (at your option) any later version.                                   *
00012  *                                                                         *
00013  *   This program is distributed in the hope that it will be useful,       *
00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00016  *   GNU General Public License for more details.                          *
00017  *                                                                         *
00018  *   You should have received a copy of the GNU General Public License     *
00019  *   along with this program; if not, write to the                         *
00020  *   Free Software Foundation, Inc.,                                       *
00021  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00022  *                                                                         *
00023  ***************************************************************************/
00024 #ifndef __CAMERASENSOR_H
00025 #define __CAMERASENSOR_H
00026 
00027 #include "camera.h"
00028 #include "sensor.h"
00029 
00030 namespace lpzrobots {
00031 
00032 
00033   /** Class to connect a Camera as a sensor to a robot. 
00034       Essentially it implements the conversion from the 2D image 
00035       to a list of double sensor values. 
00036       The initialization is a bit confusing: use the contructor (of a inherited class)
00037       to provide custom parameter; setInitData sets the handles and the camera
00038       which has to be called before the normal initialization of the Sensor (via init()).
00039       A subclass has to overload intern_init() to initialize intern structures
00040        (e.g. number of channels), sense() and get().
00041       
00042    */
00043   class CameraSensor : public Sensor {
00044   public:  
00045 
00046     /** Creates a camera sensor. Use setInitData() to make it useable.        
00047      */ 
00048     CameraSensor();
00049 
00050     virtual ~CameraSensor();
00051 
00052     /** sets the initial data structures like the camera. 
00053         The camera will be initialized in init() (don't initialize it before).
00054         @param pose position and orientation of camera wrt. 
00055         the primitive that is given at init()
00056      */ 
00057     virtual void setInitData(Camera* camera, const OdeHandle& odeHandle, 
00058                              const OsgHandle& osgHandle, const osg::Matrix& pose);
00059 
00060     /// changes the relative pose of the camera
00061     virtual void setPose(const osg::Matrix& pose);
00062 
00063     /// relative pose of the camera
00064     virtual osg::Matrix getPose();
00065 
00066     /// this function initialized the camera (no need to overload) (Sensor interface)
00067     virtual void init(Primitive* own);
00068 
00069     /// overload this function an process the image (use camera->getImage())
00070     virtual bool sense(const GlobalData& globaldata) = 0;
00071 
00072     /// overload this function and return the number of sensor values
00073     virtual int getSensorNumber() const = 0;
00074 
00075     /// overload this function and return the sensor values
00076     virtual int get(sensor* sensors, int length) const = 0;
00077     
00078     /// we update the camera's visual appearance
00079     virtual void update();
00080 
00081     /// this is implemented based on get(sensor*,int)
00082     virtual std::list<sensor> get() const;
00083 
00084   protected:
00085     /** overload this function to initialized you data structures.
00086         Use camera->getImage() to get the image from the camera
00087     */
00088     virtual void intern_init() = 0;
00089 
00090 
00091     Camera* camera;    
00092     OdeHandle odeHandle;
00093     OsgHandle osgHandle;
00094     osg::Matrix pose;
00095     bool isInitDataSet;
00096   };  
00097 
00098 }
00099 
00100 #endif
Generated on Thu Jun 28 14:45:36 2012 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.6.3