RobotMonitorNode.h 844 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. //
  2. // Created by zx on 23-3-14.
  3. //
  4. #ifndef SOCKETIO__ROBOTMONITORNODE_H_
  5. #define SOCKETIO__ROBOTMONITORNODE_H_
  6. #include <string>
  7. #include <thread>
  8. #include "emqx-client/paho_client.h"
  9. #include "pose2d.h"
  10. #include <functional>
  11. class RobotMonitorNode
  12. {
  13. public:
  14. RobotMonitorNode(std::string nodeId,std::string pubTopic,std::string subTopic);
  15. virtual ~RobotMonitorNode();
  16. bool Connect(std::string ip,int port);
  17. protected:
  18. void update();
  19. void ChangeSpeed(double v ,double vth);
  20. static void SpeedChangeCallback(std::string topic,int QOS,MqttMsg& msg,void* context);
  21. protected:
  22. Paho_client* client_;
  23. bool exit_;
  24. std::thread* thread_;
  25. std::string nodeId_;
  26. std::string pubTopic_;
  27. std::string subTopic_;
  28. Pose2d pose_;
  29. double v_;
  30. double vth_;
  31. };
  32. #endif //SOCKETIO__ROBOTMONITORNODE_H_