8 #include <argos3/core/utility/math/matrix/rotationmatrix3.h>
9 #include <argos3/core/simulator/space/space.h>
10 #include <argos3/core/simulator/simulator.h>
11 #include <argos3/plugins/simulator/media/led_medium.h>
12 #include <argos3/plugins/simulator/physics_engines/physics_cylinder_model.h>
21 m_pcEmbodiedEntity(nullptr),
22 m_pcLEDEquippedEntity(nullptr),
24 m_pcLEDMedium(nullptr) {
44 m_pcLEDEquippedEntity(
86 m_pcLEDEquippedEntity->
Init(
GetNode(t_tree,
"leds"));
88 std::string strMedium;
91 m_pcLEDEquippedEntity->
SetMedium(*m_pcLEDMedium);
92 m_pcLEDEquippedEntity->
Enable();
106 m_pcEmbodiedEntity->
Reset();
107 m_pcLEDEquippedEntity->
Reset();
116 m_pcLEDMedium = &c_medium;
117 m_pcLEDEquippedEntity->
SetMedium(*m_pcLEDMedium);
118 m_pcLEDEquippedEntity->
Enable();
125 m_pcLEDEquippedEntity->
Disable();
133 m_pcLEDEquippedEntity->
AddLED(c_offset,
144 m_fRadius = f_radius;
145 m_fHeight = f_height;
159 "Carlo Pinciroli [ilpincy@gmail.com]",
161 "A stretchable cylinder.",
162 "The cylinder entity can be used to model obstacles or cylinder-shaped\n"
163 "grippable objects. The cylinder has a red LED on the center of one\n"
164 "of the circular surfaces, that allows perception using the cameras.\n"
165 "The cylinder can be movable or not. A movable object can be pushed\n"
166 "and gripped. An unmovable object is pretty much like a column.\n\n"
167 "REQUIRED XML CONFIGURATION\n\n"
168 "To declare an unmovable object (i.e., a column) you need the following:\n\n"
171 " <cylinder id=\"cyl1\" radius=\"0.8\" height=\"0.5\" movable=\"false\">\n"
172 " <body position=\"0.4,2.3,0\" orientation=\"45,0,0\" />\n"
176 "To declare a movable object you need the following:\n\n"
179 " <cylinder id=\"cyl1\" radius=\"0.8\" height=\"0.5\"\n"
180 " movable=\"true\" mass=\"2.5\">\n"
181 " <body position=\"0.4,2.3,0\" orientation=\"45,0,0\" />\n"
185 "The 'id' attribute is necessary and must be unique among the entities. If two\n"
186 "entities share the same id, initialization aborts.\n"
187 "The 'radius' and 'height' attributes specify the size of the cylinder. When\n"
188 "you add a cylinder, imagine it initially unrotated and centered in the origin.\n"
189 "The base of the cylinder, then, is parallel to the XY plane and its height\n"
190 "goes with the Z axis.\n"
191 "The 'movable' attribute specifies whether or not the object is movable. When\n"
192 "set to 'false', the object is unmovable: if another object pushes against it,\n"
193 "the cylinder won't move. When the attribute is set to 'true', the cylinder is\n"
194 "movable upon pushing or gripping. When an object is movable, the 'mass'\n"
195 "attribute is required.\n"
196 "The 'mass' attribute quantifies the mass of the cylinder in kg.\n"
197 "The 'body/position' attribute specifies the position of the base of the\n"
198 "cylinder in the arena. The three values are in the X,Y,Z order.\n"
199 "The 'body/orientation' attribute specifies the orientation of the cylinder. All\n"
200 "rotations are performed with respect to the center of mass. The order of the\n"
201 "angles is Z,Y,X, which means that the first number corresponds to the rotation\n"
202 "around the Z axis, the second around Y and the last around X. This reflects\n"
203 "the internal convention used in ARGoS, in which rotations are performed in\n"
204 "that order. Angles are expressed in degrees.\n\n"
205 "OPTIONAL XML CONFIGURATION\n\n"
206 "It is possible to add any number of colored LEDs to the cylinder. In this way,\n"
207 "the cylinder is visible with a robot camera. The position and color of the\n"
208 "LEDs is specified with the following syntax:\n\n"
211 " <cylinder id=\"cyl1\" radius=\"0.8\" height=\"0.5\"\n"
212 " movable=\"true\" mass=\"2.5\">\n"
213 " <body position=\"0.4,2.3,0\" orientation=\"45,0,0\" />\n"
214 " <leds medium=\"id_of_led_medium\">\n"
215 " <led offset=\" 0.15, 0.15,0.15\" anchor=\"origin\" color=\"white\" />\n"
216 " <led offset=\"-0.15, 0.15,0\" anchor=\"origin\" color=\"red\" />\n"
217 " <led offset=\" 0.15, 0.15,0\" anchor=\"origin\" color=\"blue\" />\n"
218 " <led offset=\" 0.15,-0.15,0\" anchor=\"origin\" color=\"green\" />\n"
223 "In the example, four LEDs are added around the cylinder. The LEDs have\n"
224 "different colors and are located around the cylinder. The LEDs are\n"
225 "managed by the LED medium declared in the <media> section of the\n"
226 "configuration file with id \"id_of_led_medium\"",
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception.
float Real
Collects all ARGoS code.
The namespace containing all the ARGoS related code.
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.
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
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.
REGISTER_STANDARD_SPACE_OPERATIONS_ON_COMPOSABLE(CComposableEntity)
void GetNodeAttribute(TConfigurationNode &t_node, const std::string &str_attribute, T &t_buffer)
Returns the value of a node's attribute.
REGISTER_ENTITY(CFloorEntity, "floor", "Carlo Pinciroli [ilpincy@gmail.com]", "1.0", "It contains the properties of the arena floor.", "The floor entity contains the properties of the arena floor. In the current\n" "implementation, it contains only the color of the floor. The floor color is\n" "detected by the robots' ground sensors.\n\n" "REQUIRED XML CONFIGURATION\n\n" " <arena ...>\n" " ...\n" " <floor id=\"floor\"\n" " source=\"SOURCE\" />\n" " ...\n" " </arena>\n\n" "The 'id' attribute is necessary and must be unique among the entities. If two\n" "entities share the same id, initialization aborts.\n" "The 'source' attribute specifies where to get the color of the floor from. Its\n" "value, here denoted as SOURCE, can assume the following values:\n\n" " image The color is calculated from the passed image file\n" " loop_functions The color is calculated calling the loop functions\n\n" "When 'source' is set to 'image', as showed in the following example, you have\n" "to specify the image path in the additional attribute 'path':\n\n" " <arena ...>\n" " ...\n" " <floor id=\"floor\"\n" " source=\"image\"\n" " path=\"/path/to/imagefile.ext\" />\n" " ...\n" " </arena>\n\n" "Many image formats are available, such as PNG, JPG, BMP, GIF and many more.\n" "Refer to the FreeImage webpage for a complete list of supported image formats\n" "(http://freeimage.sourceforge.net/features.html).\n\n" "When 'source' is set to 'loop_functions', as showed in the following example,\n" "an image is implicitly created to be used as texture for graphical\n" "visualizations. The algorithm that creates the texture needs to convert from\n" "meters (in the arena) to pixels (of the texture). You control how many pixels\n" "per meter are used with the attribute 'pixels_per_meter'. Clearly, the higher\n" "value, the higher the quality, but also the slower the algorithm and the bigger\n" "the texture. The algorithm is called only once at init time, so the fact that\n" "it is slow is not so important. However, the image size is limited by OpenGL.\n" "Every implementation has its own limit, and you should check yours if any\n" "texture-related problem arises. Now for the example:\n\n" " <arena ...>\n" " ...\n" " <floor id=\"floor\"\n" " source=\"loop_functions\"\n" " pixels_per_meter=\"100\" />\n" " ...\n" " </arena>\n\n" "OPTIONAL XML CONFIGURATION\n\n" "None for the time being.\n", "Usable")
Basic class for an entity that contains other entities.
virtual void UpdateComponents()
Calls the Update() method on all the components.
void AddComponent(CEntity &c_component)
Adds a component to this composable entity.
This entity is a link to a body in the physics engine.
void CalculateBoundingBox()
Calculates the bounding box of this entity.
const CPhysicsModel & GetPhysicsModel(size_t un_idx) const
Returns a physics model associated to this entity.
UInt32 GetPhysicsModelsNum() const
Returns the number of physics models associated to this entity.
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
void SetMovable(bool b_movable)
Sets whether this entity is movable or not.
virtual void Reset()
Resets the state of the entity to whatever it was after Init() or the standalone constructor was call...
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
T & GetMedium(const std::string &str_id)
Returns a reference to a medium.
static CSimulator & GetInstance()
Returns the instance to the CSimulator class.
The exception that wraps all errors in ARGoS.
void AddLED(const CVector3 &c_offset, const CColor &c_color=CColor::BLACK)
Adds an LED to this entity.
void Resize(Real f_radius, Real f_height)
void EnableLEDs(CLEDMedium &c_medium)
CEmbodiedEntity & GetEmbodiedEntity()
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
virtual void Reset()
Resets the state of the entity to whatever it was after Init() or the standalone constructor was call...
A container of CLEDEntity.
void SetMedium(CLEDMedium &c_medium)
Sets the medium associated to this entity.
void AddLED(const CVector3 &c_offset, SAnchor &s_anchor, const CColor &c_color=CColor::BLACK)
Adds an LED to this entity.
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
virtual void Reset()
Resets the state of the entity to whatever it was after Init() or the standalone constructor was call...