Program Listing for File tello.hpp

Return to documentation for file (inc/tello.hpp)

#ifndef TELLO_HPP
#define TELLO_HPP

#include  <memory>

#include "command_socket.hpp"
#include "video_socket.hpp"
#include "state_socket.hpp"
#include "joystick.hpp"
#include "utils.hpp"

#ifdef USE_TERMINAL
#include "command_terminal.hpp"
#endif

class Tello{
public:
  Tello(asio::io_service& io_service,
        std::condition_variable& cv_run,
        const std::string drone_ip = "192.168.10.1",
        const std::string local_drone_port = "8889",
        const std::string local_video_port = "11111",
        const std::string local_state_port = "8890",
        const std::string camera_config_file = "../camera_config.yaml",
        const std::string vocabulary_file = "../orb_vocab.dbow2",
        const int n_retries = 0,
        const int timeout = 5,
        const std::string load_map_db_path = "",
        const std::string save_map_db_path = "",
        const std::string mask_img_path = "",
        bool load_map = false,
        bool continue_mapping = false,
        float scale = 1.0,
        const std::string sequence_file = ""
      );

  void readSequence(const std::string& file);

  ~Tello();

  // TODO: Move to private

  std::unique_ptr<CommandSocket> cs;

  std::unique_ptr<Joystick> js_;

  std::unique_ptr<VideoSocket> vs;

  std::unique_ptr<StateSocket> ss;

private:

  asio::io_service& io_service_;
  std::thread js_thread_;
  std::condition_variable& cv_run_;
  void jsToCommandThread();
  void jsToCommand(ButtonId update);
  void jsToCommand(AxisId update);
  bool run_ = true;

#ifdef USE_TERMINAL
  std::unique_ptr<Terminal> term_;
  std::thread term_thread_worker_, term_thread_fetch_;
  void terminalToCommandThread();
  void terminalToCommand(const std::string& cmd);
#endif // TERMINAL
};

#endif // TELLO_HPP