twowheeled.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Robot Group Leipzig                             *
00003  *    martius@informatik.uni-leipzig.de                                    *
00004  *    fhesse@informatik.uni-leipzig.de                                     *
00005  *    der@informatik.uni-leipzig.de                                        *
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  *                                                                         *
00012  *   This program is distributed in the hope that it will be useful,       *
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00015  *   GNU General Public License for more details.                          *
00016  *                                                                         *
00017  *   You should have received a copy of the GNU General Public License     *
00018  *   along with this program; if not, write to the                         *
00019  *   Free Software Foundation, Inc.,                                       *
00020  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00021  *                                                                         *
00022  *  A robot with 2 wheels (like nimm2) but with and a camera               *
00023  *   and possibly other sensors                                            *
00024  ***************************************************************************/
00025 #ifndef __TWO_WHEELED__
00026 #define __TWO_WHEELED__
00027 
00028 #include <ode_robots/nimm2.h>
00029 #include <ode_robots/camera.h>
00030 #include <ode_robots/camerasensor.h>
00031 #include <ode_robots/imageprocessors.h>
00032 #include <ode_robots/sensor.h>
00033 
00034 namespace lpzrobots {
00035 
00036   typedef struct {
00037     Nimm2Conf n2cfg;   ///< configuration for underlying nimm2 robot    
00038     CameraConf camcfg; ///< camera config. Allows to change the image processing
00039     bool useCamera;    ///< whether to use the camera
00040     osg::Matrix camPos; ///< relative pose of the camera
00041     /** camera sensor (converts image to sensor data) 
00042         (if NULL then DirectCameraSensor() is used) */
00043     CameraSensor* camSensor; 
00044     /// list of sensors that are mounted at the robot. (e.g.\ AxisOrientationSensor)
00045     std::list<Sensor*> sensors; 
00046     /// adds a sensor to the list of sensors
00047     void addSensor(Sensor* s) { sensors.push_back(s); }        
00048   } TwoWheeledConf;
00049   
00050   /** Robot is based on nimm2 with 
00051       a camera installed
00052   */
00053   class TwoWheeled : public Nimm2{
00054   public:
00055   
00056     /**
00057      * constructor of twowheeled robot
00058      * @param odeHandle data structure for accessing ODE
00059      * @param osgHandle ata structure for accessing OSG
00060      * @param conf configuration structure
00061      * @param name name of the robot
00062      */
00063     TwoWheeled(const OdeHandle& odeHandle, const OsgHandle& osgHandle, 
00064                TwoWheeledConf conf, const std::string& name);
00065 
00066     static TwoWheeledConf getDefaultConf(){
00067       TwoWheeledConf conf;
00068       conf.n2cfg = Nimm2::getDefaultConf();
00069       conf.camcfg = Camera::getDefaultConf();
00070       conf.camcfg.width = 256;
00071       conf.camcfg.height = 64;
00072       conf.camcfg.fov    =  90;
00073       conf.camcfg.camSize = 0.08;
00074       conf.camcfg.processors.push_back(new HSVImgProc(false,1));
00075       // filter only Yellow color
00076       conf.camcfg.processors.push_back(new ColorFilterImgProc(true, .5, 
00077                              HSVImgProc::Red+20, HSVImgProc::Green-20,100));
00078       // only two sensors for left and right visual field
00079       conf.camcfg.processors.push_back(new LineImgProc(true,20, 2));    
00080       conf.useCamera = true;
00081       conf.camPos    = osg::Matrix::rotate(M_PI/2,0,0,1) 
00082         * osg::Matrix::translate(-0.20,0,0.40);
00083       conf.camSensor = 0;      
00084       return conf;
00085     }
00086 
00087     virtual ~TwoWheeled();
00088 
00089     virtual void update();
00090 
00091     virtual int getSensorNumber();
00092 
00093     virtual int getSensors(sensor* sensors, int sensornumber);
00094 
00095     virtual void sense(GlobalData& globalData);
00096 
00097 
00098   protected:
00099     /** creates vehicle at desired pose
00100         @param pose 4x4 pose matrix
00101     */
00102     virtual void create(const osg::Matrix& pose); 
00103 
00104     /** destroys vehicle and space
00105      */
00106     virtual void destroy();
00107 
00108     TwoWheeledConf conf;
00109     CameraSensor* camsensor;
00110     Camera* cam;
00111   };
00112 
00113 }
00114 
00115 #endif
Generated on Fri Nov 4 10:59:39 2011 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.6.3