rslidar_mqtt_async.h 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. #pragma once
  2. #include "pahoc/mqtt_async.h"
  3. #include "message/unpacket.hpp"
  4. #include <pcl/point_types.h>
  5. #include <pcl/point_cloud.h>
  6. class RslidarMqttAsyncClient : public MqttAsyncClient {
  7. public:
  8. RslidarMqttAsyncClient() = default;
  9. void init();
  10. bool setCloudData(const std::string &topic, pcl::PointCloud<pcl::PointALL>::Ptr &cloud);
  11. bool getCloudData(const std::string &topic, pcl::PointCloud<pcl::PointXYZI>::Ptr &cloud);
  12. bool getCloudData(const std::string &topic, pcl::PointCloud<pcl::PointXYZ>::Ptr &cloud);
  13. bool getCloudData(const std::string &topic, pcl::PointCloud<pcl::PointXYZRGB>::Ptr &cloud, const uint8_t *color);
  14. private:
  15. static int CloudDataArrived(MqttAsyncClient *client, char *topicName, int topicLen, MQTTAsync_message *message);
  16. public:
  17. private:
  18. std::mutex m_cloud_mutex;
  19. std::map<std::string, int> m_topics_;
  20. std::map<std::string, pcl::PointCloud<pcl::PointALL>::Ptr> m_cloud_;
  21. std::map<std::string, pcl::PointCloud<pcl::PointALL>::Ptr> m_full_cloud_;
  22. std::map<std::string, std::chrono::steady_clock::time_point> m_topic_time_;
  23. };