ARGoS
3
A parallel, multi-engine simulator for swarm robotics
|
Go to the documentation of this file.
9 #include <argos3/core/utility/logging/argos_log.h>
10 #include <argos3/core/utility/math/vector3.h>
11 #include <argos3/core/utility/string_utilities.h>
12 #include <argos3/core/simulator/simulator.h>
13 #include <argos3/core/simulator/space/space.h>
14 #include <argos3/core/simulator/entity/entity.h>
30 for(
size_t i = 0; i < vecEngines.size(); ++i)
31 vecEngines[i]->CheckIntersectionWithRay(t_data, c_ray);
35 return !t_data.empty();
50 for(
size_t i = 0; i < tData.size(); ++i) {
51 if(s_item.
TOnRay > tData[i].TOnRay)
71 for(
size_t i = 0; i < tData.size(); ++i) {
72 if(s_item.
TOnRay > tData[i].TOnRay &&
73 &c_entity != tData[i].IntersectedEntity) {
85 Real CPhysicsEngine::m_fSimulationClockTick = 0.1f;
86 Real CPhysicsEngine::m_fInverseSimulationClockTick = 1.0f / CPhysicsEngine::m_fSimulationClockTick;
115 CVector2 cFirstPoint, cLastPoint, cCurPoint;
116 std::string strConnectWith;
120 tVertexIt = tVertexIt.begin(&tNode);
121 if(tVertexIt == tVertexIt.end()) {
125 cLastPoint = cFirstPoint;
128 while(tVertexIt != tVertexIt.end()) {
134 SideFaces.push_back(psFace);
136 cLastPoint = cCurPoint;
140 if(SideFaces.size() < 3) {
143 if(cLastPoint != cFirstPoint) {
147 SideFaces.push_back(psFace);
160 if(TopFace)
delete TopFace;
161 if(BottomFace)
delete BottomFace;
162 while(!SideFaces.empty()) {
163 delete SideFaces.back();
164 SideFaces.pop_back();
172 return TopFace || BottomFace || (!SideFaces.empty());
180 m_fPhysicsClockTick(m_fSimulationClockTick) {}
192 LOG <<
"[INFO] The physics engine \""
194 <<
"\" will perform "
196 <<
" iterations per tick (dt = "
235 if(fCriterion < 0.0f) {
247 m_vecTransferData.push_back(&c_entity);
254 for(
size_t i = 0; i < m_vecTransferData.size(); ++i) {
258 m_vecTransferData.clear();
265 return m_fSimulationClockTick;
272 return m_fInverseSimulationClockTick;
279 LOG <<
"[INFO] Using simulation clock tick = " << f_simulation_clock_tick << std::endl;
280 m_fSimulationClockTick = f_simulation_clock_tick;
281 m_fInverseSimulationClockTick = 1.0f / f_simulation_clock_tick;
Real GetZ() const
Returns the z coordinate of this vector.
const std::string & GetId() const
Returns the id of this physics engine.
static CSimulator & GetInstance()
Returns the instance to the CSimulator class.
virtual void TransferEntities()
Executes the transfer of entities to other engines.
CARGoSLog LOG(std::cout, SLogColor(ARGOS_LOG_ATTRIBUTE_BRIGHT, ARGOS_LOG_COLOR_GREEN))
The namespace containing all the ARGoS related code.
static void SetSimulationClockTick(Real f_simulation_clock_tick)
Sets the simulation clock tick.
std::vector< SVerticalFace * > SideFaces
TConfigurationNode & GetNode(TConfigurationNode &t_node, const std::string &str_tag)
Given a tree root node, returns the first of its child nodes with the wanted name.
The exception that wraps all errors in ARGoS.
This entity is a link to a body in the physics engine.
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
Real GetY() const
Returns the y coordinate of this vector.
CSpace & GetSpace() const
Returns a reference to the simulated space.
Real GetX() const
Returns the x coordinate of this vector.
bool GetClosestEmbodiedEntityIntersectedByRay(SEmbodiedEntityIntersectionItem &s_item, const CRay3 &c_ray)
Returns the closest intersection with an embodied entity to the ray start.
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception.
virtual bool RemoveEntity(CEntity &c_entity)=0
Removes an entity from the physics engine.
bool GetEmbodiedEntitiesIntersectedByRay(TEmbodiedEntityIntersectionData &t_data, const CRay3 &c_ray)
Checks whether the given ray intersects any entity.
ticpp::Iterator< ticpp::Element > TConfigurationNodeIterator
The iterator for the ARGoS configuration XML node.
#define THROW_ARGOSEXCEPTION(message)
This macro throws an ARGoS exception with the passed message.
void SetStart(const CVector2 &c_start)
CEmbodiedEntity * IntersectedEntity
CPhysicsEngine::TVector & GetPhysicsEngines()
Returns the list of currently existing physics engines.
Real GetX() const
Returns the x coordinate of this vector.
virtual void ScheduleEntityForTransfer(CEmbodiedEntity &c_entity)
Schedules an entity of transfer.
bool NodeExists(TConfigurationNode &t_node, const std::string &str_tag)
Given a tree root node, returns true if one of its child nodes has the wanted name.
void Init(TConfigurationNode &t_node)
A boundary face for side parts of the volume.
bool IsEntityTransferActive() const
Returns true if entity transfer is active for this engine.
Real GetPhysicsClockTick() const
Returns the length of the physics engine tick.
SVolume & GetVolume()
Returns the boundary faces for the volume associated to this engine.
SHorizontalFace * TopFace
SHorizontalFace * BottomFace
void GetNodeAttributeOrDefault(TConfigurationNode &t_node, const std::string &str_attribute, T &t_buffer, const T &t_default)
Returns the value of a node's attribute, or the passed default value.
virtual bool IsPointContained(const CVector3 &c_point)
Returns true if the given point is contained in this physics engine.
static Real GetSimulationClockTick()
Returns the simulation clock tick.
virtual void Init(TConfigurationNode &t_tree)
Initializes the resource.
A boundary face for top/bottom parts of the volume.
void GetNodeAttribute(TConfigurationNode &t_node, const std::string &str_attribute, T &t_buffer)
Returns the value of a node's attribute.
std::vector< CPhysicsEngine * > TVector
static Real GetInverseSimulationClockTick()
Returns the inverse of GetSimulationClockTick().
virtual void AddEntityToPhysicsEngine(CEmbodiedEntity &c_entity)
Real GetY() const
Returns the y coordinate of this vector.
std::vector< SEmbodiedEntityIntersectionItem > TEmbodiedEntityIntersectionData
float Real
Collects all ARGoS code.
void SetEnd(const CVector2 &c_end)