navigation_main.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. if (move_mode_ == mode)
  19. return;
  20. if (mode == eDouble) {
  21. if (timedBrotherPose_.timeout() == true || timedPose_.timeout() == true) {
  22. std::cout << "Brother/self pose is timeout can not set MainAGV pose" << std::endl;
  23. return;
  24. }
  25. //Pose2d transform(-wheelBase_/2.0,0,0);
  26. //Navigation::ResetPose(pose * transform);
  27. Pose2d brother = timedBrotherPose_.Get();
  28. Pose2d pose = timedPose_.Get();
  29. Pose2d diff = Pose2d::abs(Pose2d::relativePose(brother, pose));
  30. if (diff.x() > 3.4 || diff.x() < 2.3 || diff.y() > 0.2 || diff.theta() > 5 * M_PI / 180.0) {
  31. std::cout << " distance with two agv is too far diff: " << diff << std::endl;
  32. return;
  33. }
  34. Pose2d self_pose = timedPose_.Get();
  35. Pose2d brother_pose = timedBrotherPose_.Get();
  36. Pose2d brother_in_self = Pose2d::relativePose(brother_pose, self_pose);
  37. if (brother_in_self.x() <= 0)
  38. mode = mode | eMainInForward;
  39. else
  40. mode = mode | eMainInBackward;
  41. if (brother_in_self.theta() >= -M_PI / 2 && brother_in_self.theta() <= M_PI / 2)
  42. mode = mode | eChildSameToMain;
  43. else
  44. mode = mode | eChildOppositeToMain;
  45. printf(" Switch MoveMode --> main(%d)\n", mode);
  46. }
  47. wheelBase_ = wheelBase;
  48. move_mode_ = mode;
  49. };
  50. protected:
  51. virtual Navigation::MpcResult
  52. RotateBeforeEnterSpace(NavMessage::PathNode space, double wheelbase, NavMessage::PathNode &target);
  53. virtual void SendMoveCmd(int mode, ActionType type,
  54. double v, double angular);
  55. virtual bool clamp_close();
  56. virtual bool clamp_open();
  57. virtual bool lifter_rise();
  58. virtual bool lifter_down();
  59. virtual bool CreateRobotStatuMsg(NavMessage::RobotStatu &robotStatu);
  60. protected:
  61. float wheelBase_; //两节agv的位姿与单节的位姿变换
  62. TimedLockData<int> timed_other_clamp_;
  63. TimedLockData<int> timed_other_lifter_;
  64. };
  65. #endif //NAVIGATION_NAVIGATION_MAIN_H