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

#ifndef LIDAR_H
#define LIDAR_H
#include <ros/ros.h>
#include "EleFence.pb.h"
#include <string>
#include <pcl_conversions/pcl_conversions.h>
#include <pcl/point_types.h>
#include <pcl/PCLPointCloud2.h>
#include <pcl/conversions.h>
#include <pcl_ros/transforms.h>
#include <pcl/filters/passthrough.h>

#include <sensor_msgs/PointCloud2.h>
#include <sensor_msgs/LaserScan.h>

class Lidar
{
public:
    Lidar(EleFence::lidarParam lidar_param, ros::NodeHandle handle);
    ~Lidar();
    bool GetCloud(pcl::PointCloud<pcl::PointXYZ>::Ptr& cloud, int timeout_milli=100);

protected:
    static void cloud_callback(const sensor_msgs::LaserScan::ConstPtr& msg,Lidar* pLidar);

protected:
    ros::NodeHandle m_handle;
    pcl::PointCloud<pcl::PointXYZ>::Ptr m_cloud;
    ros::Time   m_cloud_time;

    ros::Subscriber m_scan_sub;
    EleFence::lidarParam m_lidar_param;

    bool                b_save_cloud;
};


#endif //LIDAR_H
