// // Created by zx on 23-5-8. // #include "navigation_main.h" NavigationMain::NavigationMain(){ move_mode_=Monitor_emqx::eSingle; wheelBase_=0; } NavigationMain::~NavigationMain(){ } void NavigationMain::ResetPose(const Pose2d& pose){ if(move_mode_==Monitor_emqx::eMain) { if(timedBrotherPose_.timeout()==true) { std::cout<<"Brother pose is timeout can not set MainAGV pose"<3.6 || diff.x()<2.2 || diff.y()>0.3 || diff.theta()>5*M_PI/180.0) { std::cout<<" distance with two agv is too far diff: "<3.5) { printf("Failed to Switch MoveMode --> main,wheelbase invalid :%f\n",action.wheelbase()); return; } SwitchMode(Monitor_emqx::eMain,action.wheelbase()); return ; } if(cmd.action()==5) { printf(" Switch MoveMode --> single\n"); SwitchMode(Monitor_emqx::eSingle,0); return ; } else { Navigation::HandleNavCmd(cmd); } } bool NavigationMain::Start(const NavMessage::NavCmd& cmd) { /*if(move_mode_!=Monitor_emqx::eMain) { printf(" navigation mode must set main,parameter:Pose2d\n"); return false; }*/ return Navigation::Start(cmd); } void NavigationMain::SendMoveCmd(Monitor_emqx::ActionMode mode,Monitor_emqx::ActionType type, double v,double angular) { if(monitor_) { monitor_->set_speed(mode,type,v,angular,wheelBase_); } } bool NavigationMain::CreateRobotStatuMsg(NavMessage::RobotStatu& robotStatu) { if(Navigation::CreateRobotStatuMsg(robotStatu)) { robotStatu.mutable_agvstatu()->set_clamp_other(timed_other_clamp_.Get()); return true; } //std::cout<clamp_close(move_mode_); while (exit_ == false) { if (timed_clamp_.timeout() || timed_other_clamp_.timeout()) { printf("timed clamp is timeout\n"); return false; } if (timed_clamp_.Get() == eClosed && timed_other_clamp_.Get()==eClosed) { printf("双车夹持completed!!!\n"); return true; } std::this_thread::sleep_for(std::chrono::milliseconds(100)); monitor_->clamp_close(move_mode_); } return false; } return false; } bool NavigationMain::clamp_open() { if(move_mode_==Monitor_emqx::eSingle) return Navigation::clamp_open(); if(monitor_) { printf("双车松夹持\n"); monitor_->clamp_open(move_mode_); while(exit_==false) { if(timed_clamp_.timeout()||timed_other_clamp_.timeout()) { printf("timed clamp is timeout\n"); return false; } if(timed_clamp_.Get()==eOpened&&timed_other_clamp_.Get()==eOpened) { printf("双车松夹持completed!!!\n"); return true; } std::this_thread::sleep_for(std::chrono::milliseconds(100)); monitor_->clamp_open(move_mode_); } return false; } return false; }