Robotsystem of the Robot Group Leipzig: atomcomponent.h Source File

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

- Search for |

- File List
- File Members

# atomcomponent.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 #include <osgprimitive.h>
    00027
    00028
    00029 #ifndef atomcomponent_h
    00030 #define atomcomponent_h
    00031
    00032
    00033 namespace lpzrobots
    00034 {
    00035
    00036     typedef struct
    00037     {
    00038         double core_radius;
    00039         double shell_radius;
    00040         double mass;
    00041         int max_bindings; //maximum possible number of fused atoms on this atom
    00042         double binding_energy; //the value of kinetic energy that is necessary, to fuse two AtomComponents
    00043         double min_fission_energy; //this is the minimum value of fission that has to be reached
    00044
    00045         bool leadingatom;//this value sais, that a atomcomponent is the first component a component structure, that is controlled by a robot controller;
    00046         //it only is important for the origin of an component structure
    00047
    00048
    00049     } AtomConf;
    00050
    00051
    00052 /**
    00053  * AtomComponent
    00054  *
    00055  *
    00056  */
    00057 class AtomComponent : public Component
    00058 {
    00059
    00060  public:
    00061     AtomConf atomconf;
    00062
    00063
    00064
    00065  public:
    00066
    00067     class connectionAddition
    00068     {
    00069     public:
    00070         double binding_strength;
    00071
    00072         connectionAddition ()
    00073         {
    00074         }
    00075
    00076         ~connectionAddition ()
    00077         {
    00078         }
    00079     };
    00080
    00081
    00082
    00083  private:
    00084     //only one of this two should reference to an object
    00085     OSGSphere* core;
    00086     Primitive* shell;
    00087
    00088  public:
    00089
    00090     AtomComponent ( const OdeHandle &odeHandle, const OsgHandle &osgHandle, const ComponentConf& conf, const AtomConf& aconf );
    00091
    00092     ~AtomComponent ();
    00093
    00094
    00095 static AtomConf getDefaultAtomConf()
    00096 {
    00097     AtomConf conf;
    00098
    00099     conf.core_radius = 0.05;
    00100     conf.shell_radius = 0.1;
    00101     conf.mass = 1;
    00102     conf.max_bindings = 4;
    00103     conf.binding_energy = 3;
    00104     conf.min_fission_energy = 0;
    00105     conf.leadingatom = false;
    00106
    00107     return conf;
    00108 }
    00109
    00110
    00111 /**
    00112  *Use this, to get all sensor values of all the joints of all subcomponents, and the sensors of all robots, belonging to all subcomponents.
    00113  *The sensor values have the following sequence:
    00114  *values of the component connecting joints, values of the robot of the component,
    00115  *values of component connecting joints of the first subcomponent, values of the robot of the first subcomponent, ...
    00116  *@param robot sensor values of the connecting joints of this component and all subcomponents
    00117  **/
    00118 virtual int     getSensors (sensor *sensors, int sensornumber); //returns actual sensorvalues; only for the connecting joints
    00119
    00120 /**
    00121  *Sets the motor values for the joints connecting the component with its subcomponents, an recursivly the joints of all subComponents.
    00122  *@param
    00123  **/
    00124 virtual void    setMotors (const motor *motors, int motornumber); //sets actual motorcommands; only for the connecting joints
    00125
    00126 virtual int     getSensorNumber (); //returns number of sensors; recursivly adding of the number of sensors all subcomponents and the robots of all Subcomponents.
    00127
    00128 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.
    00129
    00130 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
    00131
    00132 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
    00133 virtual void    place (const osg::Matrix &pose);//sets the pose of the vehicle; also recursive place of all subComponents; does nothing at the moment
    00134
    00135 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?
    00136
    00137 virtual bool    shellCollision ( dGeomID o1 , dGeomID o2 ); //testing function for collisions with the atom shell
    00138
    00139 virtual void    doInternalStuff (const GlobalData &globalData);// this function is called in each timestep.; maybee usefull
    00140
    00141 // virtual void         setColor (const Color &col);    sets color of the robot; not nessecary
    00142
    00143 virtual Position getPosition () const; //returns position of the object; relates to the robot or Primitive belonging to the component
    00144
    00145 //virtual Position getSpeed () const;//returns linear speed vector of the object; must be computed from all sub-robots
    00146
    00147 /**
    00148  *This is only a simple function, calculating the coordinates of the point exactly between two directly connected components.
    00149  *@return Vector containing the Position
    00150  *@param index number of the position
    00151  **/
    00152 virtual osg::Vec3 getPositionbetweenComponents ( Component* component );
    00153
    00154 /**
    00155  *@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.
    00156  **/
    00157 virtual Primitive* getMainPrimitive () const;
    00158
    00159 /**
    00160  *Searches for the softlink in the substructure of THIS component which has the highest binding strength.
    00161  *@return the softlink connection within the substructure of THIS component.
    00162  **/
    00163 virtual componentConnection* getStrongestSoftlinkofStructure ();
    00164
    00165 /**
    00166  *This changes the structure of all components connected with this component, so that this component will become the new root of this structure.
    00167  **/
    00168 virtual void makeComponentStructureRoot();
    00169
    00170
    00171 /**
    00172  *Calculates the linear force the Component has at the time of calling this function
    00173  *@return force (mass*linear velocity)
    00174  **/
    00175 virtual double getMotionForce ();
    00176
    00177 /**
    00178  *Calculates the linear force between two components at the moment of calling this function.
    00179  *@return force (masses*linear velocity of both atoms)
    00180  **/
    00181 virtual double getCollisionForce ( AtomComponent* collAtom );
    00182
    00183 /**
    00184  *Tests if the conditions for fusion of two atoms are fulfilled.
    00185  *@param Geom reference to the first atom
    00186  *@param Geom reference to the second atom
    00187  *@return true if fulfilled false if not
    00188  **/
    00189 virtual bool fusionCondition ( dGeomID o1 , dGeomID o2 );
    00190
    00191 /**
    00192  *Tests if the conditions for fission of two atoms are fulfilled.
    00193  *@param Geom reference to the first atom
    00194  *@param Geom reference to the second atom
    00195  *@return true if fulfilled false if not
    00196  **/
    00197 virtual bool fissionCondition ( dGeomID o1 , dGeomID o2 , double force );
    00198
    00199 /**
    00200  *Test which collisions should not be handled.
    00201  *@param Geom reference to the first atom
    00202  *@param Geom reference to the second atom
    00203  *@return true if fulfilled false if not
    00204  **/
    00205 virtual bool collisionExclusionCondition ( dGeomID o1 , dGeomID o2 );
    00206
    00207 /**
    00208  *fuses this AtomComponent with an other one
    00209  *@param the AtomComponent, to fuse with
    00210  *@retuen true if the fusion was successfull, false if not
    00211  **/
    00212 virtual bool fusion ( AtomComponent* atom_to_fuse );
    00213
    00214 /**
    00215  *fissions a AtomComponent from this AtomComponent
    00216  *@param the AtomComponent, to fission
    00217  *@retuen true if the fission was successfull, false if not
    00218  **/
    00219 virtual bool fission ( double force );
    00220
    00221 /**
    00222  *This is a special fusion of two AtomComponents. They have to belong to two robots, so that touching each ofer causes a crossing over in her structure.
    00223  *@param the AtomComponent which belongs to the structure to replicate with, and which is the point where the replication will happen
    00224  **/
    00225 virtual void replication ( AtomComponent* atom_to_recplicate );
    00226
    00227 };
    00228
    00229
    00230
    00231 }
    00232 #endif