2 #include <argos3/core/simulator/simulator.h>
3 #include <argos3/core/simulator/space/positional_indices/positional_index.h>
4 #include <argos3/core/simulator/entity/composable_entity.h>
5 #include <argos3/core/simulator/entity/embodied_entity.h>
6 #include <argos3/plugins/simulator/entities/led_entity.h>
7 #include <argos3/plugins/simulator/entities/perspective_camera_equipped_entity.h>
8 #include <argos3/plugins/simulator/media/led_medium.h>
25 Real f_noise_std_dev) :
27 m_cCamEntity(c_cam_entity),
28 m_cEmbodiedEntity(c_embodied_entity),
29 m_cControllableEntity(c_controllable_entity),
30 m_bShowRays(b_show_rays),
31 m_fNoiseStdDev(f_noise_std_dev),
34 if(m_fNoiseStdDev > 0.0f) {
39 while(! m_tBlobs.empty()) {
40 delete m_tBlobs.back();
49 if(m_pcRootSensingEntity == &c_led.
GetRootEntity())
return true;
56 m_cLEDRelative.
Rotate(m_cInvCameraOrient);
58 Real fDotProd = m_cLEDRelative.
GetX();
64 if(fDotProd < m_cCamEntity.
GetRange() &&
82 (m_cLEDRelative.
GetY() -
87 (m_cLEDRelative.
GetZ() -
111 while(! m_tBlobs.empty()) {
112 delete m_tBlobs.back();
129 CEntity* m_pcRootSensingEntity;
133 CRay3 m_cOcclusionCheckRay;
142 m_pcCamEntity(nullptr),
143 m_pcControllableEntity(nullptr),
144 m_pcEmbodiedEntity(nullptr),
145 m_pcLEDIndex(nullptr),
146 m_pcEmbodiedIndex(nullptr),
178 Real fNoiseStdDev = 0.0f;
181 std::string strMedium;
216 CVector3 cCenter(fHalfRange, 0.0f, 0.0f);
220 CVector3 cCorner(fHalfRange, fHalfSide, fHalfSide);
268 "colored_blob_perspective_camera",
"default",
269 "Carlo Pinciroli [ilpincy@gmail.com]",
272 "A generic perspective camera sensor to detect colored blobs.",
273 "This sensor accesses an perspective camera that detects colored blobs. The\n"
274 "sensor returns a list of blobs, each defined by a color and a position with\n"
275 "respect to the robot reference point on the ground. In controllers, you must\n"
276 "include the ci_colored_blob_perspective_camera_sensor.h header.\n\n"
278 "This sensor is disabled by default, and must be enabled before it can be\n"
281 "REQUIRED XML CONFIGURATION\n\n"
285 " <my_controller ...>\n"
289 " <colored_blob_perspective_camera implementation=\"default\"\n"
290 " medium=\"leds\" />\n"
294 " </my_controller>\n"
296 " </controllers>\n\n"
298 "The 'medium' attribute must be set to the id of the leds medium declared in the\n"
299 "<media> section.\n\n"
301 "OPTIONAL XML CONFIGURATION\n\n"
303 "It is possible to draw the rays shot by the camera sensor in the OpenGL\n"
304 "visualization. This can be useful for sensor debugging but also to understand\n"
305 "what's wrong in your controller. In OpenGL, the rays are drawn in cyan when\n"
306 "they are not obstructed and in purple when they are. In case a ray is\n"
307 "obstructed, a black dot is drawn where the intersection occurred.\n"
308 "To turn this functionality on, add the attribute \"show_rays\" as in this\n"
313 " <my_controller ...>\n"
317 " <colored_blob_perspective_camera implementation=\"default\"\n"
318 " medium=\"leds\" />\n"
319 " show_rays=\"true\" />\n"
323 " </my_controller>\n"
325 " </controllers>\n\n"
327 "It is possible to add uniform noise to the blobs, thus matching the\n"
328 "characteristics of a real robot better. This can be done with the attribute\n"
329 "\"noise_std_dev\".\n\n"
333 " <my_controller ...>\n"
337 " <colored_blob_perspective_camera implementation=\"default\"\n"
338 " medium=\"leds\" />\n"
339 " noise_std_dev=\"0.1\" />\n"
343 " </my_controller>\n"
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception.
signed int SInt32
32-bit signed integer.
float Real
Collects all ARGoS code.
The namespace containing all the ARGoS related code.
CRadians ACos(Real f_value)
Computes the arccosine of the passed value.
bool GetClosestEmbodiedEntityIntersectedByRay(SEmbodiedEntityIntersectionItem &s_item, const CRay3 &c_ray)
Returns the closest intersection with an embodied entity to the ray start.
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.
REGISTER_SENSOR(CEPuckProximityDefaultSensor, "epuck_proximity", "default", "Danesh Tarapore [daneshtarapore@gmail.com]", "1.0", "The E-Puck proximity sensor.", "This sensor accesses the epuck proximity sensor. For a complete description\n" "of its usage, refer to the ci_epuck_proximity_sensor.h interface. For the XML\n" "configuration, refer to the default proximity sensor.\n", "Usable")
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
Real Tan(const CRadians &c_radians)
Computes the tangent of the passed value in radians.
T Abs(const T &t_v)
Returns the absolute value of the passed argument.
void GetNodeAttribute(TConfigurationNode &t_node, const std::string &str_attribute, T &t_buffer)
Returns the value of a node's attribute.
virtual void Enable()
Enables updating of sensor information in the event loop.
virtual void Init(TConfigurationNode &t_node)
Initializes the sensor from the XML configuration tree.
virtual void Disable()
Disables updating of sensor information in the event loop.
Basic class for an entity that contains other entities.
CEntity & GetComponent(const std::string &str_component)
Returns the component with the passed string label.
An entity that contains a pointer to the user-defined controller.
void AddCheckedRay(bool b_obstructed, const CRay3 &c_ray)
Adds a ray to the list of checked rays.
This entity is a link to a body in the physics engine.
CEntity & GetRootEntity()
Returns the root entity containing this entity.
const CVector3 & GetPosition() const
CQuaternion Orientation
The orientation of the anchor wrt the global coordinate system.
CVector3 Position
The position of the anchor wrt the global coordinate system.
T & GetMedium(const std::string &str_id)
Returns a reference to a medium.
static CSimulator & GetInstance()
Returns the instance to the CSimulator class.
A data structure that contains positional entities.
The exception that wraps all errors in ARGoS.
It defines the basic type CRadians, used to store an angle value in radians.
CQuaternion Inverse() const
void SetEnd(const CVector3 &c_end)
void SetStart(const CVector3 &c_start)
static CRNG * CreateRNG(const std::string &str_category)
Creates a new RNG inside the given category.
Real Length() const
Returns the length of this vector.
CVector3 & Rotate(const CQuaternion &c_quaternion)
Rotates this vector by the given quaternion.
Real GetX() const
Returns the x coordinate of this vector.
CVector3 & Normalize()
Normalizes this vector.
Real GetY() const
Returns the y coordinate of this vector.
Real GetZ() const
Returns the z coordinate of this vector.
std::vector< SBlob * > TBlobList
Vector of pointers to colored blobs.
An SBlob represents a generic colored 2D segment in the image.
virtual ~CPerspectiveCameraLEDCheckOperation()
virtual bool operator()(CLEDEntity &c_led)
CPerspectiveCameraLEDCheckOperation(CCI_ColoredBlobPerspectiveCameraSensor::TBlobList &t_blobs, CPerspectiveCameraEquippedEntity &c_cam_entity, CEmbodiedEntity &c_embodied_entity, CControllableEntity &c_controllable_entity, bool b_show_rays, Real f_noise_std_dev)
virtual void SetRobot(CComposableEntity &c_entity)
Sets the entity associated to this sensor.
virtual void Disable()
Disables updating of sensor information in the event loop.
CPerspectiveCameraLEDCheckOperation * m_pcOperation
CPositionalIndex< CLEDEntity > * m_pcLEDIndex
CEmbodiedEntity * m_pcEmbodiedEntity
CPerspectiveCameraEquippedEntity * m_pcCamEntity
CControllableEntity * m_pcControllableEntity
virtual void Enable()
Enables updating of sensor information in the event loop.
virtual void Destroy()
Destroys the sensor.
CColoredBlobPerspectiveCameraDefaultSensor()
virtual void Reset()
Resets the sensor to the state it had just after Init().
virtual void Init(TConfigurationNode &t_tree)
Initializes the sensor from the XML configuration tree.
virtual ~CColoredBlobPerspectiveCameraDefaultSensor()
virtual void Update()
Updates the state of the entity associated to this sensor, if the sensor is currently enabled.
const CColor & GetColor() const
Returns the current color of the LED.
Real GetRange() const
Returns the range of the camera.
const SAnchor & GetAnchor() const
Returns the offset of the camera with respect to the reference point.
SInt32 GetImagePxWidth() const
Returns the image width in pixel.
const CRadians & GetAperture() const
Returns the aperture of the visibility cone of the camera.
Real GetFocalLength() const
Returns the focal length of the camera.
Real GetImageMtWidth() const
Returns the image width in meters.
SInt32 GetImagePxHeight() const
Returns the image height in pixel.
Real GetImageMtHeight() const
Returns the image height in meters.