navigation_main.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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,
  54. NavMessage::PathNode &target,int clampLifterAction=0);
  55. virtual void SendMoveCmd(int clampLifterAction,int mode, ActionType type, double v[], double angular[]);
  56. virtual void SendMoveCmd(int clampLifterAction,int mode, ActionType type, double v[], double angular[],
  57. int space_id, double distance,double Y1=0.0,double Y2=0.0);
  58. virtual bool clamp_close();
  59. virtual bool clamp_half_open();
  60. virtual bool lifter_rise();
  61. virtual bool lifter_down();
  62. virtual bool CreateRobotStatuMsg(NavMessage::RobotStatu &robotStatu);
  63. protected:
  64. };
  65. #endif //NAVIGATION_NAVIGATION_MAIN_H