navigation_main.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //
  2. // Created by zx on 23-5-8.
  3. //
  4. #ifndef NAVIGATION_NAVIGATION_MAIN_H
  5. #define NAVIGATION_NAVIGATION_MAIN_H
  6. #include "navigation.h"
  7. class NavigationMain : public Navigation {
  8. public:
  9. NavigationMain();
  10. ~NavigationMain();
  11. virtual void ResetPose(const Pose2d &pose);
  12. virtual void Start(const NavMessage::NavCmd &cmd, NavMessage::NavResponse &response);
  13. virtual void publish_statu(NavMessage::NavStatu &statu);
  14. void ResetOtherClamp(ClampStatu statu);
  15. void ResetOtherLifter(LifterStatus status);
  16. virtual void HandleAgvStatu(const MqttMsg &msg);
  17. virtual void SwitchMode(int mode, float wheelBase) {
  18. printf("change mode to:%d\n", mode);
  19. wheelBase_ = wheelBase;
  20. if (move_mode_ == mode)
  21. return;
  22. if (mode == eDouble) {
  23. if (timedBrotherPose_.timeout() == true || timedPose_.timeout() == true) {
  24. std::cout << "Brother/self pose is timeout can not set MainAGV pose" << std::endl;
  25. return;
  26. }
  27. //Pose2d transform(-wheelBase_/2.0,0,0);
  28. //Navigation::ResetPose(pose * transform);
  29. Pose2d brother = timedBrotherPose_.Get();
  30. Pose2d pose = timedPose_.Get();
  31. Pose2d diff = Pose2d::abs(Pose2d::relativePose(brother, pose));
  32. if (diff.x() > 3.4 || diff.x() < 2.3 || diff.y() > 0.2 || diff.theta() > 5 * M_PI / 180.0) {
  33. std::cout << " distance with two agv is too far diff: " << diff << std::endl;
  34. return;
  35. }
  36. Pose2d self_pose = timedPose_.Get();
  37. Pose2d brother_pose = timedBrotherPose_.Get();
  38. Pose2d brother_in_self = Pose2d::relativePose(brother_pose, self_pose);
  39. if (brother_in_self.x() <= 0)
  40. mode = mode | eMainInForward;
  41. else
  42. mode = mode | eMainInBackward;
  43. if (brother_in_self.theta() >= -M_PI / 2 && brother_in_self.theta() <= M_PI / 2)
  44. mode = mode | eChildSameToMain;
  45. else
  46. mode = mode | eChildOppositeToMain;
  47. printf(" Switch MoveMode --> main(%d), wheelBase: %f\n", mode, wheelBase);
  48. }
  49. move_mode_ = mode;
  50. };
  51. protected:
  52. virtual Navigation::MpcResult
  53. RotateBeforeEnterSpace(NavMessage::PathNode space, double wheelbase, NavMessage::PathNode &target);
  54. virtual void SendMoveCmd(int mode, ActionType type, double v[], double angular[]);
  55. virtual void SendMoveCmd(int mode, ActionType type, double v[], double angular[],
  56. int space_id, double distance,double Y1=0.,double Y2=0.);
  57. virtual bool clamp_close();
  58. virtual bool clamp_half_open();
  59. virtual bool lifter_rise();
  60. virtual bool lifter_down();
  61. virtual bool CreateRobotStatuMsg(NavMessage::RobotStatu &robotStatu);
  62. protected:
  63. TimedLockData<int> timed_other_clamp_;
  64. TimedLockData<int> timed_other_lifter_;
  65. };
  66. #endif //NAVIGATION_NAVIGATION_MAIN_H