ARGoS
3
A parallel, multi-engine simulator for swarm robotics
|
Go to the documentation of this file.
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].");
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);
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));
void Set(const Real f_x, const Real f_y, const Real f_z)
Sets the vector contents from Cartesian coordinates.
Real LensFocalLength
The focal length of the lens (if this was a real camera)
Real GetZ() const
Returns the z coordinate of this vector.
void Do()
Places this camera in the right position.
void CalculateSensitivity()
Calculate the sensitivity of the camera.
Real Cos(const CRadians &c_radians)
Computes the cosine of the passed value in radians.
void SetX(const Real f_x)
Sets the x coordinate of this vector.
The namespace containing all the ARGoS related code.
It defines the basic type CRadians, used to store an angle value in radians.
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.
The exception that wraps all errors in ARGoS.
static const CRadians PI_OVER_TWO
Set to PI / 2.
CDegrees ToDegrees(const CRadians &c_radians)
Converts CRadians to CDegrees.
void RotateUpDown(const CRadians &c_angle)
Rotation around the local Y axis.
CVector3 Up
The local Z axis of the camera in the global reference frame.
void RotateLeftRight(const CRadians &c_angle)
Rotation around the local Z axis.
static const CVector3 Z
The z axis.
void Init(TConfigurationNode &t_tree)
Initialize from XML.
Real Sin(const CRadians &c_radians)
Computes the sine of the passed value in radians.
CRadians ATan2(const Real f_y, const Real f_x)
Computes the arctangent of the passed values.
void RotateLeftRight2(const CRadians &c_angle)
Rotation around the global Z axis.
void Move(SInt32 n_forwards_backwards, SInt32 n_sideways, SInt32 n_up_down)
CARGoSLog LOGERR(std::cerr, SLogColor(ARGOS_LOG_ATTRIBUTE_BRIGHT, ARGOS_LOG_COLOR_RED))
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
Real GetY() const
Returns the y coordinate of this vector.
CVector3 & CrossProduct(const CVector3 &c_vector3)
Calculates the cross product between this vector and the passed one.
Real GetX() const
Returns the x coordinate of this vector.
CVector3 Left
The local Y axis of the camera in the global reference frame.
void Rotate(const QPoint &c_delta)
Real Length() const
Returns the length of this vector.
CVector3 Position
The position of the camera in the global reference frame.
void CalculateYFieldOfView()
Calculates the value of YFieldOfView.
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception.
ticpp::Iterator< ticpp::Element > TConfigurationNodeIterator
The iterator for the ARGoS configuration XML node.
#define THROW_ARGOSEXCEPTION(message)
This macro throws an ARGoS exception with the passed message.
Real GetX() const
Returns the x coordinate of this vector.
signed int SInt32
32-bit signed integer.
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.
void Init(TConfigurationNode &t_tree)
CVector3 Target
The direction of sight of the camera in the global reference frame.
CRadians GetAngleWith(const CVector3 &c_other)
Returns the angle between this vector and the passed vector.
CVector3 Forward
The local X axis of the camera in the global reference frame.
CVector3 & Normalize()
Normalizes this vector.
void GetNodeAttribute(TConfigurationNode &t_node, const std::string &str_attribute, T &t_buffer)
Returns the value of a node's attribute.
bool NodeAttributeExists(TConfigurationNode &t_node, const std::string &str_attribute)
Returns true if the specified attribute of a node exists.
CVector2 & Perpendicularize()
Transforms this vector into its ortogonal.
Real GetY() const
Returns the y coordinate of this vector.
float Real
Collects all ARGoS code.
void Translate(const CVector3 &c_delta)
c_delta is expressed in the camera local coordinates