perspective_camera_equipped_entity.h
Go to the documentation of this file.
1 
7 #ifndef PERSPECTIVE_CAMERA_EQUIPPED_ENTITY_H
8 #define PERSPECTIVE_CAMERA_EQUIPPED_ENTITY_H
9 
10 namespace argos {
11  class CPerspectiveCameraEquippedEntity;
12  class CEmbodiedEntity;
13  struct SAnchor;
14 }
15 
16 #include <argos3/core/simulator/entity/entity.h>
17 #include <argos3/core/simulator/physics_engine/physics_model.h>
18 #include <argos3/core/utility/math/vector3.h>
19 #include <argos3/core/utility/math/quaternion.h>
20 
21 namespace argos {
22 
24 
25  public:
26 
27  ENABLE_VTABLE();
28 
29  public:
30 
37 
53  const std::string& str_id,
54  const CRadians& c_aperture,
55  Real f_focal_length,
56  Real f_range,
57  SInt32 n_width,
58  SInt32 n_height,
59  SAnchor& s_anchor);
60 
65  virtual void Init(TConfigurationNode& t_tree);
66 
67  virtual void Enable();
68 
69  virtual void Disable();
70 
75  inline const CRadians& GetAperture() const {
76  return m_cAperture;
77  }
78 
83  inline void SetAperture(const CRadians& c_aperture) {
84  m_cAperture = c_aperture;
85  }
86 
91  inline Real GetFocalLength() const {
92  return m_fFocalLength;
93  }
94 
99  inline void SetFocalLength(Real f_focal_length) {
100  m_fFocalLength = f_focal_length;
101  }
102 
107  inline Real GetRange() const {
108  return m_fRange;
109  }
110 
115  inline void SetRange(Real f_range) {
116  m_fRange = f_range;
117  }
118 
123  inline const SAnchor& GetAnchor() const {
124  return *m_psAnchor;
125  }
126 
131  inline void SetAnchor(SAnchor& s_anchor) {
132  m_psAnchor = &s_anchor;
133  }
134 
139  inline SInt32 GetImagePxWidth() const {
140  return m_nImagePxWidth;
141  }
142 
147  inline SInt32 GetImagePxHeight() const {
148  return m_nImagePxHeight;
149  }
150 
156  inline void SetImagePxSize(SInt32 n_width,
157  SInt32 n_height) {
158  m_nImagePxWidth = n_width;
159  m_nImagePxHeight = n_height;
160  Real fAspectRatio =
161  static_cast<Real>(m_nImagePxWidth) /
162  static_cast<Real>(m_nImagePxHeight);
163  m_fImageMtHeight =
164  2.0 * m_fFocalLength * Tan(m_cAperture) /
165  Sqrt(1.0 + fAspectRatio * fAspectRatio);
166  m_fImageMtWidth = m_fImageMtHeight * fAspectRatio;
167  }
168 
173  inline Real GetImageMtWidth() const {
174  return m_fImageMtWidth;
175  }
176 
181  inline Real GetImageMtHeight() const {
182  return m_fImageMtHeight;
183  }
184 
185  virtual std::string GetTypeDescription() const {
186  return "perspective_camera";
187  }
188 
189  private:
190 
192  CRadians m_cAperture;
193 
195  Real m_fFocalLength;
196 
198  Real m_fRange;
199 
201  SInt32 m_nImagePxWidth;
202 
204  SInt32 m_nImagePxHeight;
205 
207  Real m_fImageMtWidth;
208 
210  Real m_fImageMtHeight;
211 
213  SAnchor* m_psAnchor;
214 
215  };
216 }
217 
218 #endif
signed int SInt32
32-bit signed integer.
Definition: datatypes.h:93
#define Sqrt
Definition: general.h:64
Real GetRange() const
Returns the range of the camera.
float Real
Collects all ARGoS code.
Definition: datatypes.h:39
The basic entity type.
Definition: entity.h:89
void SetFocalLength(Real f_focal_length)
Sets the focal length of the camera.
Real GetFocalLength() const
Returns the focal length of the camera.
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
void SetAperture(const CRadians &c_aperture)
Sets the aperture of the visibility cone of the camera.
It defines the basic type CRadians, used to store an angle value in radians.
Definition: angles.h:42
SInt32 GetImagePxHeight() const
Returns the image height in pixel.
Real GetImageMtWidth() const
Returns the image width in meters.
Basic class for an entity that contains other entities.
virtual std::string GetTypeDescription() const
Returns a string label for this class.
An anchor related to the body of an entity.
Definition: physics_model.h:38
Real GetImageMtHeight() const
Returns the image height in meters.
void SetImagePxSize(SInt32 n_width, SInt32 n_height)
Sets the image size in pixel.
Real Tan(const CRadians &c_radians)
Computes the tangent of the passed value in radians.
Definition: angles.h:604
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
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.
void SetRange(Real f_range)
Sets the range of the camera.
CPerspectiveCameraEquippedEntity(CComposableEntity *pc_parent)
Class constructor.
const CRadians & GetAperture() const
Returns the aperture of the visibility cone of the camera.
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
void SetAnchor(SAnchor &s_anchor)
Sets the anchor to which the camera is attached.