ASCO Aerial Autonomy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
takeoff_functors.h
Go to the documentation of this file.
1 #pragma once
6 #include <aerial_autonomy/uav_basic_events.h>
7 #include <glog/logging.h>
8 #include <parsernode/common.h>
9 
15 template <class LogicStateMachineT>
17  : EventAgnosticActionFunctor<UAVSystem, LogicStateMachineT> {
18  void run(UAVSystem &robot_system) {
19  VLOG(1) << "Takingoff!";
20  robot_system.takeOff();
21  }
22 };
23 
29 template <class LogicStateMachineT>
31  : EventAgnosticActionFunctor<UAVSystem, LogicStateMachineT> {
32  void run(UAVSystem &robot_system) {
33  VLOG(1) << "Aborting Takeoff!";
34  robot_system.land();
35  }
36 };
37 
43 template <class LogicStateMachineT>
45  : EventAgnosticGuardFunctor<UAVSystem, LogicStateMachineT> {
46  bool guard(UAVSystem &robot_system) {
47  parsernode::common::quaddata data = robot_system.getUAVData();
48  bool result = false;
49  // Check for voltage
50  if (data.batterypercent >
51  robot_system.getConfiguration().minimum_battery_percent()) {
52  result = true;
53  } else {
54  LOG(WARNING) << "Battery too low! " << data.batterypercent
55  << "\% SoCannot takeoff";
56  }
57  return result;
58  }
59 };
60 
66 template <class LogicStateMachineT>
68  : InternalActionFunctor<UAVSystem, LogicStateMachineT> {
76  bool run(UAVSystem &robot_system, LogicStateMachineT &logic_state_machine) {
77  parsernode::common::quaddata data = robot_system.getUAVData();
78  // If hardware is not allowing us to control UAV
79  if (data.localpos.z >=
80  // Transition to hovering state once reached high altitude
81  robot_system.getConfiguration().minimum_takeoff_height()) {
82  VLOG(1) << "Completed Takeoff";
83  logic_state_machine.process_event(Completed());
84  return false;
85  }
86  return true;
87  }
88 };
89 
95 template <class LogicStateMachineT>
96 using TakingOff_ = BaseState<UAVSystem, LogicStateMachineT,
Base state for all states in logic state machine.
Definition: base_state.h:24
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
void run(UAVSystem &robot_system)
Override this run function for different sub classes. This function performs the logic checking for e...
Definition: takeoff_functors.h:32
Check when takeoff is complete, and ensure enough battery voltage.
Definition: takeoff_functors.h:67
void takeOff()
Public API call to takeoff.
Definition: uav_system.h:118
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
Guard to avoid accidental takeoff.
Definition: takeoff_functors.h:44
void run(UAVSystem &robot_system)
Override this run function for different sub classes. This function performs the logic checking for e...
Definition: takeoff_functors.h:18
Guard functor that does not require the event triggering it.
Definition: base_functors.h:157
UAVSystemConfig getConfiguration()
Get system configuration.
Definition: uav_system.h:192
action to perform when aborting takeoff
Definition: takeoff_functors.h:30
action to take when starting takeoff
Definition: takeoff_functors.h:16
bool guard(UAVSystem &robot_system)
Override this run function for different sub classes. This function performs the logic checking for e...
Definition: takeoff_functors.h:46
bool run(UAVSystem &robot_system, LogicStateMachineT &logic_state_machine)
Function to check when takeoff is complete. If battery is low while takeoff, trigger Land event...
Definition: takeoff_functors.h:76