Exemplo n.º 1
0
  void CWiFiSensor::SetEntity(CEntity& c_entity) {
    /* Treat the entity as composable */
    CComposableEntity* pcComposableEntity = dynamic_cast<CComposableEntity*>(&c_entity);
    if(pcComposableEntity != NULL) {
      /* The entity is composable, does it have the required component? */
      if(pcComposableEntity->HasComponent("wifi_equipped_entity")) {
	/* Yes, it does */
	m_pcWiFiEquippedEntity = &(pcComposableEntity->GetComponent<CWiFiEquippedEntity>("wifi_equipped_entity"));
	m_pcEntity = &c_entity;
      }
      else {
	/* No, error */
	THROW_ARGOSEXCEPTION("Cannot associate a wifi sensor to an entity of type \"" << c_entity.GetTypeDescription() << "\"");
      }
    }
  }
Exemplo n.º 2
0
 void CEPuckRangeAndBearingSensor::SetEntity(CEntity& c_entity) {
    /* Treat the entity as composable */
    CComposableEntity* pcComposableEntity = dynamic_cast<CComposableEntity*>(&c_entity);
    if(pcComposableEntity != NULL) {
       /* The entity is composable, does it have the required components? */
       if(pcComposableEntity->HasComponent("rab_equipped_entity<2>") &&
          pcComposableEntity->HasComponent("embodied_entity") &&
          pcComposableEntity->HasComponent("controllable_entity")) {
          /* Yes, it does */
          m_pcRABEquippedEntity = &(pcComposableEntity->GetComponent< CRABEquippedEntity<2> >("rab_equipped_entity<2>"));
          m_pcEmbodiedEntity = &(pcComposableEntity->GetComponent<CEmbodiedEntity>("embodied_entity"));
          m_pcControllableEntity = &(pcComposableEntity->GetComponent<CControllableEntity>("controllable_entity"));
          m_pcEntity = &c_entity;
       }
       else {
          /* No, error */
          THROW_ARGOSEXCEPTION("Cannot associate a range and bearing sensor to an entity of type \"" << c_entity.GetTypeDescription() << "\"");
       }
    }
 }
 void CQuadRotorSpeedDefaultActuator::SetRobot(CComposableEntity& c_entity) {
    try {
       /* Get the quadrotor component */
       m_pcQuadRotorEntity = &(c_entity.GetComponent<CQuadRotorEntity>("quadrotor"));
       /* Check whether the control methods is unset - only one is allowed */
       if(m_pcQuadRotorEntity->GetControlMethod() == CQuadRotorEntity::NO_CONTROL) {
          /* Get the robot body */
          m_pcEmbodiedEntity = &(c_entity.GetComponent<CEmbodiedEntity>("body"));
          /* Set the speed control method */
          m_pcQuadRotorEntity->SetControlMethod(CQuadRotorEntity::SPEED_CONTROL);
       }
       else {
          THROW_ARGOSEXCEPTION("Can't associate a quadrotor speed actuator to entity \"" << c_entity.GetId() << "\" because it conflicts with a previously associated quadrotor actuator.");
       }
    }
    catch(CARGoSException& ex) {
       THROW_ARGOSEXCEPTION_NESTED("Error setting quadrotor speed actuator to entity \"" << c_entity.GetId() << "\"", ex);
    }
 }