ASCO Aerial Autonomy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
arm_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 
10 namespace be = uav_basic_events;
11 
17 template <class LogicStateMachineT>
19  : EventAgnosticActionFunctor<ArmSystem, LogicStateMachineT> {
20  void run(ArmSystem &robot_system) {
21  VLOG(1) << "Folding Arm!";
22  robot_system.foldArm();
23  }
24 };
25 
31 template <class LogicStateMachineT>
33  : EventAgnosticActionFunctor<ArmSystem, LogicStateMachineT> {
34  void run(ArmSystem &robot_system) {
35  VLOG(1) << "Folding Arm to right angle!";
36  robot_system.rightArm();
37  }
38 };
39 
45 template <class LogicStateMachineT>
47  : EventAgnosticActionFunctor<ArmSystem, LogicStateMachineT> {
48  void run(ArmSystem &robot_system) {
49  VLOG(1) << "Powering off Arm!";
50  robot_system.power(false);
51  }
52 };
53 
59 template <class LogicStateMachineT>
61  : EventAgnosticActionFunctor<ArmSystem, LogicStateMachineT> {
62  void run(ArmSystem &robot_system) {
63  VLOG(1) << "Powering on Arm!";
64  robot_system.power(true);
65  }
66 };
67 
73 template <class LogicStateMachineT>
75  : EventAgnosticGuardFunctor<ArmSystem, LogicStateMachineT> {
76  bool guard(ArmSystem &robot_system_) {
77  if (!robot_system_.enabled()) {
78  LOG(WARNING) << "Robot system not enabled!";
79  return false;
80  }
81  return true;
82  }
83 };
84 
90 template <class LogicStateMachineT>
92  : EventAgnosticActionFunctor<ArmSystem, LogicStateMachineT> {
93  void run(ArmSystem &robot_system) {
94  LOG(WARNING) << "Aborting arm controller";
95  robot_system.abortController(HardwareType::Arm);
96  }
97 };
98 
108 template <class LogicStateMachineT>
110  : InternalActionFunctor<ArmSystem, LogicStateMachineT> {
111  bool run(ArmSystem &robot_system, LogicStateMachineT &logic_state_machine) {
112  // Check if arm finally powered on
113  if (!robot_system.enabled()) {
114  LOG(WARNING) << "Arm not enabled! Aborting!";
115  logic_state_machine.process_event(be::Abort());
116  return false;
117  }
118  return true;
119  }
120 };
126 template <class LogicStateMachineT>
128  : InternalActionFunctor<ArmSystem, LogicStateMachineT> {
136  bool run(ArmSystem &robot_system, LogicStateMachineT &logic_state_machine) {
137  if (robot_system.getCommandStatus()) {
138  VLOG(1) << "Completed Folding arm!";
139  logic_state_machine.process_event(Completed());
140  return false;
141  } else if (!robot_system.enabled()) {
142  LOG(WARNING) << "Arm not enabled!";
143  logic_state_machine.process_event(be::Abort());
144  return false;
145  }
146  return true;
147  }
148 };
149 
155 template <class LogicStateMachineT>
156 using ArmFolding_ =
157  BaseState<ArmSystem, LogicStateMachineT,
164 template <class LogicStateMachineT>
165 class ArmPreTakeoffFolding_ : public ArmFolding_<LogicStateMachineT> {};
171 template <class LogicStateMachineT>
172 class ArmPreLandingFolding_ : public ArmFolding_<LogicStateMachineT> {};
Power on the arm.
Definition: arm_functors.h:60
void run(ArmSystem &robot_system)
Override this run function for different sub classes. This function performs the logic checking for e...
Definition: arm_functors.h:20
Abort arm controller.
Definition: arm_functors.h:91
void run(ArmSystem &robot_system)
Override this run function for different sub classes. This function performs the logic checking for e...
Definition: arm_functors.h:93
Base state for all states in logic state machine.
Definition: base_state.h:24
bool run(ArmSystem &robot_system, LogicStateMachineT &logic_state_machine)
Function to check when folding arm is complete. If arm is not enabled, then abort.
Definition: arm_functors.h:136
action to fold arm
Definition: arm_functors.h:18
void abortController(HardwareType hardware_type)
Remove active controller for given hardware type.
Definition: base_robot_system.h:126
Check when folding arm is complete.
Definition: arm_functors.h:127
void foldArm()
Set the arm joints to a known folded configuration.
Definition: arm_system.h:79
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
bool run(ArmSystem &robot_system, LogicStateMachineT &logic_state_machine)
Override this run function for different sub classes. This function performs the logic checking for e...
Definition: arm_functors.h:111
Action functor that does not require the event triggering it.
Definition: base_functors.h:113
action to move arm to right angle
Definition: arm_functors.h:32
bool guard(ArmSystem &robot_system_)
Override this run function for different sub classes. This function performs the logic checking for e...
Definition: arm_functors.h:76
Power off arm.
Definition: arm_functors.h:46
void run(ArmSystem &robot_system)
Override this run function for different sub classes. This function performs the logic checking for e...
Definition: arm_functors.h:62
action for checking arm status.
Definition: arm_functors.h:109
bool getCommandStatus() const
Verify the status of grip/power on/off and fold/rightArm commands.
Definition: arm_system.h:138
bool enabled() const
If arm is enabled return.
Definition: arm_system.h:145
void run(ArmSystem &robot_system)
Override this run function for different sub classes. This function performs the logic checking for e...
Definition: arm_functors.h:34
Same state as above. Used to distinguish between landing and takeoff.
Definition: arm_functors.h:165
void run(ArmSystem &robot_system)
Override this run function for different sub classes. This function performs the logic checking for e...
Definition: arm_functors.h:48
void rightArm()
Set the arm joints to a known L shaped configuration.
Definition: arm_system.h:84
Guard functor that does not require the event triggering it.
Definition: base_functors.h:157
Owns, initializes, and facilitates communication between different hardware/software components...
Definition: arm_system.h:18
Same state as above. Used to distinguish between landing and takeoff.
Definition: arm_functors.h:172
void power(bool state)
Power the arm on/off.
Definition: arm_system.h:68
Check arm is enabled before picking objects.
Definition: arm_functors.h:74