9 #include <argos3/core/utility/math/quaternion.h>
10 #include <argos3/core/utility/logging/argos_log.h>
14 static const Real MOVE_GAIN = 0.005f / ::exp(0.02f);
15 static const Real ROTATE_GAIN = 0.01f / ::exp(-0.02f);
24 tCameraNode =
GetNode(t_tree,
"camera");
27 for(itSettingss = itSettingss.begin(&tCameraNode);
28 itSettingss != itSettingss.end();
31 if(nIdx >=0 && nIdx <= 11) {
32 m_sSettings[nIdx].
Init(*itSettingss);
35 THROW_ARGOSEXCEPTION(
"Error initializing QTOpenGL camera settings: value given for 'idx' is out of bounds. Value = \"" << nIdx <<
"\", allowed [0-9].");
63 Left.
Set(cLeftXY.GetX(), cLeftXY.GetY(), 0.0f);
67 LOGERR <<
"[WARNING] The given camera position is ambiguous, "
68 <<
"and a standard attitude has been used to calculate it. "
69 <<
"Consider specifying the \"up\" vector in the .argos file "
70 <<
"for more precise placement."
88 GetNodeAttributeOrDefault<Real>(t_tree,
"lens_focal_length", fValue, 20.0f);
114 cNewUp *=
Cos(c_angle);
115 cNewUp += Forward *
Sin(c_angle);
126 if(Forward.GetZ() < 0.0f) {
169 Forward *=
Cos(c_angle);
170 Forward += Left *
Sin(c_angle);
177 Left.CrossProduct(Forward).Normalize();
192 if(Forward.GetX() != 0 || Forward.GetY() != 0) {
194 CVector3 cForwardXY(Forward.GetX(), Forward.GetY(), 0.0f);
198 cForwardXY.Normalize();
223 cNewForwardXY *=
Cos(c_angle);
224 cNewForwardXY += cLeftXY *
Sin(c_angle);
235 cNewForwardXY *= cForwardXYLength;
238 Forward.SetY(cNewForwardXY.
GetY());
248 Left *=
Cos(c_angle);
249 Left -= cForwardXY *
Sin(c_angle);
254 Up.CrossProduct(Left).Normalize();
262 Position += Forward * c_delta.
GetX() + Left * c_delta.
GetY() + Up * c_delta.
GetZ();
287 YFieldOfView =
ToDegrees(2.0f *
ATan2(0.027f * 0.5f, LensFocalLength));
294 MotionSensitivity = MOVE_GAIN * ::exp(LensFocalLength);
295 RotationSensitivity = ROTATE_GAIN * ::exp(-LensFocalLength);
302 m_unActiveSettings(0) {
315 m_sSettings[m_unActiveSettings]
317 m_sSettings[m_unActiveSettings]
319 m_sSettings[m_unActiveSettings]
321 m_sSettings[m_unActiveSettings]
331 m_sSettings[m_unActiveSettings].
Translate(
332 CVector3(m_sSettings[m_unActiveSettings].MotionSensitivity * n_forwards_backwards,
333 m_sSettings[m_unActiveSettings].MotionSensitivity * n_sideways,
334 m_sSettings[m_unActiveSettings].MotionSensitivity * n_up_down));
signed int SInt32
32-bit signed integer.
void Move(SInt32 n_forwards_backwards, SInt32 n_sideways, SInt32 n_up_down)
void Init(TConfigurationNode &t_tree)
Initialize from XML.
void Init(TConfigurationNode &t_tree)
CDegrees ToDegrees(const CRadians &c_radians)
Converts CRadians to CDegrees.
void RotateLeftRight(const CRadians &c_angle)
Rotation around the local Z axis.
float Real
Collects all ARGoS code.
CRadians ATan2(const Real f_y, const Real f_x)
Computes the arctangent of the passed values.
#define THROW_ARGOSEXCEPTION(message)
This macro throws an ARGoS exception with the passed message.
Real GetX() const
Returns the x coordinate of this vector.
void CalculateSensitivity()
Calculate the sensitivity of the camera.
Real GetY() const
Returns the y coordinate of this vector.
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.
CVector3 Up
The local Z axis of the camera in the global reference frame.
Real Cos(const CRadians &c_radians)
Computes the cosine of the passed value in radians.
void RotateLeftRight2(const CRadians &c_angle)
Rotation around the global Z axis.
CVector3 Position
The position of the camera in the global reference frame.
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
CVector2 & Perpendicularize()
Transforms this vector into its ortogonal.
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception...
It defines the basic type CRadians, used to store an angle value in radians.
Real Length() const
Returns the length of this vector.
void Set(const Real f_x, const Real f_y, const Real f_z)
Sets the vector contents from Cartesian coordinates.
void SetX(const Real f_x)
Sets the x coordinate of this vector.
void Do()
Places this camera in the right position.
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.
bool NodeAttributeExists(TConfigurationNode &t_node, const std::string &str_attribute)
Returns true if the specified attribute of a node exists.
Real Sin(const CRadians &c_radians)
Computes the sine of the passed value in radians.
void Rotate(const QPoint &c_delta)
CARGoSLog LOGERR(std::cerr, SLogColor(ARGOS_LOG_ATTRIBUTE_BRIGHT, ARGOS_LOG_COLOR_RED))
ticpp::Iterator< ticpp::Element > TConfigurationNodeIterator
The iterator for the ARGoS configuration XML node.
void GetNodeAttribute(TConfigurationNode &t_node, const std::string &str_attribute, T &t_buffer)
Returns the value of a node's attribute.
The exception that wraps all errors in ARGoS.
void Translate(const CVector3 &c_delta)
c_delta is expressed in the camera local coordinates
static const CVector3 Z
The z axis.
CVector3 Forward
The local X axis of the camera in the global reference frame.
Real LensFocalLength
The focal length of the lens (if this was a real camera)
CRadians GetAngleWith(const CVector3 &c_other)
Returns the angle between this vector and the passed vector.
CVector3 & CrossProduct(const CVector3 &c_vector3)
Calculates the cross product between this vector and the passed one.
void RotateUpDown(const CRadians &c_angle)
Rotation around the local Y axis.
CVector3 Target
The direction of sight of the camera in the global reference frame.
The namespace containing all the ARGoS related code.
Real GetZ() const
Returns the z coordinate of this vector.
void CalculateYFieldOfView()
Calculates the value of YFieldOfView.
CVector3 & Normalize()
Normalizes this vector.
CVector3 Left
The local Y axis of the camera in the global reference frame.
static const CRadians PI_OVER_TWO
Set to PI / 2.