Robot Simulator of the Robotics Group for Self-Organization of Control: twowheeled.h Source File

# twowheeled.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 __TWO_WHEELED__
    00025 #define __TWO_WHEELED__
    00026
    00027 #include <ode_robots/nimm2.h>
    00028 #include <ode_robots/camera.h>
    00029 #include <ode_robots/camerasensor.h>
    00030 #include <ode_robots/imageprocessors.h>
    00031 #include <ode_robots/sensor.h>
    00032
    00033 namespace lpzrobots {
    00034
    00035   typedef struct {
    00036     Nimm2Conf n2cfg;   ///< configuration for underlying nimm2 robot
    00037     CameraConf camcfg; ///< camera config. Allows to change the image processing
    00038     bool useCamera;    ///< whether to use the camera
    00039     osg::Matrix camPos; ///< relative pose of the camera
    00040     /** camera sensor (converts image to sensor data)
    00041         (if NULL then DirectCameraSensor() is used) */
    00042     CameraSensor* camSensor;
    00043     /// list of sensors that are mounted at the robot. (e.g.\ AxisOrientationSensor)
    00044     std::list<Sensor*> sensors;
    00045     /// adds a sensor to the list of sensors
    00046     void addSensor(Sensor* s) { sensors.push_back(s); }
    00047   } TwoWheeledConf;
    00048
    00049   /** Robot is based on nimm2 with
    00050       a camera installed
    00051   */
    00052   class TwoWheeled : public Nimm2{
    00053   public:
    00054
    00055     /**
    00056      * constructor of twowheeled robot
    00057      * @param odeHandle data structure for accessing ODE
    00058      * @param osgHandle ata structure for accessing OSG
    00059      * @param conf configuration structure
    00060      * @param name name of the robot
    00061      */
    00062     TwoWheeled(const OdeHandle& odeHandle, const OsgHandle& osgHandle,
    00063                TwoWheeledConf conf, const std::string& name);
    00064
    00065     static TwoWheeledConf getDefaultConf(){
    00066       TwoWheeledConf conf;
    00067       conf.n2cfg = Nimm2::getDefaultConf();
    00068       conf.camcfg = Camera::getDefaultConf();
    00069       conf.camcfg.width = 256;
    00070       conf.camcfg.height = 64;
    00071       conf.camcfg.fov    =  90;
    00072       conf.camcfg.camSize = 0.08;
    00073       conf.camcfg.processors.push_back(new HSVImgProc(false,1));
    00074       // filter only Yellow color
    00075       conf.camcfg.processors.push_back(new ColorFilterImgProc(true, .5,
    00076                              HSVImgProc::Red+20, HSVImgProc::Green-20,100));
    00077       // only two sensors for left and right visual field
    00078       conf.camcfg.processors.push_back(new LineImgProc(true,20, 2));
    00079       conf.useCamera = true;
    00080       conf.camPos    = osg::Matrix::rotate(M_PI/2,0,0,1)
    00081         * osg::Matrix::translate(-0.20,0,0.40);
    00082       conf.camSensor = 0;
    00083       return conf;
    00084     }
    00085
    00086     virtual ~TwoWheeled();
    00087
    00088     virtual void update();
    00089
    00090     virtual int getSensorNumber();
    00091
    00092     virtual int getSensors(sensor* sensors, int sensornumber);
    00093
    00094     virtual void sense(GlobalData& globalData);
    00095
    00096
    00097   protected:
    00098     /** creates vehicle at desired pose
    00099         @param pose 4x4 pose matrix
    00100     */
    00101     virtual void create(const osg::Matrix& pose);
    00102
    00103     /** destroys vehicle and space
    00104      */
    00105     virtual void destroy();
    00106
    00107     TwoWheeledConf conf;
    00108     CameraSensor* camsensor;
    00109     Camera* cam;
    00110   };
    00111
    00112 }
    00113
    00114 #endif