11#ifndef INCLUDE_WEBGUI_HPP_
22#define INCLUDE_WEBGUI_HPP_
33
4- #include < boost/beast/core.hpp>
5- #include < boost/beast/websocket.hpp>
6- #include < boost/asio/connect.hpp>
7- #include < boost/asio/ip/tcp.hpp>
8- #include < boost/asio/strand.hpp>
9- #include < nlohmann/json.hpp>
104#include < opencv2/opencv.hpp>
11- #include < mutex >
5+ #include < vector >
126#include < memory>
137#include < string>
14- #include < vector>
15- #include " rclcpp/rclcpp.hpp"
16- #include " geometry_msgs/msg/point.hpp"
17- #include " nav_msgs/msg/path.hpp"
18- #include " sensor_msgs/msg/image.hpp"
19- #include " common_interfaces_cpp/hal/odometry.hpp"
20- #include " Map.hpp"
8+ #include < thread>
219
22- namespace beast = boost::beast;
23- namespace websocket = beast::websocket;
24- namespace net = boost::asio;
25- using tcp = net::ip::tcp;
26- using json = nlohmann::json;
10+ class WebGUINode ;
11+ namespace rclcpp ::executors { class MultiThreadedExecutor ; }
2712
2813class WebGUI
2914{
3015public:
31- WebGUI ();
32-
33- static void showNumpy (const cv::Mat& image);
34- static void showPath (const std::vector<std::vector<int >>& array);
35- static std::vector<double > getTargetPose ();
36- static cv::Mat getMap (const std::string& url);
37- static std::vector<int > rowColumn (const std::vector<double >& pose);
38- static std::vector<int > worldToGrid (const std::vector<double >& pose);
39- static std::vector<double > gridToWorld (const std::vector<int >& cell);
40- static void reset_gui ();
41- static std::string payloadImage ();
42-
43- static std::vector<double > worldXY;
44- static std::string array_str;
45-
46- private:
47- static cv::Mat image_to_be_shown;
48- static bool image_to_be_shown_updated;
49- static std::mutex image_show_lock;
50- static std::mutex array_lock;
51- };
16+ WebGUI () = delete ;
5217
53- class WebGUINode : public rclcpp ::Node
54- {
55- public:
56- WebGUINode ();
57-
58- static std::shared_ptr<Map> map_;
59- static std::shared_ptr<OdometryNode> pose3d_node_;
60-
61- static void publish_target (double x, double y);
18+ static void show_image (const cv::Mat& image);
19+ static void show_path (const std::vector<std::vector<int >>& path);
20+ static std::vector<double > get_target_pose ();
21+ static cv::Mat get_map (const std::string& url);
22+ static std::vector<int > world_to_grid (const std::vector<double >& pose);
23+ static std::vector<double > grid_to_world (const std::vector<double >& cell);
6224
6325private:
64- void path_callback (nav_msgs::msg::Path::UniquePtr msg);
65- void image_callback (sensor_msgs::msg::Image::UniquePtr msg);
66-
67- rclcpp::Subscription<nav_msgs::msg::Path>::SharedPtr path_sub_;
68- rclcpp::Subscription<sensor_msgs::msg::Image>::SharedPtr image_sub_;
26+ static void init ();
27+ friend class SystemBootstrapper ;
6928
70- static std::shared_ptr<rclcpp::Publisher<geometry_msgs::msg::Point>> target_pub_;
29+ static std::shared_ptr<WebGUINode> gui_node_;
30+ static std::shared_ptr<rclcpp::executors::MultiThreadedExecutor> executor_;
31+ static std::thread spin_thread_;
7132};
7233
7334#endif
0 commit comments