addsensors2robotadapter.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __ADDSENSORS2ROBOTADAPTER__
00025 #define __ADDSENSORS2ROBOTADAPTER__
00026
00027 #include "oderobot.h"
00028 #include "sensor.h"
00029 #include "motor.h"
00030
00031 namespace lpzrobots {
00032
00033
00034
00035
00036
00037
00038
00039 class AddSensors2RobotAdapter : public OdeRobot {
00040 public:
00041
00042
00043
00044
00045
00046
00047
00048 AddSensors2RobotAdapter( const OdeHandle& odeHandle, const OsgHandle& osgHandle,
00049 OdeRobot* robot,
00050 const std::list<Sensor*>& sensors = std::list<Sensor*>(),
00051 const std::list<Motor*>& motors = std::list<Motor*>(),
00052 bool sensors_before_rest = false);
00053
00054 virtual ~AddSensors2RobotAdapter();
00055
00056
00057 virtual void addSensor(Sensor* sensor);
00058
00059
00060 virtual void addMotor(Motor* motor);
00061
00062 virtual void update();
00063
00064 virtual void place(const osg::Matrix& pose);
00065
00066 virtual bool collisionCallback(void *data, dGeomID o1, dGeomID o2){
00067 return robot->collisionCallback(data,o1,o2);
00068 }
00069
00070 virtual void setColor(const Color& col) {
00071 robot->setColor(col);
00072 }
00073
00074 virtual int getSensorNumber();
00075 virtual int getSensors(sensor* sensors_, int sensornumber);
00076
00077 virtual int getMotorNumber();
00078 virtual void setMotors(const motor* motors_, int motornumber);
00079
00080 virtual std::list<Sensor*> getAttachedSensors(){
00081 return sensors;
00082 }
00083
00084 void sense(GlobalData& globalData);
00085 void doInternalStuff(GlobalData& globalData);
00086
00087 virtual void notifyOnChange(const paramkey& key);
00088
00089 virtual Primitive* getMainPrimitive() const { return robot->getMainPrimitive();}
00090 virtual std::vector<Primitive*> getAllPrimitives() const {
00091 return robot->getAllPrimitives();
00092 }
00093 virtual std::vector<Primitive*>& getAllPrimitives() {
00094 return robot->getAllPrimitives();
00095 }
00096
00097 protected:
00098 OdeRobot* robot;
00099 std::list<Sensor*> sensors;
00100 std::list<Motor*> motors;
00101 bool sensors_before_rest;
00102 bool initialized;
00103 bool askedfornumber;
00104 };
00105
00106 }
00107
00108 #endif