fsm_unit.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #ifndef FSMUNIT_H
  2. #define FSMUNIT_H
  3. #include <QObject>
  4. #include <QTimer>
  5. #include <QDateTime>
  6. #include <QMutex>
  7. #include <iostream>
  8. #include <yaml-cpp/yaml.h>
  9. #include "modulecomm.h"
  10. #include "FSMSkipCMD.pb.h"
  11. #include "brainstate.pb.h"
  12. #ifndef IV_MSGUNIT
  13. #define IV_MSGUNIT
  14. namespace iv {
  15. struct msgunit
  16. {
  17. char mstrmsgname[256];
  18. int mnBufferSize = 10000;
  19. int mnBufferCount = 1;
  20. void * mpa = nullptr;
  21. std::shared_ptr<char> mpstrmsgdata;
  22. int mndatasize = 0;
  23. bool mbRefresh = false;
  24. bool mbImportant = false;
  25. int mnkeeptime = 100;
  26. };
  27. }
  28. #endif
  29. #ifndef GLOBAL_GPS_POINT
  30. #define GLOBAL_GPS_POINT
  31. struct gGPSPoint
  32. {
  33. double latitude = 0.0;
  34. double longitude = 0.0;
  35. double height = 0.0;
  36. };
  37. #endif
  38. #ifndef IV_XODROBJ
  39. #define IV_XODROBJ
  40. class xodrobj
  41. {
  42. public:
  43. double flatsrc;
  44. double flonsrc;
  45. double fhgdsrc;
  46. double flat;
  47. double flon;
  48. int lane;
  49. };
  50. #endif
  51. class FSMUnit : public QObject
  52. {
  53. Q_OBJECT
  54. public:
  55. FSMUnit(void);
  56. ~FSMUnit(void);
  57. void dec_yaml(const char * stryamlpath);
  58. void ListenGPSIMUMsg(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname);
  59. void ListenBrainStateMsg(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname);
  60. private:
  61. unsigned int skipCMDSendInterval = 100;
  62. gGPSPoint waitingStation;
  63. gGPSPoint maintainStation;
  64. iv::msgunit shmGPSIMU;
  65. iv::msgunit shmFSMSkipCMD;
  66. iv::msgunit shmBrainState;
  67. iv::msgunit shmXodrRequest;
  68. QMutex mutex_GPSIMU;
  69. gGPSPoint currentPosition;
  70. double currentSpeed;
  71. gGPSPoint currentDestination;
  72. QTimer arriveCheckLoopTimer;
  73. QTimer skipCMDSendTimer;
  74. uint32_t FSMState = 0;
  75. iv::brain::MissionCMD missionCMD = iv::brain::MissionCMD::MISSION_RESERVED; // 任务开始 完成 取消
  76. iv::brain::WorkCMD workCMD = iv::brain::WorkCMD::WORK_RESERVED; // 开工 停工
  77. iv::brain::RemoteCtrlCMD remoteCtrlCMD = iv::brain::RemoteCtrlCMD::REMOTE_CTRL_RESERVED; // 人工接管进入 退出
  78. bool waitingStationArrived = false; // 到达等待站点
  79. bool maintainStationArrived = false; // 到达维护站点
  80. signals:
  81. void refreshFSMStatus(void);
  82. void useStatusChanged(int status);
  83. void setAllowPlan(bool isAllow);
  84. void sendPathPlanRequest(double latitude,double longitude);
  85. public slots:
  86. void navagationSwitchChanged_Slot(bool status);
  87. void useStatusCMDChanged_Slot(bool status);
  88. void remoteCtrlModeChanged_Slot(bool status);
  89. void setFSMDestination_Slot(double latitude,double longitude);
  90. void setMissionFinished_Slot(void);
  91. private slots:
  92. void skipCMDSend_Timeout(void);
  93. void refreshFSMStatus_Slot(void);
  94. void arriveCheckLoop_Timeout(void);
  95. void sendPathPlanRequest_Slot(double latitude,double longitude);
  96. };
  97. #endif // FSMUNIT_H