ARGoS  3
A parallel, multi-engine simulator for swarm robotics
core/simulator/physics_engine/physics_engine.h
Go to the documentation of this file.
00001 
00007 #ifndef PHYSICS_ENGINE_H
00008 #define PHYSICS_ENGINE_H
00009 
00010 namespace argos {
00011    class CPhysicsEngine;
00012    class CPhysicsModel;
00013    class CEntity;
00014    class CEmbodiedEntity;
00015    class CVector3;
00016    class CRay3;
00017 }
00018 
00019 #include <map>
00020 #include <argos3/core/utility/logging/argos_log.h>
00021 #include <argos3/core/utility/configuration/base_configurable_resource.h>
00022 #include <argos3/core/utility/configuration/argos_configuration.h>
00023 #include <argos3/core/utility/datatypes/datatypes.h>
00024 #include <argos3/core/utility/plugins/factory.h>
00025 
00026 namespace argos {
00027 
00028    class CPhysicsEngine : public CBaseConfigurableResource {
00029 
00030    public:
00031 
00032       typedef std::vector<CPhysicsEngine*> TVector;
00033       typedef std::map<std::string, CPhysicsEngine*, std::less<std::string> > TMap;
00034 
00035    public:
00036 
00037       CPhysicsEngine();
00038       virtual ~CPhysicsEngine() {}
00039 
00040       virtual void Init(TConfigurationNode& t_tree);
00041       virtual void Reset() {}
00042       virtual void Destroy() {}
00043 
00044       virtual void Update() = 0;
00045 
00046       virtual bool IsPointContained(const CVector3& c_point) = 0;
00047 
00048       virtual UInt32 GetNumPhysicsEngineEntities() = 0;
00049 
00055       virtual void AddEntity(CEntity& c_entity) = 0;
00056 
00062       virtual void RemoveEntity(CEntity& c_entity) = 0;
00063 
00067       virtual bool IsEntityTransferNeeded() const  = 0;
00068 
00072       virtual void TransferEntities()  = 0;
00073 
00080       virtual CEmbodiedEntity* CheckIntersectionWithRay(Real& f_t_on_ray,
00081                                                         const CRay3& c_ray) const = 0;
00082 
00091       static Real GetSimulationClockTick();
00092 
00097       static Real GetInverseSimulationClockTick();
00098 
00108       static void SetSimulationClockTick(Real f_simulation_clock_tick);
00109 
00119       inline UInt32 GetIterations() const {
00120          return m_unIterations;
00121       }
00122 
00129       inline Real GetPhysicsClockTick() const {
00130          return m_fPhysicsClockTick;
00131       }
00132 
00137       inline const std::string& GetId() const {
00138          return m_strId;
00139       }
00140 
00145       void SetId(const std::string& str_id) {
00146          m_strId = str_id;
00147       }
00148                
00149    private:
00150 
00152       UInt32 m_unIterations;
00153 
00155       Real m_fPhysicsClockTick;
00156 
00158       std::string m_strId;
00159 
00161       static Real m_fSimulationClockTick;
00162 
00164       static Real m_fInverseSimulationClockTick;
00165 
00166    };
00167 
00168 }
00169 
00170 #define REGISTER_PHYSICS_ENGINE(CLASSNAME,          \
00171                                 LABEL,              \
00172                                 AUTHOR,             \
00173                                 VERSION,            \
00174                                 BRIEF_DESCRIPTION,  \
00175                                 LONG_DESCRIPTION,   \
00176                                 STATUS)             \
00177    REGISTER_SYMBOL(CPhysicsEngine,                  \
00178                    CLASSNAME,                       \
00179                    LABEL,                           \
00180                    AUTHOR,                          \
00181                    VERSION,                         \
00182                    BRIEF_DESCRIPTION,               \
00183                    LONG_DESCRIPTION,                \
00184                    STATUS)
00185 
00186 #endif