//
// Created by zx on 2019/12/9.
//

#ifndef REGION_WORKER_H
#define REGION_WORKER_H

#include "region_detect.h"
#include "StdCondition.h"
#include <thread>
#include <mutex>
#include <iostream>
#include "define.h"

class Region_worker{
public:
    Region_worker(int id, EleFence::Region region);
    ~Region_worker();
    void update_cloud(pcl::PointCloud<pcl::PointXYZ>::Ptr &cloud_in);
    static void detect_loop(Region_worker* worker);
    int get_id();
    bool get_wheel_result(pcl::PointCloud<pcl::PointXYZ>::Ptr &cloud_in, double &x, double &y, double &c, double &wheelbase, double &width);

private:
    Region_detector*                                m_detector;
    pcl::PointCloud<pcl::PointXYZ>::Ptr             m_cloud;
    bool                                            b_cloud_updated;

    StdCondition                                    m_cond_exit;
    std::thread*                                    m_update_thread;
    std::mutex                                      m_mutex;
};

#endif //REGION_WORKER_H
