ASCO Aerial Autonomy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
uav_vision_system.h
Go to the documentation of this file.
1 #pragma once
7 #include "uav_system_config.pb.h"
8 
9 #include <tf/tf.h>
10 
14 class UAVVisionSystem : public UAVSystem {
15 public:
22  UAVVisionSystem(BaseTracker &tracker, parsernode::Parser &drone_hardware,
23  UAVSystemConfig config)
24  : UAVSystem(drone_hardware, config),
26  config_.uav_vision_system_config().camera_transform())),
27  tracker_(tracker), constant_heading_depth_controller_(
28  config_.uav_vision_system_config()
29  .constant_heading_depth_controller_config()),
30  visual_servoing_drone_connector_(tracker, drone_hardware_,
31  constant_heading_depth_controller_,
34  visual_servoing_drone_connector_);
35  }
36 
45  return visual_servoing_drone_connector_.getTrackingVectorGlobalFrame(pos);
46  }
47 
48  bool initializeTracker() { return tracker_.initialize(); }
49 
50  std::string getSystemStatus() const {
51  std::stringstream status;
52  status << UAVSystem::getSystemStatus() << std::endl;
53  HtmlTableWriter table_writer;
54  table_writer.beginRow();
55  table_writer.addHeader("Tracker Status", Colors::blue);
56  table_writer.beginRow();
57  std::string tracking_valid =
58  (tracker_.trackingIsValid() ? "True" : "False");
59  std::string valid_color =
60  (tracker_.trackingIsValid() ? Colors::green : Colors::red);
61  table_writer.addCell(tracking_valid, "Valid", valid_color);
62  table_writer.beginRow();
63  table_writer.addCell("Tracking Vectors: ");
64  std::unordered_map<uint32_t, Position> tracking_vectors;
65  if (tracker_.getTrackingVectors(tracking_vectors)) {
66  for (auto tv : tracking_vectors) {
67  tf::Vector3 tv_body_frame =
69  tf::Vector3(tv.second.x, tv.second.y, tv.second.z);
70  table_writer.beginRow();
71  table_writer.addCell(tv.first);
72  table_writer.addCell(tv_body_frame.x());
73  table_writer.addCell(tv_body_frame.y());
74  table_writer.addCell(tv_body_frame.z());
75  }
76  }
77  status << table_writer.getTableString();
78  return status.str();
79  }
80 
81 protected:
85  tf::Transform camera_transform_;
86 
87 private:
88  BaseTracker &tracker_;
92  ConstantHeadingDepthController constant_heading_depth_controller_;
97  VisualServoingControllerDroneConnector visual_servoing_drone_connector_;
98 };
static constexpr const char * green
Green color hex code.
Definition: html_utils.h:18
TypeMap< AbstractControllerHardwareConnector > controller_hardware_connector_container_
Container to store and retrieve controller-hardware-connectors.
Definition: base_robot_system.h:23
std::string getSystemStatus() const
Provide the current state of UAV system.
Definition: uav_vision_system.h:50
bool getTrackingVectorGlobalFrame(Position &tracking_vector)
Get the tracking vector of the RoiToPositionConverter in the global frame.
Definition: visual_servoing_controller_drone_connector.cpp:25
std::string getTableString()
Get the html table in string format.
Definition: html_utils.h:170
Interface for classes that provide a vector to a tracked target.
Definition: base_tracker.h:13
parsernode::Parser & drone_hardware_
Hardware.
Definition: uav_system.h:26
Owns, initializes, and facilitates communication between different hardware/software components...
Definition: uav_system.h:21
virtual bool initialize()
Initialze the tracker. Can simply return true if the subclass requires no additional initialization...
Definition: base_tracker.cpp:28
tf::Transform camera_transform_
Camera transform in the frame of the UAV.
Definition: uav_vision_system.h:85
virtual bool getTrackingVectors(std::unordered_map< uint32_t, Position > &pos)=0
Get the tracking vectors.
bool getTrackingVector(Position &pos)
Get the direction vector of the tracking target in the global frame.
Definition: uav_vision_system.h:44
UAVVisionSystem(BaseTracker &tracker, parsernode::Parser &drone_hardware, UAVSystemConfig config)
Constructor.
Definition: uav_vision_system.h:22
A visual servoing controller that uses a tracker output as feedback.
Definition: visual_servoing_controller_drone_connector.h:16
bool initializeTracker()
Definition: uav_vision_system.h:48
static constexpr const char * blue
Blue color hex code.
Definition: html_utils.h:22
A position controller that keeps a constant heading while attempting to keep a certain distance from ...
Definition: constant_heading_depth_controller.h:12
void addCell(const DataT &data, std::string header="", std::string bg_color=Colors::white, int colspan=1)
Add a cell to the table. Should be called after beginning a row. Otherwise will throw an exception...
Definition: html_utils.h:116
std::string getSystemStatus() const
Provide the current state of UAV system.
Definition: uav_system.h:137
tf::Transform getTransformFromVector(const T &input)
Generate a tf transform from a vector of xyzrpy.
Definition: math.h:41
void beginRow()
Begin a new row in the table.
Definition: html_utils.h:135
void addHeader(std::string header, std::string text_color=Colors::black, int colspan=1)
Add a table header. Should be called after beginning a row.
Definition: html_utils.h:152
virtual bool trackingIsValid()=0
Check whether tracking is valid.
UAV system with a camera and visual sevoing capabilities.
Definition: uav_vision_system.h:14
UAVSystemConfig config_
UAV configuration parameters.
Definition: uav_system.h:30
Store 3D position.
Definition: position.h:8
Helper class to write html tables to text format.
Definition: html_utils.h:91
void setObject(ObjectT &object)
Store the object with base class as GenericObjectT.
Definition: type_map.h:27
static constexpr const char * red
Red color hex code.
Definition: html_utils.h:14