ARGoS
3
A parallel, multi-engine simulator for swarm robotics
|
00001 00007 #include "footbot_turret_default_actuator.h" 00008 00009 namespace argos { 00010 00011 const Real RPM_TO_RADIANS_PER_SEC = ARGOS_PI / 30.0f; 00012 00013 /****************************************/ 00014 /****************************************/ 00015 00016 CFootBotTurretDefaultActuator::CFootBotTurretDefaultActuator() : 00017 m_fDesiredRotationSpeed(0.0f), 00018 m_unDesiredMode(CFootBotTurretEntity::MODE_OFF) {} 00019 00020 /****************************************/ 00021 /****************************************/ 00022 00023 void CFootBotTurretDefaultActuator::SetRobot(CComposableEntity& c_entity) { 00024 m_pcTurretEntity = &(c_entity.GetComponent<CFootBotTurretEntity>("turret")); 00025 m_pcTurretEntity->SetCanBeEnabledIfDisabled(true); 00026 m_pcTurretEntity->Enable(); 00027 } 00028 00029 /****************************************/ 00030 /****************************************/ 00031 00032 void CFootBotTurretDefaultActuator::SetRotation(const CRadians& c_angle) { 00033 m_cDesiredRotation = c_angle; 00034 } 00035 00036 /****************************************/ 00037 /****************************************/ 00038 00039 void CFootBotTurretDefaultActuator::SetRotationSpeed(SInt32 n_speed_pulses) { 00040 m_fDesiredRotationSpeed = RPM_TO_RADIANS_PER_SEC * n_speed_pulses; 00041 } 00042 00043 /****************************************/ 00044 /****************************************/ 00045 00046 void CFootBotTurretDefaultActuator::SetMode(ETurretModes e_mode) { 00047 m_unDesiredMode = e_mode; 00048 } 00049 00050 /****************************************/ 00051 /****************************************/ 00052 00053 void CFootBotTurretDefaultActuator::Update() { 00054 m_pcTurretEntity->SetMode(m_unDesiredMode); 00055 if(m_unDesiredMode == CFootBotTurretEntity::MODE_POSITION_CONTROL) { 00056 m_pcTurretEntity->SetRotation(m_cDesiredRotation); 00057 } 00058 else if(m_unDesiredMode == CFootBotTurretEntity::MODE_SPEED_CONTROL) { 00059 m_pcTurretEntity->SetRotationSpeed(m_fDesiredRotationSpeed); 00060 } 00061 } 00062 00063 /****************************************/ 00064 /****************************************/ 00065 00066 void CFootBotTurretDefaultActuator::Reset() { 00067 m_cDesiredRotation = CRadians::ZERO; 00068 m_fDesiredRotationSpeed = 0.0f; 00069 m_unDesiredMode = CFootBotTurretEntity::MODE_OFF; 00070 } 00071 00072 /****************************************/ 00073 /****************************************/ 00074 00075 REGISTER_ACTUATOR(CFootBotTurretDefaultActuator, 00076 "footbot_turret", "default", 00077 "Carlo Pinciroli [ilpincy@gmail.com]", 00078 "1.0", 00079 "The foot-bot turret actuator.", 00080 "This actuator controls the foot-bot turret. For a complete\n" 00081 "description of its usage, refer to the ci_footbot_turret_actuator\n" 00082 "file.\n\n" 00083 "REQUIRED XML CONFIGURATION\n\n" 00084 " <controllers>\n" 00085 " ...\n" 00086 " <my_controller ...>\n" 00087 " ...\n" 00088 " <actuators>\n" 00089 " ...\n" 00090 " <footbot_turret implementation=\"default\" />\n" 00091 " ...\n" 00092 " </actuators>\n" 00093 " ...\n" 00094 " </my_controller>\n" 00095 " ...\n" 00096 " </controllers>\n\n" 00097 "OPTIONAL XML CONFIGURATION\n\n" 00098 "None for the time being.\n", 00099 "Usable" 00100 ); 00101 00102 }