robotcomponent.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 * marcel@informatik.uni-leipzig.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 00025 #include "component.h" 00026 00027 #ifndef robotcomponent_h 00028 #define robotcomponent_h 00029 00030 00031 namespace lpzrobots 00032 { 00033 /** 00034 * This is a special class of the component system. The physical object that belongs to objects of this class is a robot whose class is derived from OdeRobot. 00035 * The sensor an motor values these component sends and gets could be used to controll the robot that belongs to this component. 00036 * If this controling method should be used there are two controling parameters that tell the component, how to handle its sensor/motor values. 00037 * These are the params completemotormode and complete sensormode of the componentConf. These two parameters control if the sensor/motor values will eb send to the robot of the component or not. If thei are not sent to the robot the robot needs its own controller. 00038 */ 00039 class RobotComponent : public Component 00040 { 00041 00042 private: 00043 00044 OdeRobot* robot; 00045 00046 public: 00047 00048 RobotComponent ( const OdeHandle &odeHandle, const OsgHandle &osgHandle, const ComponentConf& conf); 00049 00050 ~RobotComponent (); 00051 00052 public: 00053 00054 /** 00055 *Use this, to get all sensor values of all the joints of all subcomponents, and the sensors of all robots, belonging to all subcompionents. 00056 *The sensor values have the following sequence: 00057 *values of the component connecting joints, values of the robot of the component, 00058 *values of component connecting joints of the first subcomponent, values of the robot of the first subcomponent, ... 00059 *@robot sensor values of the connecting joints of this component and all subcomponents 00060 **/ 00061 virtual int getSensors (sensor *sensors, int sensornumber); //returns actual sensorvalues; only for the connecting joints 00062 00063 /** 00064 *Sets the motor values for the joints connecting the component with its subcomponents, an recursivly the joints of all subComponents. 00065 *The motors of all robots of the subcomponents is not set. 00066 *@param 00067 **/ 00068 virtual void setMotors (const motor *motors, int motornumber); //sets actual motorcommands; only for the connecting joints 00069 00070 virtual int getSensorNumber (); //returns number of sensors; recursivly adding of the number of sensors all subcomponents and the robots of all Subcomponents. 00071 00072 virtual int getMotorNumber (); //returns number of motors; recursivly adding of the number of sensors all subcomponents; at the moment only counts Hinge-, Slider-, Hinge2 and Universal-Joints; The Motor-Numbers of the robots of the Components is not counted. 00073 00074 virtual void update ();//update the OSG notes here; update of the underlying robot or Primitive and recursive update of all Components in the Connection-vector 00075 00076 virtual void place (const Pos &pos);//sets the vehicle to position pos - desired position of the robot; the first component is seen as center of the robot, on which the position pos refers; also recursive place of all subComponents 00077 virtual void place (const osg::Matrix &pose);//sets the pose of the vehicle; also recursive place of all subComponents; does nothing at the moment 00078 00079 virtual bool collisionCallback (void *data, dGeomID o1, dGeomID o2);// checks for internal collisions and treats them.; should do nothing, because there should not be any ode-objects belonging to the component, which are not handled elsewhere....and what is with Primitives? are they automaticaly handled? 00080 00081 virtual void doInternalStuff (const GlobalData &globalData);// this function is called in each timestep.; maybee usefull 00082 00083 // virtual void setColor (const Color &col); sets color of the robot; not nessecary 00084 00085 virtual Position getPosition () const; //returns position of the object; relates to the robot or Primitive belonging to the component 00086 00087 //virtual Position getSpeed () const;//returns linear speed vector of the object; must be computed from all sub-robots 00088 00089 //virtual matrix::Matrix getOrientation () const;//returns the orientation of the object; 00090 00091 00092 /** 00093 *This is only a simple function, calculating the coordinates of the point exactly between two directly connected components. 00094 *@return Vector containing the Position 00095 *@param index number of the position 00096 **/ 00097 virtual osg::Vec3 getPositionbetweenComponents ( Component* component ); 00098 00099 /** 00100 *Sets the reference to the robot for the component, but only if there is no Primitive assigned to the component. 00101 *Overwriting an existing robot reference is possible, also to set it NULL, and then set a reference to a Primitive with setSimplePrimitive ( .. ). 00102 *But first the robot reference should be saved elsewhere or it won't be updated graficaly 00103 *return true if the reference could be set; false else 00104 **/ 00105 virtual bool setRobot ( OdeRobot* newrobot ); 00106 00107 /** 00108 *returns a reference to the robot belonging to the component, if there is no robot it is an NULL pointer, then try getMeinPrimitive, because there is only a solid Primitive not a complex robot for this component 00109 *@return the robot asigned to the component 00110 **/ 00111 virtual OdeRobot* getRobot (); // 00112 00113 /** 00114 *return reference to the simple Primitive, or to the main Primitive of the robot assigend to the component. If nothimng is assigned, NULL is returned. 00115 **/ 00116 virtual Primitive* getMainPrimitive () const; 00117 00118 }; 00119 00120 00121 } 00122 #endif

Generated on Tue Jan 16 02:14:37 2007 for Robotsystem of the Robot Group Leipzig by doxygen 1.3.8