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

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages
- Examples

- Search for |

- File List
- File Members

# addsensors2robotadapter.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  *   This is an adapter class to add sensors to existing robots            *
    00023  *    without modifiing them.                                              *
    00024  *                                                                         *
    00025  *   $Log: addsensors2robotadapter.h,v $
    00026  *   Revision 1.4  2009/10/09 17:17:19  martius
    00027  *   This does not work with configurables and inspectable robots
    00028  *   comments added.
    00029  *
    00030  *   Revision 1.3  2008/05/07 16:45:51  martius
    00031  *   code cosmetics and documentation
    00032  *
    00033  *   Revision 1.2  2007/11/07 13:20:25  martius
    00034  *   also motors can be added
    00035  *
    00036  *   Revision 1.1  2007/08/24 11:48:56  martius
    00037  *   initial
    00038  *
    00039  *                                                                 *
    00040  ***************************************************************************/
    00041 #ifndef __ADDSENSORS2ROBOTADAPTER__
    00042 #define __ADDSENSORS2ROBOTADAPTER__
    00043
    00044 #include "oderobot.h"
    00045 #include "sensor.h"
    00046 #include "motor.h"
    00047
    00048 namespace lpzrobots {
    00049
    00050   /** Robot adapter to add sensors and also motors to robots without the
    00051       need to modify the robot itself.
    00052       Examples are Speed sensors, microphons and beepers and so forth
    00053       // TODO: add inspectable, make configurable work!
    00054       // Maybe it is easier to add this into OdeRobot itself!
    00055   */
    00056   class AddSensors2RobotAdapter : public OdeRobot {
    00057   public:
    00058
    00059     /**
    00060      * constructor of adapter
    00061      * @param robot robot the wrap and plug sensors in
    00062      * @param sensors list of sensors to add
    00063      * @param motors list of motors to add
    00064      */
    00065     AddSensors2RobotAdapter( const OdeHandle& odeHandle, const OsgHandle& osgHandle,
    00066                              OdeRobot* robot,
    00067                              const std::list<Sensor*>& sensors = std::list<Sensor*>(),
    00068                              const std::list<Motor*>& motors  = std::list<Motor*>(),
    00069                              bool sensors_before_rest = false);
    00070
    00071     virtual ~AddSensors2RobotAdapter();
    00072
    00073     /// adds a sensor to the robot. Must be called before placement of the robot, otherwise it has no affect
    00074     virtual void addSensor(Sensor* sensor);
    00075
    00076     /// adds a motor to the robot. Must be called before placement of the robot, otherwise it has no affect
    00077     virtual void addMotor(Motor* motor);
    00078
    00079     virtual void update(){ robot->update(); }
    00080
    00081     virtual void place(const osg::Matrix& pose);
    00082
    00083     virtual bool collisionCallback(void *data, dGeomID o1, dGeomID o2){
    00084       return robot->collisionCallback(data,o1,o2);
    00085     }
    00086
    00087     virtual int getSensorNumber();
    00088     virtual int getSensors(sensor* sensors_, int sensornumber);
    00089
    00090     virtual int getMotorNumber();
    00091     virtual void setMotors(const motor* motors_, int motornumber);
    00092
    00093     void doInternalStuff(GlobalData& globalData);
    00094
    00095     virtual Primitive* getMainPrimitive() const { return robot->getMainPrimitive();}
    00096
    00097   protected:
    00098     OdeRobot* robot;
    00099     std::list<Sensor*> sensors;
    00100     std::list<Motor*> motors;
    00101     bool sensors_before_rest;
    00102   };
    00103
    00104 }
    00105
    00106 #endif