simmodel.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #ifndef SIMMODEL_H
  2. #define SIMMODEL_H
  3. #include <chrono>
  4. #include <thread>
  5. #include "gpsimu.pb.h"
  6. #include "modulecomm.h"
  7. class simmodel
  8. {
  9. public:
  10. simmodel();
  11. ~simmodel();
  12. enum SHIFT_GEER
  13. {
  14. PARK = 0,
  15. REVERSE = 1,
  16. DRIVE = 2
  17. };
  18. protected:
  19. double mx;
  20. double my;
  21. double mhdg;
  22. SHIFT_GEER mshift;
  23. double macc;
  24. double mwheelsteer;
  25. double mvel;
  26. double mlon0,mlat0;
  27. bool mbInitOK = false;
  28. public:
  29. double GetX();
  30. double GetY();
  31. double Gethdg();
  32. SHIFT_GEER GetShift();
  33. double Getacc();
  34. double Getwheelsteer();
  35. double Getvel();
  36. virtual void CalcModel() = 0;
  37. protected:
  38. double mfcmd_acc;
  39. double mfcmd_torque;
  40. double mfcmd_brake;
  41. double mfcmd_wheelangle;
  42. int64_t mlastcmdtime = 0; //chrono ns
  43. public:
  44. void SetCMD(double facc,double ftorque,double fbrake,double fwheelangle);
  45. void SetX(double fx);
  46. void SetY(double fy);
  47. void Sethdg(double fhdg);
  48. void SetShift(SHIFT_GEER sg);
  49. void Setacc(double facc);
  50. void Setwheelsteer(double fwheelsteer);
  51. void Setvel(double fvel);
  52. void SetLon0Lat0(double flon0,double flat0);
  53. private:
  54. std::thread * mpthread;
  55. bool mbrun = true;
  56. void threadupdate();
  57. std::thread * mpthreadstate;
  58. void threadstate();
  59. void * mpa;
  60. };
  61. #endif // SIMMODEL_H