ASCO Aerial Autonomy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
uav_vision_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 
13 
14 #include "uav_system_handler_config.pb.h"
15 
24 template <class LogicStateMachineT, class EventManagerT>
26 public:
32  UAVVisionSystemHandler(UAVSystemHandlerConfig &config)
33  : nh_uav_("~uav"), nh_tracker_("~tracker"),
34  parser_loader_("parsernode", "parsernode::Parser"),
35  uav_hardware_(
36  parser_loader_.createUnmanagedInstance(config.uav_parser_type())),
37  tracker_(
38  config.uav_system_config()
39  .uav_vision_system_config()
40  .tracker_type() == "ROI"
41  ? dynamic_cast<BaseTracker *>(
42  new RoiToPositionConverter(nh_tracker_))
43  : dynamic_cast<BaseTracker *>(new AlvarTracker(nh_tracker_))),
44  uav_system_(*tracker_, *uav_hardware_, config.uav_system_config()),
45  common_handler_(config.base_config(), uav_system_),
46  uav_controller_timer_(
47  std::bind(&UAVVisionSystem::runActiveController,
48  std::ref(uav_system_), HardwareType::UAV),
49  std::chrono::milliseconds(config.uav_controller_timer_duration())) {
50  // Initialize UAV plugin
51  uav_hardware_->initialize(nh_uav_);
52 
53  // Get the party started
54  common_handler_.startTimers();
55  uav_controller_timer_.start();
56  }
57 
62 
67  parsernode::common::quaddata getUAVData() {
68  parsernode::common::quaddata quad_data;
69  uav_hardware_->getquaddata(quad_data);
70  return quad_data;
71  }
72 
79  bool isConnected() { return common_handler_.isConnected(); }
80 
81 private:
82  ros::NodeHandle nh_uav_;
83  ros::NodeHandle nh_tracker_;
84  pluginlib::ClassLoader<parsernode::Parser>
85  parser_loader_;
86  std::unique_ptr<parsernode::Parser> uav_hardware_;
87  std::unique_ptr<BaseTracker> tracker_;
88  UAVVisionSystem uav_system_;
90  common_handler_;
91  AsyncTimer uav_controller_timer_;
93 };
Only aerial vehicle.
Converts a ROI in image to vector in camera frame.
Definition: roi_to_position_converter.h:25
Interface for classes that provide a vector to a tracked target.
Definition: base_tracker.h:13
bool isConnected()
Forward common handler connected function for testing is GUI is connected to this node or not...
Definition: uav_vision_system_handler.h:79
void start()
Starts running the timer thread.
Definition: async_timer.cpp:16
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_vision_system_handler.h:25
bool isConnected()
Checks if internal ROS topics are connected.
Definition: common_system_handler.h:62
UAVVisionSystemHandler(UAVSystemHandlerConfig &config)
Constructor.
Definition: uav_vision_system_handler.h:32
Provides vector to a tracked object based on output from alvar.
Definition: alvar_tracker.h:13
UAV system with a camera and visual sevoing capabilities.
Definition: uav_vision_system.h:14
HardwareType
Type of hardware used by ControllerHardwareConnector. Enum ID must be contiguous. ...
Definition: base_controller_hardware_connector.h:11
parsernode::common::quaddata getUAVData()
Get UAV state.
Definition: uav_vision_system_handler.h:67