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_box_model.h>
21 m_pcEmbodiedEntity(nullptr),
22 m_pcLEDEquippedEntity(nullptr),
24 m_pcLEDMedium(nullptr) {}
42 m_pcLEDEquippedEntity(
82 m_pcLEDEquippedEntity->
Init(
GetNode(t_tree,
"leds"));
84 std::string strMedium;
87 m_pcLEDEquippedEntity->
SetMedium(*m_pcLEDMedium);
88 m_pcLEDEquippedEntity->
Enable();
111 m_pcLEDMedium = &c_medium;
112 m_pcLEDEquippedEntity->
SetMedium(*m_pcLEDMedium);
113 m_pcLEDEquippedEntity->
Enable();
120 m_pcLEDEquippedEntity->
Disable();
128 m_pcLEDEquippedEntity->
AddLED(c_offset,
153 "Carlo Pinciroli [ilpincy@gmail.com]",
155 "A stretchable 3D box.",
156 "The box entity can be used to model walls, obstacles or box-shaped grippable\n"
157 "objects. It can be movable or not. A movable object can be pushed and gripped.\n"
158 "An unmovable object is pretty much like a wall.\n\n"
159 "REQUIRED XML CONFIGURATION\n\n"
160 "To declare an unmovable object (i.e., a wall) you need the following:\n\n"
163 " <box id=\"box1\" size=\"0.75,0.1,0.5\" movable=\"false\">\n"
164 " <body position=\"0.4,2.3,0\" orientation=\"45,0,0\" />\n"
168 "To declare a movable object you need the following:\n\n"
171 " <box id=\"box1\" size=\"0.75,0.1,0.5\" movable=\"true\" mass=\"2.5\">\n"
172 " <body position=\"0.4,2.3,0\" orientation=\"45,0,0\" />\n"
176 "The 'id' attribute is necessary and must be unique among the entities. If two\n"
177 "entities share the same id, initialization aborts.\n"
178 "The 'size' attribute specifies the size of the box along the three axes, in\n"
179 "the X,Y,Z order. When you add a box, imagine it initially unrotated and\n"
180 "centered in the origin. The size, then, corresponds to the extent along the X,\n"
182 "The 'movable' attribute specifies whether or not the object is movable. When\n"
183 "set to 'false', the object is unmovable: if another object pushes against it,\n"
184 "the box won't move. When the attribute is set to 'true', the box is movable\n"
185 "upon pushing or gripping. When an object is movable, the 'mass' attribute is\n"
187 "The 'mass' attribute quantifies the mass of the box in kg.\n"
188 "The 'body/position' attribute specifies the position of the base of the box in\n"
189 "the arena. The three values are in the X,Y,Z order.\n"
190 "The 'body/orientation' attribute specifies the orientation of the 3D box. All\n"
191 "rotations are performed with respect to the center of mass. The order of the\n"
192 "angles is Z,Y,X, which means that the first number corresponds to the rotation\n"
193 "around the Z axis, the second around Y and the last around X. This reflects\n"
194 "the internal convention used in ARGoS, in which rotations are performed in\n"
195 "that order. Angles are expressed in degrees.\n\n"
196 "OPTIONAL XML CONFIGURATION\n\n"
197 "It is possible to add any number of colored LEDs to the box. In this way,\n"
198 "the box is visible with a robot camera. The position and color of the\n"
199 "LEDs is specified with the following syntax:\n\n"
202 " <box id=\"box1\" size=\"0.75,0.1,0.5\" movable=\"true\" mass=\"2.5\">\n"
203 " <body position=\"0.4,2.3,0\" orientation=\"45,0,0\" />\n"
204 " <leds medium=\"id_of_led_medium\">\n"
205 " <led offset=\" 0.15, 0.15,0.15\" anchor=\"origin\" color=\"white\" />\n"
206 " <led offset=\"-0.15, 0.15,0\" anchor=\"origin\" color=\"red\" />\n"
207 " <led offset=\" 0.15, 0.15,0\" anchor=\"origin\" color=\"blue\" />\n"
208 " <led offset=\" 0.15,-0.15,0\" anchor=\"origin\" color=\"green\" />\n"
213 "In the example, four LEDs are added to the box. The LEDs have\n"
214 "different colors and are located one on the top and three\n"
215 "around the box. The LEDs are managed by the LED medium declared in\n"
216 "the <media> section of the 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 Reset()
Resets the state of the entity to whatever it was after Init() or the standalone constructor was call...
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.
const std::string & GetId() const
Returns the id of this entity.
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.
CEmbodiedEntity & GetEmbodiedEntity()
virtual void Reset()
Resets the state of the entity to whatever it was after Init() or the standalone constructor was call...
void EnableLEDs(CLEDMedium &c_medium)
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
void Resize(const CVector3 &c_size)
void AddLED(const CVector3 &c_offset, const CColor &c_color=CColor::BLACK)
Adds an LED to this entity.
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.