7 #ifndef CAMERA_SENSOR_TAG_DETECTOR_ALGORITHM_H
8 #define CAMERA_SENSOR_TAG_DETECTOR_ALGORITHM_H
11 class CCameraSensorTagDetectorAlgorithm;
14 #include <argos3/core/simulator/entity/embodied_entity.h>
15 #include <argos3/core/simulator/space/positional_indices/positional_index.h>
16 #include <argos3/core/utility/math/ray3.h>
17 #include <argos3/core/utility/math/matrix/transformationmatrix3.h>
19 #include <argos3/plugins/simulator/entities/tag_entity.h>
20 #include <argos3/plugins/robots/generic/simulator/camera_sensor_algorithm.h>
21 #include <argos3/plugins/robots/generic/control_interface/ci_camera_sensor_algorithms/ci_camera_sensor_tag_detector_algorithm.h>
40 const std::array<CPlane, 6>& arr_frustum_planes,
46 c_camera_to_world_transform,
48 m_cAlgorithm(c_algorithm) {
49 m_cOcclusionCheckRay.
SetStart(c_camera_location);
58 std::transform(std::begin(m_arrTagCornerOffsets),
59 std::end(m_arrTagCornerOffsets),
60 std::begin(m_arrTagCorners),
61 [&c_tag] (
const CVector3& c_tag_corner_offset) {
66 for(
const CVector3& c_corner : m_arrTagCorners) {
72 for(
const CVector3& c_corner : m_arrTagCorners) {
73 m_cOcclusionCheckRay.
SetEnd(c_corner);
83 std::transform(std::begin(m_arrTagCorners),
84 std::end(m_arrTagCorners),
85 std::begin(m_arrTagCornerPixels),
86 [
this] (
const CVector3& c_tag_corner) {
90 const std::string& strPayload = c_tag.
GetPayload();
91 m_cAlgorithm.
AddReading(strPayload, cCenterPixel, m_arrTagCornerPixels);
97 const std::array<CVector3, 4> m_arrTagCornerOffsets = {{
103 std::array<CVector3, 4> m_arrTagCorners;
104 std::array<CVector2, 4> m_arrTagCornerPixels;
105 CRay3 m_cOcclusionCheckRay;
106 SEmbodiedEntityIntersectionItem m_sIntersectionItem;
119 const std::array<CPlane, 6>& arr_frustum_planes,
122 const CVector3& c_bounding_box_position,
123 const CVector3& c_bounding_box_half_extents);
133 const std::array<CVector2, 4>& arr_corner_pixels) {
134 m_vecReadings.emplace_back(str_payload, c_center_pixel, arr_corner_pixels);
150 m_bShowRays = b_show_rays;
The namespace containing all the ARGoS related code.
bool GetClosestEmbodiedEntityIntersectedByRay(SEmbodiedEntityIntersectionItem &s_item, const CRay3 &c_ray)
Returns the closest intersection with an embodied entity to the ray start.
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
const CQuaternion & GetOrientation() const
const CVector3 & GetPosition() const
A data structure that contains positional entities.
void SetEnd(const CVector3 &c_end)
void SetStart(const CVector3 &c_start)
CVector3 & Rotate(const CQuaternion &c_quaternion)
Rotates this vector by the given quaternion.
std::vector< SReading > m_vecReadings
std::vector< std::pair< bool, CRay3 > > m_vecCheckedRays
CRadians GetAngleWithCamera(const CPositionalEntity &c_entity) const
CVector2 ProjectOntoSensor(const CVector3 &c_vector) const
bool IsPointInsideFrustum(const CVector3 &c_point) const
This class provides the most general interface to a camera.
virtual void Init(TConfigurationNode &t_tree)
Initializes the resource.
void SetShowRays(bool b_show_rays)
Sets whether or not the rays must be shown in the GUI.
CCameraSensorTagDetectorAlgorithm()
void AddReading(const std::string &str_payload, const CVector2 &c_center_pixel, const std::array< CVector2, 4 > &arr_corner_pixels)
virtual ~CCameraSensorTagDetectorAlgorithm()
bool IsShowRays()
Returns true if the rays must be shown in the GUI.
void AddCheckedRay(bool b_intersected, const CRay3 &c_ray)
virtual void Update(const CSquareMatrix< 3 > &c_projection_matrix, const std::array< CPlane, 6 > &arr_frustum_planes, const CTransformationMatrix3 &c_camera_to_world_transform, const CVector3 &c_camera_location, const CVector3 &c_bounding_box_position, const CVector3 &c_bounding_box_half_extents)
virtual ~CUpdateOperation()
CUpdateOperation(const CSquareMatrix< 3 > &c_projection_matrix, const std::array< CPlane, 6 > &arr_frustum_planes, const CTransformationMatrix3 &c_camera_to_world_transform, const CVector3 &c_camera_location, CCameraSensorTagDetectorAlgorithm &c_algorithm)
virtual bool operator()(CTagEntity &c_tag)
const std::string & GetPayload() const
Returns the current payload of the tag.
const CRadians & GetObservableAngle() const
Returns the observable angle of the tag.
Real GetSideLength() const
Returns the side length of the tag.