monkeycar_person.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #ifndef __MONKEYCAR_PERSON__
  2. #define __MONKEYCAR_PERSON__
  3. #include <memory>
  4. #include "base_data.h"
  5. #include "linear_fit.h"
  6. #include "fp_path.h"
  7. #include "monkey_fit.h"
  8. #include "../point.h"
  9. struct monkey_bus;
  10. struct monkey_area;
  11. #define MAX_POINT_V 30
  12. #define MAX_GETOFF_NUM 5
  13. #define ZERO_ 1E-5
  14. extern const int num_fit_point[4];
  15. struct monkey_person
  16. {
  17. std::weak_ptr<monkey_bus> m_bus;
  18. std::weak_ptr<monkey_area> m_area;
  19. std::deque<st_coord> m_fit_point;
  20. monkey_person(std::shared_ptr<monkey_area> area);
  21. ~monkey_person();
  22. void GetOnTheBus(std::shared_ptr<monkey_bus> bus,double speed);
  23. void GetOffTheBus();
  24. bool Judge_OffIndex();
  25. void resetOffIndex();
  26. bool is_on_bus() const;
  27. std::shared_ptr<monkey_bus> getBus();
  28. bool on_step_map(const st_coord & pt);
  29. bool fit_speed(double*ret_speed);
  30. bool get_num_point(int * p);
  31. bool init_another_list(size_t index);
  32. point getPoint()
  33. {
  34. point p;
  35. const auto pt = get_position();
  36. if(point_2::is_valid(pt))
  37. {
  38. p.x = pt.x_;
  39. p.y = pt.y_;
  40. }
  41. return p;
  42. }
  43. inline void setCompensationSpeed(double v)
  44. {
  45. //debug_print_syslog(0,"[framework adjust speed] :%s,v:%f",getCardId().c_str(),v);
  46. m_compensation_speed = v;
  47. }
  48. void reset(double speed);
  49. void Set_AverageSpeed();
  50. void handle_monkeycar_fit(double);
  51. private:
  52. point_2 get_position();
  53. public:
  54. int m_getOffIndex;
  55. double m_cur_distance; //curTime distance
  56. double m_compensation_speed;
  57. uint64_t m_timeval;
  58. uint64_t m_adjustDis_timeval;
  59. uint64_t m_timestamp;
  60. comp_linear_fit* m_linear_fit;
  61. std::array<monkey_fit*,2> mp_monkey_fit;
  62. };
  63. #endif