1
0

monkeycar_person.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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(uint64_t t,double &speed)
  33. {
  34. point p;
  35. const auto pt = get_position(speed);
  36. t=m_timeval;
  37. if(point_2::is_valid(pt))
  38. {
  39. p.x = pt.x_;
  40. p.y = pt.y_;
  41. }
  42. return p;
  43. }
  44. inline void setCompensationSpeed(double v)
  45. {
  46. //debug_print_syslog(0,"[framework adjust speed] :%s,v:%f",getCardId().c_str(),v);
  47. m_compensation_speed = v;
  48. }
  49. void reset(double speed);
  50. void Set_AverageSpeed();
  51. void handle_monkeycar_fit(double);
  52. private:
  53. point_2 get_position(double &speed);
  54. public:
  55. int m_getOffIndex;
  56. double m_cur_distance; //curTime distance
  57. double m_compensation_speed;
  58. uint64_t m_timeval;
  59. uint64_t m_adjustDis_timeval;
  60. uint64_t m_timestamp;
  61. comp_linear_fit* m_linear_fit;
  62. std::array<monkey_fit*,2> mp_monkey_fit;
  63. };
  64. #endif