Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# Tools/PotentialFields/FieldObject.h

Go to the documentation of this file.

    00001 /**
    00002 * @file FieldObject.h
    00003 *
    00004 * Definition of class PotentialFieldsObject
    00005 *
    00006 * @author <a href="mailto:timlaue@informatik.uni-bremen.de">Tim Laue</a>
    00007 */
    00008
    00009 #ifndef OBJECT_H_
    00010 #define OBJECT_H_
    00011
    00012 #include "PotentialFunctions.h"
    00013 #include "PfieldDatatypes.h"
    00014 #include "PfieldGeometry.h"
    00015 #include <string>
    00016
    00017 class PotentialfieldComposition;
    00018
    00019
    00020 /** The possible types of tangential fields*/
    00021 enum TangentialField {NO_TANGENTIALFIELD, CLOCKWISE, COUNTER_CLOCKWISE};
    00022
    00023
    00024 /**
    00025 * @class PotentialFieldsObject
    00026 *
    00027 * A class representing an object in a potential field
    00028 */
    00029 class PotentialFieldsObject
    00030 {
    00031 public:
    00032   /** Constructor */
    00033   PotentialFieldsObject();
    00034
    00035   /** Constructor
    00036   * @param name The name of the object
    00037   * @param objectType The type of the object
    00038   */
    00039   PotentialFieldsObject(const std::string& name, ObjectType objectType);
    00040
    00041   /** Destructor */
    00042   virtual ~PotentialFieldsObject();
    00043
    00044   /** Computes the impact of an object at a given pose
    00045   * @param otherPose The pose
    00046   * @return The charge (= f(otherPose))
    00047   */
    00048   virtual double computeChargeAt(const PfPose& otherPose);
    00049
    00050   /** Computes the gradient of an object at a given pose
    00051   * @param otherPose The pose
    00052   * @return The gradient (= f'(otherPose))
    00053   */
    00054   virtual PfVec computeAbsFieldVecAt(const PfPose& otherPose);
    00055
    00056   /** Creates a copy of this object and changes the name of the copied object
    00057   * @param instanceName The name of the copy
    00058   * @return The copy
    00059   */
    00060   PotentialFieldsObject* createInstance(const std::string& instanceName);
    00061
    00062   /** Copy operator
    00063   * @param other The object to copy
    00064   */
    00065   void operator = (const PotentialFieldsObject& other);
    00066
    00067   /** Polymorph copy function
    00068   * @return A copy of the object
    00069   */
    00070   virtual PotentialFieldsObject* getCopy();
    00071
    00072   /** Get new data from other object. It is assumed that a full copy had been done
    00073   *   before. Only changing data (e.g. the pose) is copied.
    00074   * @param other The object to get the data from
    00075   */
    00076   void getMinimalCopyFrom(PotentialFieldsObject* other);
    00077
    00078   /** Returns the name of the object
    00079   * @return The name
    00080   */
    00081   std::string getName() const
    00082   { return name;}
    00083
    00084   /** Returns the pose of the object
    00085   * @return The pose
    00086   */
    00087   PfPose getPose() const
    00088   { return pose;}
    00089
    00090   /** Returns the pose of the object in reference to the robot pose
    00091   *   (used for getting a pose from formation objects)
    00092   * @param robotPose The robot pose
    00093   * @return The object pose
    00094   */
    00095   virtual PfPose getPose(const PfPose& robotPose)
    00096   { return pose;}
    00097
    00098   /** Sets the pose of the object and updates the absolute geometry
    00099   * @param pose The new pose
    00100   */
    00101   void setPose(const PfPose& pose);
    00102
    00103   /** Sets the state of the object
    00104   * @param active Flag which determines whether the object is active or not
    00105   */
    00106   void setActivation(const bool& active)
    00107   { this->active = active;}
    00108
    00109   /** Returns whether the object is active or not
    00110   * @return true, if active
    00111   */
    00112   virtual bool isActive() const
    00113   { return active;}
    00114
    00115   /** Returns the type of the object
    00116   * @return The type
    00117   */
    00118   ObjectType getType() const
    00119   { return objectType;}
    00120
    00121   /** Sets the static/dynamic state of the object
    00122   * @param isStatic Flag
    00123   * @param dynamicPoseId The id of the static pose
    00124   */
    00125   void setStatic(const bool& isStatic, unsigned int dynamicPoseId=0)
    00126   {
    00127     this->isStaticVar = isStatic;
    00128     this->dynamicPoseId = dynamicPoseId;
    00129   }
    00130
    00131   /** Return whether the object is static or not
    00132   * @return true, if the object is static
    00133   */
    00134   virtual bool isStatic() const
    00135   { return isStaticVar;}
    00136
    00137   /** Sets the function of the object
    00138   * @param function The function
    00139   */
    00140   void setFunction(PotentialfieldFunction* function);
    00141
    00142   /** Sets the field type of the object
    00143   * @param type The field type
    00144   */
    00145   void setField(FieldType type);
    00146
    00147   /** Sets the field type of the object
    00148   * @param type The field type
    00149   * @param sector A sector description (if type == SECTOR_FIELD)
    00150   */
    00151   void setField(FieldType type, const Sector& sector);
    00152
    00153   /** Sets the type of the tangential field
    00154   * @param tangentialField The type of the tangential field
    00155   */
    00156   void setTangentialField(TangentialField tangentialField)
    00157   { this->tangentialField = tangentialField;}
    00158
    00159   /** Sets the geometry of the object
    00160   * @param geometry The geometric description
    00161   */
    00162   void setGeometry(PfieldGeometricObject* geometry);
    00163
    00164   /** Returns a pointer to the geometry of the object
    00165   * @return The geometric description
    00166   */
    00167   virtual PfieldGeometricObject* getGeometry() const
    00168   { return geometry;}
    00169
    00170   /** Returns a pointer to the absolute geometry of the object
    00171   * @return The geometric description
    00172   */
    00173   virtual PfieldGeometricObject* getAbsGeometry() const
    00174   { return absGeometry;}
    00175
    00176   /** Sets the reference to the PotentialfieldComposition
    00177   * @param ref The reference
    00178   */
    00179   void setPfieldCompositionRef(PotentialfieldComposition* ref)
    00180   { this->refToPfieldComposition = ref;}
    00181
    00182   /** Gets new data (pose/activation), if dynamic*/
    00183   virtual void updateData();
    00184
    00185   /** Computes the absolute geometry*/
    00186   void computeAbsGeometry();
    00187
    00188 protected:
    00189   /** The pose of the object*/
    00190   PfPose pose;
    00191   /** The name of the object*/
    00192   std::string name;
    00193   /** Flag, determines if object is active*/
    00194   bool active;
    00195   /** Flag, determines if object is static/dynamic*/
    00196   bool isStaticVar;
    00197   /** Flag, determines, if the field has a tangential direction*/
    00198   TangentialField tangentialField;
    00199   /** The type of the potential field*/
    00200   FieldType fieldType;
    00201   /** The function of this object*/
    00202   PotentialfieldFunction* function;
    00203   /** The type of the object (attractive/repulsive)*/
    00204   ObjectType objectType;
    00205   /** The description of the object's geometry*/
    00206   PfieldGeometricObject* geometry;
    00207   /** The description of the object's geometry in absolute coordinates*/
    00208   PfieldGeometricObject* absGeometry;
    00209   /** The sector of the potential field (if fieldType==SECTOR_FIELD)*/
    00210   Sector sector;
    00211   /** A pointer to the PotentialfieldComposition*/
    00212   PotentialfieldComposition* refToPfieldComposition;
    00213   /** The id of the dynamic pose (if used)*/
    00214   unsigned int dynamicPoseId;
    00215
    00216   /** Computes the charge at a pose
    00217   * @param objectPose The pose of an object
    00218   * @param position A position influenced by the object
    00219   * @return The charge
    00220   */
    00221   double computeChargeForSinglePose(const PfPose& objectPose, const PfPose& position) const;
    00222
    00223   /** Computes the gradient at a pose
    00224   * @param objectPose The pose of an object
    00225   * @param position A position influenced by the object
    00226   * @return The gradient vector
    00227   */
    00228   PfVec computeGradientVecForSinglePose(const PfPose& objectPose, const PfPose& position) const;
    00229 };
    00230
    00231
    00232 #endif  //OBJECT_H_