|
@@ -426,6 +426,47 @@ bool Navigation::RotateReferToTarget(const Pose2d &target, stLimit limit_rotate,
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+bool Navigation::AdjustReferToTarget(const Pose2d& target, stLimit limit_rotate) {
|
|
|
+ if (inited_ == false) {
|
|
|
+ printf(" MPC_rotate has not inited\n");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (PoseTimeout()) {
|
|
|
+ printf(" MPC_rotate Error:Pose is timeout \n");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ Pose2d current = timedPose_.Get();
|
|
|
+ NavMessage::PathNode yawTarget;
|
|
|
+ yawTarget.set_x(current.x() + 100.);
|
|
|
+ yawTarget.set_y(current.y());
|
|
|
+ int directions = Direction::eForward | Direction::eRight | Direction::eLeft | Direction::eBackward;
|
|
|
+ RotateReferToTarget(yawTarget, limit_rotate, directions);
|
|
|
+ printf(" exec MPC_rotate autoDirect:%d\n", directions);
|
|
|
+
|
|
|
+ current = timedPose_.Get();
|
|
|
+ Pose2d diff=target-current;
|
|
|
+ Pose2d newTarget;
|
|
|
+ NavMessage::PathNode node;
|
|
|
+ if(fabs(diff.x())>fabs(diff.y())){
|
|
|
+ newTarget=Pose2d(current.x(),target.y(),current.theta());
|
|
|
+ node.set_theta(M_PI/2.0);
|
|
|
+ }else{
|
|
|
+ newTarget=Pose2d(target.x(),current.y(),current.theta());
|
|
|
+ node.set_theta(0);
|
|
|
+ }
|
|
|
+ node.set_x(newTarget.x());
|
|
|
+ node.set_y(newTarget.y());
|
|
|
+ node.set_l(0.03);
|
|
|
+ node.set_w(0.2);
|
|
|
+
|
|
|
+ stLimit limitV={0.03,0.5};
|
|
|
+ stLimit limitW={0.03,0.1};
|
|
|
+ return MoveToTarget(node,limitV,limitW,true,true);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
Navigation::MpcResult Navigation::RotateReferToTarget(NavMessage::PathNode node, stLimit limit_rotate, int directions) {
|
|
|
if (inited_ == false) {
|
|
|
printf(" MPC_rotate has not inited\n");
|
|
@@ -557,8 +598,11 @@ bool Navigation::MoveToTarget(NavMessage::PathNode node, Navigation::stLimit lim
|
|
|
Pose2d target(node.x(), node.y(), 0);
|
|
|
Pose2d targetInCurrent = Pose2d::relativePose(target, current);
|
|
|
|
|
|
- if (enableTotarget == false && Pose2d::distance(Pose2d(0, 0, 0), targetInCurrent) > 0.3) {
|
|
|
- if (already_in_mpc && enable_rotate == false) {
|
|
|
+ if (enableTotarget == false ) {
|
|
|
+ bool adjustRet=AdjustReferToTarget(target,limit_w);
|
|
|
+ if(adjustRet==false)
|
|
|
+ return false;
|
|
|
+ /*if (already_in_mpc && enable_rotate == false) {
|
|
|
printf(" Move to node failed ,impossible to target and rotate is not enabled\n");
|
|
|
return false;
|
|
|
}
|
|
@@ -573,8 +617,9 @@ bool Navigation::MoveToTarget(NavMessage::PathNode node, Navigation::stLimit lim
|
|
|
" directions: " << std::hex << directions << " line_: " << __LINE__ << std::endl;
|
|
|
return false;
|
|
|
}
|
|
|
- continue;
|
|
|
+ continue;*/
|
|
|
}
|
|
|
+
|
|
|
already_in_mpc = true;
|
|
|
MpcResult ret = MpcToTarget(node, limit_v, anyDirect);
|
|
|
if (ret == eMpcSuccess) {
|
|
@@ -609,10 +654,8 @@ bool Navigation::execute_nodes(NavMessage::NewAction action, int space_id) {
|
|
|
|
|
|
/////////////////////////////////////////
|
|
|
|
|
|
-
|
|
|
- std::thread *thread_clampOpenHalf = nullptr;
|
|
|
if(move_mode_==eSingle) {
|
|
|
- thread_clampOpenHalf = new std::thread(&Navigation::clamp_half_open, this);
|
|
|
+ clamp_half_open();
|
|
|
}
|
|
|
////////////////////////////////////////////////////////////
|
|
|
for (int i = 0; i < action.pathnodes_size(); ++i) {
|
|
@@ -634,23 +677,17 @@ bool Navigation::execute_nodes(NavMessage::NewAction action, int space_id) {
|
|
|
if (anyDirect)
|
|
|
directions = Direction::eForward | Direction::eBackward |
|
|
|
Direction::eLeft | Direction::eRight;
|
|
|
- if (i > 0) {
|
|
|
+ /*if (i > 0) {
|
|
|
if (RotateReferToTarget(node, wmg_limit, directions) != eMpcSuccess) {
|
|
|
printf(" before move node RotateReferToNone Failed!!\n");
|
|
|
return false;
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
if (MoveToTarget(node, mpc_velocity, wmg_limit, anyDirect, true) == false)
|
|
|
return false;
|
|
|
else
|
|
|
isInSpace_ = false;
|
|
|
}
|
|
|
- if(move_mode_==eSingle) {
|
|
|
- printf(" wait clamp open half...\n");
|
|
|
- thread_clampOpenHalf->join();
|
|
|
- printf("clamp open half completed!!!\n");
|
|
|
- delete thread_clampOpenHalf;
|
|
|
- }
|
|
|
if (cancel_ == true) {
|
|
|
return false;
|
|
|
}
|
|
@@ -843,23 +880,13 @@ bool Navigation::execute_InOut_space(NavMessage::NewAction action) {
|
|
|
//计算车位朝向
|
|
|
action.mutable_spacenode()->set_theta(Pose2d::vector2yaw(vec.x(), vec.y()));
|
|
|
//计算当前车是进入车位1点还是2点, 提升下降动作与旋转调整并行
|
|
|
- LifterStatus lifter_actType;
|
|
|
- std::thread *thread_lifter = nullptr;
|
|
|
- if (IsUperSpace(action.spacenode())) {
|
|
|
- //进载车板库前提升机构上升
|
|
|
- lifter_actType = eRose;
|
|
|
- thread_lifter = new std::thread(&Navigation::lifter_rise, this);
|
|
|
- } else {
|
|
|
- //否则下降
|
|
|
- lifter_actType = eDowned;
|
|
|
- thread_lifter = new std::thread(&Navigation::lifter_down, this);
|
|
|
+ if (IsUperSpace(action.spacenode())) { //进载车板库前提升机构上升
|
|
|
+ lifter_rise();
|
|
|
+ } else { //否则下降
|
|
|
+ lifter_down();
|
|
|
}
|
|
|
NavMessage::PathNode new_target;
|
|
|
bool retRotate=RotateBeforeEnterSpace(action.spacenode(), action.wheelbase(), new_target) == eMpcSuccess;
|
|
|
- printf(" wait lifter action:%d\n", lifter_actType);
|
|
|
- thread_lifter->join();
|
|
|
- delete thread_lifter;
|
|
|
- printf("lifter action:%d completed!!!\n", lifter_actType);
|
|
|
|
|
|
if(retRotate==false){
|
|
|
return false;
|
|
@@ -897,13 +924,9 @@ bool Navigation::execute_InOut_space(NavMessage::NewAction action) {
|
|
|
}
|
|
|
isInSpace_ = true;
|
|
|
printf("Enter space beg...\n");
|
|
|
-
|
|
|
- std::thread *thread_clamp = nullptr;
|
|
|
- thread_clamp = new std::thread(&Navigation::singleClamp_fullyOpen_until_inspaceBegin, this);
|
|
|
-
|
|
|
+ if(move_mode_==eSingle)
|
|
|
+ clamp_half_open(); //////// 后续再改为全打开位
|
|
|
bool retMove=MoveToTarget(new_target, limit_v, limit_w, true, false);
|
|
|
- thread_clamp->join();
|
|
|
- delete thread_clamp;
|
|
|
|
|
|
if(retMove==false){
|
|
|
printf(" Enter space:%s failed. type:%d\n", action.spacenode().id().data(), action.type());
|
|
@@ -934,7 +957,7 @@ bool Navigation::execute_InOut_space(NavMessage::NewAction action) {
|
|
|
return false;
|
|
|
}
|
|
|
isInSpace_ = false;
|
|
|
-
|
|
|
+ lifter_down();
|
|
|
//从入口出库旋转180
|
|
|
if (move_mode_ == eDouble && action.spacenode().id().find("S1101") != -1) {
|
|
|
Pose2d current_pose = timedPose_.Get();
|
|
@@ -1154,9 +1177,10 @@ void Navigation::SendMoveCmd(int mode, ActionType type,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void Navigation::SendMoveCmd(int mode, ActionType type, double v[], double angular[], int space_id, double distance) {
|
|
|
+void Navigation::SendMoveCmd(int mode, ActionType type, double v[], double angular[],
|
|
|
+ int space_id, double distance,double Y1,double Y2) {
|
|
|
if (monitor_) {
|
|
|
- monitor_->set_ToAgvCmd(mode, type, v, angular, 0, space_id, distance);
|
|
|
+ monitor_->set_ToAgvCmd(mode, type, v, angular, 0, space_id, distance,Y1,Y2);
|
|
|
if (type == eRotation)
|
|
|
RWheel_position_ = eR;
|
|
|
if (type == eVertical)
|
|
@@ -1240,6 +1264,7 @@ bool Navigation::singleClamp_fullyOpen_until_inspaceBegin(){
|
|
|
return false;
|
|
|
}
|
|
|
if(fabs(timedV_.Get())<0.02){
|
|
|
+
|
|
|
usleep(1000*300);
|
|
|
continue;
|
|
|
}
|
|
@@ -1373,7 +1398,11 @@ Navigation::MpcResult Navigation::MpcToTarget(NavMessage::PathNode node, stLimit
|
|
|
} else {
|
|
|
std::cout << " MPC X axis target_relative:" << target_relative << std::endl;
|
|
|
}
|
|
|
+ if(!PossibleToTarget(node, directY)){
|
|
|
+ directY=!directY;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
printf(" exec along autoDirect:%d\n", autoDirect);
|
|
|
|
|
|
//文件log
|
|
@@ -1476,11 +1505,15 @@ Navigation::MpcResult Navigation::MpcToTarget(NavMessage::PathNode node, stLimit
|
|
|
std::string id = node.id().substr(1, node.id().length() - 1);
|
|
|
space_id = stoi(id);
|
|
|
}
|
|
|
-// double diff_yaw_[2] = {diff_yaw[0], diff_yaw[1]};
|
|
|
+ double Y1=0.0,Y2=0.0;
|
|
|
+ if(move_mode_==eDouble){
|
|
|
+ Y1=timeYawDiff1_.Get();
|
|
|
+ Y2=timeYawDiff2_.Get();
|
|
|
+ }
|
|
|
if (directY == false)
|
|
|
- SendMoveCmd(move_mode_, eVertical, down_v, down_w, space_id, distance);
|
|
|
+ SendMoveCmd(move_mode_, eVertical, down_v, down_w, space_id, distance,Y1,Y2);
|
|
|
else
|
|
|
- SendMoveCmd(move_mode_, eHorizontal, down_v, down_w, space_id, distance);
|
|
|
+ SendMoveCmd(move_mode_, eHorizontal, down_v, down_w, space_id, distance,Y1,Y2);
|
|
|
actionType_ = directY ? eHorizontal : eVertical;
|
|
|
|
|
|
//日志打印
|
|
@@ -1674,7 +1707,7 @@ void Navigation::Start(const NavMessage::NavCmd &cmd, NavMessage::NavResponse &r
|
|
|
break;
|
|
|
}
|
|
|
} else if (act.type() == 7) {
|
|
|
- if (this->clamp_fully_open() == false) {
|
|
|
+ if (this->clamp_half_open() == false) {
|
|
|
printf("打开夹持 failed...\n");
|
|
|
break;
|
|
|
}
|