ASCO Aerial Autonomy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
position_control_functors.h
Go to the documentation of this file.
1 #pragma once
8 #include <aerial_autonomy/uav_basic_events.h>
9 #include <glog/logging.h>
10 #include <parsernode/common.h>
11 
12 namespace be = uav_basic_events;
13 
19 template <class LogicStateMachineT>
21  : ActionFunctor<PositionYaw, UAVSystem, LogicStateMachineT> {
22  void run(const PositionYaw &goal, UAVSystem &robot_system) {
24  }
25 };
26 
32 template <class LogicStateMachineT>
34  : EventAgnosticActionFunctor<UAVSystem, LogicStateMachineT> {
35  void run(UAVSystem &robot_system) {
36  LOG(WARNING) << "Aborting UAV Controller";
37  robot_system.abortController(HardwareType::UAV);
38  }
39 };
40 
47 template <class LogicStateMachineT>
49  : GuardFunctor<PositionYaw, UAVSystem, LogicStateMachineT> {
50  bool guard(const PositionYaw &goal, UAVSystem &robot_system) {
51  parsernode::common::quaddata data = robot_system.getUAVData();
52  geometry_msgs::Vector3 current_position = data.localpos;
53  // Check goal is close to position before sending goal (Can use a geofence
54  // here)
55  const double &tolerance_pos =
56  robot_system.getConfiguration().max_goal_distance();
57  bool result = true;
58  if (std::abs(current_position.x - goal.x) > tolerance_pos ||
59  std::abs(current_position.y - goal.y) > tolerance_pos ||
60  std::abs(current_position.z - goal.z) > tolerance_pos) {
61  LOG(WARNING) << "Goal not within the position tolerance";
62  result = false;
63  }
64  return result;
65  }
66 };
67 
73 template <class LogicStateMachineT>
78  LogicStateMachineT, PositionControllerDroneConnector>>>;
79 
85 template <class LogicStateMachineT>
86 using ReachingGoal_ =
87  BaseState<UAVSystem, LogicStateMachineT,
Logic to abort if controller status is critical.
Definition: hovering_functors.h:57
double y
y component in m
Definition: position.h:23
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
Only aerial vehicle.
Transition action to perform when going into position control mode.
Definition: position_control_functors.h:20
double x
x component in m
Definition: position.h:22
Stores Position, yaw. PositionYaw is used as the goal for UAV systems.
Definition: position_yaw.h:10
bool guard(const PositionYaw &goal, UAVSystem &robot_system)
Override this guard function for different sub classes. This function decides whether to call the run...
Definition: position_control_functors.h:50
void run(UAVSystem &robot_system)
Override this run function for different sub classes. This function performs the logic checking for e...
Definition: position_control_functors.h:35
Action functor that does not require the event triggering it.
Definition: base_functors.h:113
void setGoal(GoalT goal)
sets goal to the connector and swaps the active connector with the specified connector type...
Definition: base_robot_system.h:59
Owns, initializes, and facilitates communication between different hardware/software components...
Definition: uav_system.h:21
Action Functor for a given event, robot system, state machine.
Definition: base_functors.h:68
Action Functor for a given event, robot system, state machine.
Definition: base_functors.h:20
Manages communication between a drone plugin and a position controller that outputs position commands...
Definition: position_controller_drone_connector.h:14
parsernode::common::quaddata getUAVData() const
Get sensor data from UAV.
Definition: uav_system.h:109
void run(const PositionYaw &goal, UAVSystem &robot_system)
Override this run function for different sub classes. This function performs the logic checking for e...
Definition: position_control_functors.h:22
Internal action when hovering.
Definition: hovering_functors.h:21
double z
z component in m
Definition: position.h:24
UAVSystemConfig getConfiguration()
Get system configuration.
Definition: uav_system.h:192
Action sequence that runs until one of the actions returns false.
Definition: shorting_action_sequence.h:46
Transition action to perform when aborting any UAV Controller.
Definition: position_control_functors.h:33
Guard function to check the goal is within tolerance before starting towards goal.
Definition: position_control_functors.h:48