out_sim.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #pragma once
  2. #include <thread>
  3. #include <mutex>
  4. #include <functional>
  5. #include <condition_variable>
  6. #include "../common/comm.h"
  7. #include "../common/notifier.h"
  8. class CIOBuffer;
  9. #pragma pack(1)
  10. struct OutSimPack
  11. {
  12. /*
  13. unsigned int time;
  14. float AVelocityX;
  15. float AVelocityY;
  16. float AVelocitZ;
  17. float yaw;
  18. float pitch;
  19. float roll;
  20. float accX;
  21. float accY;
  22. float accZ;
  23. float velX;
  24. float vely;
  25. float velz;
  26. int posx;
  27. int posy;
  28. int posz;
  29. */
  30. int8_t start1 = 0x55;
  31. int8_t start2 = 0xaa;
  32. int8_t start3 = 0xbb;
  33. int8_t cmd =6;
  34. float tx=0;
  35. float ty=0;
  36. float tz=0;
  37. float rx;
  38. float ry;
  39. float rz=0;
  40. float var1=0;
  41. float var2=0;
  42. float var3=0;
  43. float var4=0;
  44. float var5=0;
  45. float var6=0;
  46. int time=50;
  47. };
  48. #pragma pack()
  49. class COutSim
  50. {
  51. public:
  52. COutSim(const char * ip,int32_t port);
  53. void Start();
  54. void Stop();
  55. void PushSimPack(CIOBuffer* pBuffer);
  56. void OnPeerMessage(int16_t cmd, int16_t length, const void* data);
  57. private:
  58. void Run();
  59. bool SendOutSim(CIOBuffer* pBuffer);
  60. private:
  61. SOCKET _socket;
  62. std::thread _thread;
  63. bool _run;
  64. std::mutex Mtx;
  65. std::condition_variable cv;
  66. CIOBuffer* _head;
  67. std::string _ip;
  68. int32_t _port;
  69. };