ASCO Aerial Autonomy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
land_functors.h
Go to the documentation of this file.
1 #pragma once
7 #include <parsernode/common.h>
8 
14 template <class LogicStateMachineT>
16  : EventAgnosticActionFunctor<UAVSystem, LogicStateMachineT> {
17  void run(UAVSystem &robot_system) {
19  // Need to iterate through enum class HardwareType
20  VLOG(1) << "Aborting UAV Controllers";
21  robot_system.abortController(HardwareType::UAV);
22  VLOG(1) << "Landing";
23  robot_system.land();
24  }
25 };
26 
34 template <class LogicStateMachineT>
36  : InternalActionFunctor<UAVSystem, LogicStateMachineT> {
43  bool run(UAVSystem &robot_system, LogicStateMachineT &logic_state_machine) {
44  parsernode::common::quaddata data = robot_system.getUAVData();
45  // If hardware is not allowing us to control UAV
46  if (data.localpos.z < robot_system.getConfiguration().landing_height()) {
48  VLOG(1) << "Completed Landing";
49  logic_state_machine.process_event(Completed());
50  return false;
51  }
52  return true;
53  }
54 };
55 
61 template <class LogicStateMachineT>
63  : InternalActionFunctor<UAVSystem, LogicStateMachineT> {
70  bool run(UAVSystem &robot_system, LogicStateMachineT &logic_state_machine) {
71  parsernode::common::quaddata data = robot_system.getUAVData();
72  // If hardware is not allowing us to control UAV
73  if (!data.rc_sdk_control_switch) {
74  VLOG(1) << "Switching to Manual UAV state";
75  logic_state_machine.process_event(ManualControlEvent());
76  return false;
77  }
78  return true;
79  }
80 };
81 
87 template <class LogicStateMachineT>
88 using Landing_ = BaseState<UAVSystem, LogicStateMachineT,
95 template <class LogicStateMachineT>
96 using Landed_ = BaseState<UAVSystem, LogicStateMachineT,
Base state for all states in logic state machine.
Definition: base_state.h:24
void abortController(HardwareType hardware_type)
Remove active controller for given hardware type.
Definition: base_robot_system.h:126
Internal action to switch to manual uav state.
Definition: land_functors.h:62
Only aerial vehicle.
Completed Event for transition from for example Landing to Landed etc.
Definition: completed_event.h:6
Internal action that returns whether it processed an event.
Definition: base_functors.h:208
Action functor that does not require the event triggering it.
Definition: base_functors.h:113
Owns, initializes, and facilitates communication between different hardware/software components...
Definition: uav_system.h:21
Internal action to figure out when landing is complete.
Definition: land_functors.h:35
bool run(UAVSystem &robot_system, LogicStateMachineT &logic_state_machine)
Internal function to check when landing is complete.
Definition: land_functors.h:43
parsernode::common::quaddata getUAVData() const
Get sensor data from UAV.
Definition: uav_system.h:109
void land()
Public API call to land.
Definition: uav_system.h:130
void run(UAVSystem &robot_system)
Override this run function for different sub classes. This function performs the logic checking for e...
Definition: land_functors.h:17
UAVSystemConfig getConfiguration()
Get system configuration.
Definition: uav_system.h:192
Transition action when starting to land.
Definition: land_functors.h:15
bool run(UAVSystem &robot_system, LogicStateMachineT &logic_state_machine)
Internal function to switch to manual uav state.
Definition: land_functors.h:70
Event to get into manual control state when UAV leaves SDK mode and enters Manual mode...
Definition: manual_control_event.h:8