9 #include <argos3/core/simulator/entity/composable_entity.h>
10 #include <argos3/plugins/robots/prototype/simulator/prototype_entity.h>
20 m_cExtents(0.0f, 0.0f, 0.0f),
22 m_psAnchor(nullptr) {}
32 std::string strLinkGeometry;
34 if(strLinkGeometry ==
"box") {
37 }
else if(strLinkGeometry ==
"cylinder") {
43 m_cExtents.
Set(fRadius * 2.0f, fRadius * 2.0f, fHeight);
44 }
else if(strLinkGeometry ==
"sphere") {
48 m_cExtents.
Set(fRadius * 2.0f, fRadius * 2.0f, fRadius * 2.0f);
49 }
else if(strLinkGeometry ==
"convex_hull") {
50 std::string strPoints;
51 std::vector<std::string> vecPoints;
54 m_cExtents.
Set(0.0f, 0.0f, 0.0f);
58 std::string::iterator itEraseBegin =
59 std::remove_if(std::begin(strPoints), std::end(strPoints), ::isspace);
60 strPoints.erase(itEraseBegin, std::end(strPoints));
62 Tokenize(strPoints, vecPoints,
"()");
63 for(
const std::string& str_point : vecPoints) {
64 std::istringstream(str_point) >> cPoint;
65 m_vecConvexHullPoints.push_back(cPoint);
69 m_vecConvexHullFaces = cConvexHull.
GetFaces();
84 m_psAnchor = &(cBody.AddAnchor(
GetId(), cOffsetPosition, cOffsetOrientation));
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception.
#define THROW_ARGOSEXCEPTION(message)
This macro throws an ARGoS exception with the passed message.
float Real
Collects all ARGoS code.
The namespace containing all the ARGoS related code.
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.
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
void Tokenize(const std::string &str_string, std::vector< std::string > &vec_tokens, const std::string &str_delimiters)
Tokenizes the given string according to the wanted delimiters (by default just a " ").
void GetNodeText(TConfigurationNode &t_node, T &t_buffer)
Returns the text of the passed XML node A node text is as follows:
REGISTER_STANDARD_SPACE_OPERATIONS_ON_ENTITY(CEntity)
void GetNodeAttribute(TConfigurationNode &t_node, const std::string &str_attribute, T &t_buffer)
Returns the value of a node's attribute.
Basic class for an entity that contains other entities.
CEntity & GetComponent(const std::string &str_component)
Returns the component with the passed string label.
This entity is a link to a body in the physics engine.
const std::string & GetId() const
Returns the id of this entity.
void Enable()
Enables the entity.
CComposableEntity & GetParent()
Returns this entity's parent.
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
The exception that wraps all errors in ARGoS.
const std::vector< SFace > & GetFaces() const
void Set(const Real f_x, const Real f_y, const Real f_z)
Sets the vector contents from Cartesian coordinates.
CPrototypeLinkEntity(CComposableEntity *pc_parent)
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.