mqttmsg.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //
  2. // Created by zx on 23-2-22.
  3. //
  4. #ifndef PAHOC_SAMPLE_SAMPLES_DEVICE_MSG_H_
  5. #define PAHOC_SAMPLE_SAMPLES_DEVICE_MSG_H_
  6. #include "message.pb.h"
  7. #include <mutex>
  8. class MqttMsg
  9. {
  10. public:
  11. enum Dtype
  12. {
  13. ePointCloudXYZ,
  14. ePointCloudXYZI,
  15. eString,
  16. eImage,
  17. eAGVStatu,
  18. eAGVSpeed
  19. };
  20. public:
  21. MqttMsg();
  22. MqttMsg(char* data,const int length);
  23. MqttMsg(const MqttMsg& msg);
  24. MqttMsg& operator=(const MqttMsg& msg);
  25. ~MqttMsg();
  26. char* data()const;
  27. int length()const;
  28. void fromStatu(double x,double y,double theta,double v,double vth);
  29. void fromSpeed(double v,double vth);
  30. void fromNavCmd(const NavCmd& cmd);
  31. void fromNavStatu(const NavStatu& statu);
  32. bool toStatu(double& x,double& y,double& theta,double& v,double& vth);
  33. bool toSpeed(double& v,double& vth);
  34. bool toNavCmd(NavCmd& cmd);
  35. bool toNavStatu(NavStatu& statu);
  36. protected:
  37. char* data_=nullptr;
  38. int length_=0;
  39. std::mutex mutex_;
  40. };
  41. #endif //PAHOC_SAMPLE_SAMPLES_DEVICE_MSG_H_