navigation_main.h 3.0 KB

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