ASCO Aerial Autonomy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
uav_system_handler.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <ros/ros.h>
4 
5 #include <parsernode/parser.h>
6 #include <pluginlib/class_loader.h>
7 
11 
12 #include "uav_system_handler_config.pb.h"
13 
22 template <class LogicStateMachineT, class EventManagerT>
24 public:
30  UAVSystemHandler(UAVSystemHandlerConfig &config)
31  : nh_uav_("~uav"), parser_loader_("parsernode", "parsernode::Parser"),
32  uav_hardware_(
33  parser_loader_.createUnmanagedInstance(config.uav_parser_type())),
34  uav_system_(*uav_hardware_, config.uav_system_config()),
35  common_handler_(config.base_config(), uav_system_),
36  uav_controller_timer_(
37  std::bind(&UAVSystem::runActiveController, std::ref(uav_system_),
38  HardwareType::UAV),
39  std::chrono::milliseconds(config.uav_controller_timer_duration())) {
40  // Initialize UAV plugin
41  uav_hardware_->initialize(nh_uav_);
42 
43  // Get the party started
44  common_handler_.startTimers();
45  uav_controller_timer_.start();
46  }
47 
51  UAVSystemHandler(const UAVSystemHandler &) = delete;
52 
57  parsernode::common::quaddata getUAVData() {
58  parsernode::common::quaddata quad_data;
59  uav_hardware_->getquaddata(quad_data);
60  return quad_data;
61  }
62 
69  bool isConnected() { return common_handler_.isConnected(); }
70 
71 private:
72  ros::NodeHandle nh_uav_;
73  pluginlib::ClassLoader<parsernode::Parser>
74  parser_loader_;
75  std::unique_ptr<parsernode::Parser> uav_hardware_;
76  UAVSystem uav_system_;
78  common_handler_;
79  AsyncTimer uav_controller_timer_;
81 };
Only aerial vehicle.
bool isConnected()
Forward common handler connected function for testing is GUI is connected to this node or not...
Definition: uav_system_handler.h:69
void start()
Starts running the timer thread.
Definition: async_timer.cpp:16
parsernode::common::quaddata getUAVData()
Get UAV state.
Definition: uav_system_handler.h:57
Owns, initializes, and facilitates communication between different hardware/software components...
Definition: uav_system.h:21
void startTimers()
Start state machine internal event processing and status timer.
Definition: common_system_handler.h:70
Calls given function on a timer in its own thread.
Definition: async_timer.h:11
Owns all of the autonomous system components and is responsible for thread management. Also owns a common system handler object to handle creation of state machine and connecting it to GUI.
Definition: uav_system_handler.h:23
bool isConnected()
Checks if internal ROS topics are connected.
Definition: common_system_handler.h:62
UAVSystemHandler(UAVSystemHandlerConfig &config)
Constructor.
Definition: uav_system_handler.h:30
HardwareType
Type of hardware used by ControllerHardwareConnector. Enum ID must be contiguous. ...
Definition: base_controller_hardware_connector.h:11