ARGoS  3
A parallel, multi-engine simulator for swarm robotics
quadrotor_speed_default_actuator.cpp
Go to the documentation of this file.
1 
8 #include <argos3/core/utility/logging/argos_log.h>
9 
10 namespace argos {
11 
12  /****************************************/
13  /****************************************/
14 
16  m_pcQuadRotorEntity(NULL) {
17  }
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 */
28  /* Get the robot body */
29  m_pcEmbodiedEntity = &(c_entity.GetComponent<CEmbodiedEntity>("body"));
30  /* Set the speed control method */
32  }
33  else {
34  THROW_ARGOSEXCEPTION("Can't associate a quadrotor speed 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 speed 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 speed actuator.", ex);
52  }
53  }
54 
55  /****************************************/
56  /****************************************/
57 
59  m_sDesiredSpeedData.Velocity = c_velocity;
60  }
61 
62  /****************************************/
63  /****************************************/
64 
66  m_sDesiredSpeedData.RotSpeed = c_speed;
67  }
68 
69  /****************************************/
70  /****************************************/
71 
74  }
75 
76  /****************************************/
77  /****************************************/
78 
82  Update();
83  }
84 
85  /****************************************/
86  /****************************************/
87 
88 }
89 
90 REGISTER_ACTUATOR(CQuadRotorSpeedDefaultActuator,
91  "quadrotor_speed", "default",
92  "Carlo Pinciroli [ilpincy@gmail.com]",
93  "1.0",
94  "The quadrotor speed actuator.",
95  "This actuator controls the speed of a quadrotor robot. For a\n"
96  "complete description of its usage, refer to the\n"
97  "ci_quadrotor_speed_actuator.h file.\n\n"
98  "REQUIRED XML CONFIGURATION\n\n"
99  " <controllers>\n"
100  " ...\n"
101  " <my_controller ...>\n"
102  " ...\n"
103  " <actuators>\n"
104  " ...\n"
105  " <quadrotor_speed implementation=\"default\" />\n"
106  " ...\n"
107  " </actuators>\n"
108  " ...\n"
109  " </my_controller>\n"
110  " ...\n"
111  " </controllers>\n\n"
112  "OPTIONAL XML CONFIGURATION\n\n"
113  "None for the time being.\n\n"
114  ,
115  "Usable"
116  );
quadrotor_speed_default_actuator.h
argos::CEntity::GetId
const std::string & GetId() const
Returns the id of this entity.
Definition: entity.h:157
argos
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
argos::CVector3
A 3D vector class.
Definition: vector3.h:29
argos::CQuadRotorSpeedDefaultActuator::m_pcQuadRotorEntity
CQuadRotorEntity * m_pcQuadRotorEntity
Definition: quadrotor_speed_default_actuator.h:45
argos::CRadians
It defines the basic type CRadians, used to store an angle value in radians.
Definition: angles.h:42
argos::CComposableEntity
Basic class for an entity that contains other entities.
Definition: composable_entity.h:32
argos::CARGoSException
The exception that wraps all errors in ARGoS.
Definition: argos_exception.h:61
argos::CComposableEntity::GetComponent
CEntity & GetComponent(const std::string &str_component)
Returns the component with the passed string label.
Definition: composable_entity.cpp:109
argos::CEmbodiedEntity
This entity is a link to a body in the physics engine.
Definition: embodied_entity.h:48
argos::TConfigurationNode
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
Definition: argos_configuration.h:27
argos::CQuadRotorSpeedDefaultActuator::m_sDesiredSpeedData
CQuadRotorEntity::SSpeedControlData m_sDesiredSpeedData
Definition: quadrotor_speed_default_actuator.h:47
argos::CQuadRotorEntity::SetSpeedControlData
void SetSpeedControlData(const SSpeedControlData &s_data)
Definition: quadrotor_entity.h:78
argos::CQuadRotorSpeedDefaultActuator::Init
virtual void Init(TConfigurationNode &t_tree)
Initializes the actuator from the XML configuration tree.
Definition: quadrotor_speed_default_actuator.cpp:45
argos::CQuadRotorSpeedDefaultActuator::Update
virtual void Update()
Updates the state of the entity associated to this actuator.
Definition: quadrotor_speed_default_actuator.cpp:72
argos::CQuadRotorEntity::SetControlMethod
void SetControlMethod(EControlMethod e_control_method)
Definition: quadrotor_entity.h:62
THROW_ARGOSEXCEPTION_NESTED
#define THROW_ARGOSEXCEPTION_NESTED(message, nested)
This macro throws an ARGoS exception with the passed message and nesting the passed exception.
Definition: argos_exception.h:115
THROW_ARGOSEXCEPTION
#define THROW_ARGOSEXCEPTION(message)
This macro throws an ARGoS exception with the passed message.
Definition: argos_exception.h:111
REGISTER_ACTUATOR
REGISTER_ACTUATOR(CQuadRotorSpeedDefaultActuator, "quadrotor_speed", "default", "Carlo Pinciroli [ilpincy@gmail.com]", "1.0", "The quadrotor speed actuator.", "This actuator controls the speed of a quadrotor robot. For a\n" "complete description of its usage, refer to the\n" "ci_quadrotor_speed_actuator.h file.\n\n" "REQUIRED XML CONFIGURATION\n\n" " <controllers>\n" " ...\n" " <my_controller ...>\n" " ...\n" " <actuators>\n" " ...\n" " <quadrotor_speed implementation=\"default\" />\n" " ...\n" " </actuators>\n" " ...\n" " </my_controller>\n" " ...\n" " </controllers>\n\n" "OPTIONAL XML CONFIGURATION\n\n" "None for the time being.\n\n", "Usable")
argos::CQuadRotorEntity::SSpeedControlData::Velocity
CVector3 Velocity
Definition: quadrotor_entity.h:39
argos::CQuadRotorSpeedDefaultActuator::CQuadRotorSpeedDefaultActuator
CQuadRotorSpeedDefaultActuator()
Definition: quadrotor_speed_default_actuator.cpp:15
argos::CQuadRotorEntity::NO_CONTROL
@ NO_CONTROL
Definition: quadrotor_entity.h:24
argos::CQuadRotorEntity
Definition: quadrotor_entity.h:15
argos::CQuadRotorSpeedDefaultActuator::Reset
virtual void Reset()
Resets the actuator to the state it had just after Init().
Definition: quadrotor_speed_default_actuator.cpp:79
argos::CQuadRotorSpeedDefaultActuator::SetLinearVelocity
virtual void SetLinearVelocity(const CVector3 &c_velocity)
Sets the linear velocity of the quadrotor.
Definition: quadrotor_speed_default_actuator.cpp:58
argos::CQuadRotorEntity::GetControlMethod
EControlMethod GetControlMethod() const
Definition: quadrotor_entity.h:58
argos::CQuadRotorEntity::SSpeedControlData::RotSpeed
CRadians RotSpeed
Definition: quadrotor_entity.h:40
argos::CQuadRotorEntity::SPEED_CONTROL
@ SPEED_CONTROL
Definition: quadrotor_entity.h:26
argos::CQuadRotorSpeedDefaultActuator::SetRobot
virtual void SetRobot(CComposableEntity &c_entity)
Sets the entity associated to this actuator.
Definition: quadrotor_speed_default_actuator.cpp:22
argos::CCI_Actuator::Init
virtual void Init(TConfigurationNode &t_node)
Initializes the actuator from the XML configuration tree.
Definition: ci_actuator.h:54
argos::CQuadRotorSpeedDefaultActuator::m_pcEmbodiedEntity
CEmbodiedEntity * m_pcEmbodiedEntity
Definition: quadrotor_speed_default_actuator.h:46
argos::CQuadRotorSpeedDefaultActuator::SetRotationalSpeed
virtual void SetRotationalSpeed(const CRadians &c_speed)
Sets the rotational velocity of the quadrotor around the local Z axis (yaw).
Definition: quadrotor_speed_default_actuator.cpp:65
argos::CRadians::ZERO
static const CRadians ZERO
Set to zero radians.
Definition: angles.h:79