ARGoS 3
A parallel, multi-engine simulator for swarm robotics
quadrotor_position_default_actuator.cpp
Go to the documentation of this file.
1
6
8#include <argos3/core/utility/logging/argos_log.h>
9
10namespace argos {
11
12 /****************************************/
13 /****************************************/
14
18
19 /****************************************/
20 /****************************************/
21
23 try {
24 /* Get the quadrotor component */
25 m_pcQuadRotorEntity = &(c_entity.GetComponent<CQuadRotorEntity>("quadrotor"));
26 /* Check whether the control methods is unset - only one is allowed */
27 if(m_pcQuadRotorEntity->GetControlMethod() == CQuadRotorEntity::NO_CONTROL) {
28 /* Get the robot body */
29 m_pcEmbodiedEntity = &(c_entity.GetComponent<CEmbodiedEntity>("body"));
30 /* Set the position control method */
32 }
33 else {
34 THROW_ARGOSEXCEPTION("Can't associate a quadrotor position actuator to entity \"" << c_entity.GetId() << "\" because it conflicts with a previously associated quadrotor actuator.");
35 }
36 }
37 catch(CARGoSException& ex) {
38 THROW_ARGOSEXCEPTION_NESTED("Error setting quadrotor position actuator to entity \"" << c_entity.GetId() << "\"", ex);
39 }
40 }
41
42 /****************************************/
43 /****************************************/
44
46 try {
48 Reset();
49 }
50 catch(CARGoSException& ex) {
51 THROW_ARGOSEXCEPTION_NESTED("Initialization error in quadrotor position actuator.", ex);
52 }
53 }
54
55 /****************************************/
56 /****************************************/
57
61
62 /****************************************/
63 /****************************************/
64
66 m_sDesiredPosData.Position = c_pos;
67 m_sDesiredPosData.Position.Rotate(m_pcEmbodiedEntity->GetOriginAnchor().Orientation);
68 m_sDesiredPosData.Position += m_pcEmbodiedEntity->GetOriginAnchor().Position;
69 }
70
71 /****************************************/
72 /****************************************/
73
77
78 /****************************************/
79 /****************************************/
80
82 CRadians cYAngle, cXAngle;
83 m_pcEmbodiedEntity->GetOriginAnchor().Orientation.ToEulerAngles(m_sDesiredPosData.Yaw, cYAngle, cXAngle);
84 m_sDesiredPosData.Yaw += c_yaw;
85 }
86
87 /****************************************/
88 /****************************************/
89
93
94 /****************************************/
95 /****************************************/
96
98 m_sDesiredPosData.Position = m_pcEmbodiedEntity->GetOriginAnchor().Position;
99 CRadians cYAngle, cXAngle;
100 m_pcEmbodiedEntity->GetOriginAnchor().Orientation.ToEulerAngles(m_sDesiredPosData.Yaw, cYAngle, cXAngle);
101 Update();
102 }
103
104 /****************************************/
105 /****************************************/
106
107}
108
109REGISTER_ACTUATOR(CQuadRotorPositionDefaultActuator,
110 "quadrotor_position", "default",
111 "Carlo Pinciroli [ilpincy@gmail.com]",
112 "1.0",
113 "The quadrotor position actuator.",
114
115 "This actuator controls the position of a quadrotor robot. For a\n"
116 "complete description of its usage, refer to the\n"
117 "ci_quadrotor_position_actuator.h file.\n\n"
118
119 "REQUIRED XML CONFIGURATION\n\n"
120
121 " <controllers>\n"
122 " ...\n"
123 " <my_controller ...>\n"
124 " ...\n"
125 " <actuators>\n"
126 " ...\n"
127 " <quadrotor_position implementation=\"default\" />\n"
128 " ...\n"
129 " </actuators>\n"
130 " ...\n"
131 " </my_controller>\n"
132 " ...\n"
133 " </controllers>\n\n"
134
135 "OPTIONAL XML CONFIGURATION\n\n"
136
137 "None for the time being.\n\n"
138 ,
139 "Usable"
140 );
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception.
#define THROW_ARGOSEXCEPTION(message)
This macro throws an ARGoS exception with the passed message.
#define REGISTER_ACTUATOR(CLASSNAME, LABEL, IMPLEMENTATION, AUTHOR, VERSION, BRIEF_DESCRIPTION, LONG_DESCRIPTION, STATUS)
Registers a new actuator model inside ARGoS.
Definition actuator.h:59
The namespace containing all the ARGoS related code.
Definition ci_actuator.h:12
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
virtual void Init(TConfigurationNode &t_node)
Initializes the actuator from the XML configuration tree.
Definition ci_actuator.h:54
Basic class for an entity that contains other entities.
CEntity & GetComponent(const std::string &str_component)
Returns the component with the passed string label.
This entity is a link to a body in the physics engine.
const std::string & GetId() const
Returns the id of this entity.
Definition entity.h:157
The exception that wraps all errors in ARGoS.
It defines the basic type CRadians, used to store an angle value in radians.
Definition angles.h:42
A 3D vector class.
Definition vector3.h:31
virtual void Init(TConfigurationNode &t_tree)
Initializes the actuator from the XML configuration tree.
virtual void Update()
Updates the state of the entity associated to this actuator.
virtual void SetAbsoluteYaw(const CRadians &c_yaw)
Sets the absolute yaw of the robot in the world.
virtual void SetRelativePosition(const CVector3 &c_pos)
Sets the position of the robot in the environment relative to the current position and attitude.
virtual void SetAbsolutePosition(const CVector3 &c_pos)
Sets the absolute position of the robot in the environment.
virtual void SetRelativeYaw(const CRadians &c_yaw)
Sets the yaw of the robot in the environment relative to the current position and attitude.
virtual void SetRobot(CComposableEntity &c_entity)
Sets the entity associated to this actuator.
CQuadRotorEntity::SPositionControlData m_sDesiredPosData
virtual void Reset()
Resets the actuator to the state it had just after Init().