|
@@ -136,13 +136,32 @@ void Navigation::RobotPoseCallback(const MqttMsg &msg, void *context) {
|
|
|
|
|
|
void Navigation::HandleAgvStatu(const MqttMsg &msg) {
|
|
void Navigation::HandleAgvStatu(const MqttMsg &msg) {
|
|
NavMessage::AgvStatu speed;
|
|
NavMessage::AgvStatu speed;
|
|
- if (msg.toProtoMessage(speed)) {
|
|
|
|
- ResetStatu(speed.v(), speed.w());
|
|
|
|
- ResetClamp((ClampStatu) speed.clamp());
|
|
|
|
- ResetLifter((LifterStatus) speed.lifter());
|
|
|
|
|
|
+ if (IsMasterAGV()) {
|
|
|
|
+ if (msg.toProtoMessage(speed)) {
|
|
|
|
+ ResetStatu(speed.v(), speed.w());
|
|
|
|
+ ResetClamp((ClampStatu) speed.clamp());
|
|
|
|
+// ResetOtherClamp((ClampStatu) speed.clamp_other());
|
|
|
|
+ ResetLifter((LifterStatus) speed.lifter());
|
|
|
|
+// ResetOtherLifter((LifterStatus) speed.lifter_other());
|
|
|
|
+ //printf(" clamp:%d other:%d\n",speed.clamp(),speed.clamp_other());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if (msg.toProtoMessage(speed)) {
|
|
|
|
+ ResetStatu(speed.v(), speed.w());
|
|
|
|
+ ResetClamp((ClampStatu) speed.clamp());
|
|
|
|
+ ResetLifter((LifterStatus) speed.lifter());
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ ResetInsideDoor(speed.door());
|
|
|
|
+ std::vector<int32_t> vecStatus;
|
|
|
|
+ for(int i=0;i<speed.zcb_size();++i){
|
|
|
|
+ vecStatus.push_back(speed.zcb(i));
|
|
|
|
+ }
|
|
|
|
+ ResetCarrier(vecStatus);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
void Navigation::RobotSpeedCallback(const MqttMsg &msg, void *context) {
|
|
void Navigation::RobotSpeedCallback(const MqttMsg &msg, void *context) {
|
|
Navigation *navigator = (Navigation *) context;
|
|
Navigation *navigator = (Navigation *) context;
|
|
navigator->HandleAgvStatu(msg);
|
|
navigator->HandleAgvStatu(msg);
|
|
@@ -255,6 +274,7 @@ void Navigation::ResetLifter(LifterStatus status) {
|
|
timed_lifter_.reset(status, 1);
|
|
timed_lifter_.reset(status, 1);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
void Navigation::ResetPose(const Pose2d &pose) {
|
|
void Navigation::ResetPose(const Pose2d &pose) {
|
|
timedPose_.reset(pose, 1.0);
|
|
timedPose_.reset(pose, 1.0);
|
|
if (pose.theta() > 0) {
|
|
if (pose.theta() > 0) {
|
|
@@ -331,6 +351,7 @@ bool Navigation::SlowlyStop() {
|
|
|
|
|
|
|
|
|
|
Navigation::Navigation() {
|
|
Navigation::Navigation() {
|
|
|
|
+ is_master_AGV=false;
|
|
wheelBase_ = 0;
|
|
wheelBase_ = 0;
|
|
isInSpace_ = false; //是否在车位或者正在进入车位
|
|
isInSpace_ = false; //是否在车位或者正在进入车位
|
|
RWheel_position_ = eUnknow;
|
|
RWheel_position_ = eUnknow;
|
|
@@ -362,6 +383,7 @@ void Navigation::BrotherAgvStatuCallback(const MqttMsg &msg, void *context) {
|
|
}
|
|
}
|
|
|
|
|
|
//未使用
|
|
//未使用
|
|
|
|
+/*
|
|
bool Navigation::RotateReferToTarget(const Pose2d &target, stLimit limit_rotate, bool anyDirect) {
|
|
bool Navigation::RotateReferToTarget(const Pose2d &target, stLimit limit_rotate, bool anyDirect) {
|
|
|
|
|
|
while (cancel_ == false) {
|
|
while (cancel_ == false) {
|
|
@@ -425,10 +447,10 @@ bool Navigation::RotateReferToTarget(const Pose2d &target, stLimit limit_rotate,
|
|
}
|
|
}
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
+*/
|
|
|
|
|
|
-
|
|
|
|
-bool Navigation::AdjustReferToTarget(const Pose2d& target, stLimit limit_rotate) {
|
|
|
|
- std::cout<<"Adjust to : "<<target<<std::endl;
|
|
|
|
|
|
+bool Navigation::AdjustReferToTarget(const Pose2d &target, stLimit limit_rotate,int directions) {
|
|
|
|
+ std::cout << "Adjust to : " << target << std::endl;
|
|
if (inited_ == false) {
|
|
if (inited_ == false) {
|
|
printf(" MPC_rotate has not inited\n");
|
|
printf(" MPC_rotate has not inited\n");
|
|
return false;
|
|
return false;
|
|
@@ -442,19 +464,19 @@ bool Navigation::AdjustReferToTarget(const Pose2d& target, stLimit limit_rotate)
|
|
NavMessage::PathNode yawTarget;
|
|
NavMessage::PathNode yawTarget;
|
|
yawTarget.set_x(current.x() + 100.);
|
|
yawTarget.set_x(current.x() + 100.);
|
|
yawTarget.set_y(current.y());
|
|
yawTarget.set_y(current.y());
|
|
- int directions = Direction::eForward | Direction::eRight | Direction::eLeft | Direction::eBackward;
|
|
|
|
- std::cout<<"Adjust RotateRefer : "<<Pose2d(yawTarget.x(),yawTarget.y(),0)<<std::endl;
|
|
|
|
|
|
+
|
|
|
|
+ std::cout << "Adjust RotateRefer : " << Pose2d(yawTarget.x(), yawTarget.y(), 0) << std::endl;
|
|
RotateReferToTarget(yawTarget, limit_rotate, directions);
|
|
RotateReferToTarget(yawTarget, limit_rotate, directions);
|
|
|
|
|
|
current = timedPose_.Get();
|
|
current = timedPose_.Get();
|
|
- Pose2d diff=target-current;
|
|
|
|
|
|
+ Pose2d diff = target - current;
|
|
Pose2d newTarget;
|
|
Pose2d newTarget;
|
|
NavMessage::PathNode node;
|
|
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());
|
|
|
|
|
|
+ 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_theta(0);
|
|
}
|
|
}
|
|
node.set_x(newTarget.x());
|
|
node.set_x(newTarget.x());
|
|
@@ -462,11 +484,10 @@ bool Navigation::AdjustReferToTarget(const Pose2d& target, stLimit limit_rotate)
|
|
node.set_l(0.03);
|
|
node.set_l(0.03);
|
|
node.set_w(0.2);
|
|
node.set_w(0.2);
|
|
|
|
|
|
- stLimit limitV={0.03,0.5};
|
|
|
|
- stLimit limitW={0.03,0.1};
|
|
|
|
- std::cout<<" Adjust MoveTarget:"<<Pose2d(node.x(),node.y(),node.theta())<<std::endl;
|
|
|
|
- return MoveToTarget(node,limitV,limitW,true,true);
|
|
|
|
-
|
|
|
|
|
|
+ stLimit limitV = {0.03, 0.5};
|
|
|
|
+ stLimit limitW = {0.03, 0.1};
|
|
|
|
+ std::cout << " Adjust MoveTarget:" << Pose2d(node.x(), node.y(), node.theta()) << std::endl;
|
|
|
|
+ return MoveToTarget(node, limitV, limitW, true, true);
|
|
}
|
|
}
|
|
|
|
|
|
Navigation::MpcResult Navigation::RotateReferToTarget(NavMessage::PathNode node, stLimit limit_rotate, int directions) {
|
|
Navigation::MpcResult Navigation::RotateReferToTarget(NavMessage::PathNode node, stLimit limit_rotate, int directions) {
|
|
@@ -549,22 +570,15 @@ Navigation::MpcResult Navigation::RotateReferToTarget(NavMessage::PathNode node,
|
|
const int down_count = 3;
|
|
const int down_count = 3;
|
|
double v[down_count] = {0, 0, 0};
|
|
double v[down_count] = {0, 0, 0};
|
|
double w[down_count] = {out[0], out[1], out[2]};
|
|
double w[down_count] = {out[0], out[1], out[2]};
|
|
-// if(out[0]>=0){
|
|
|
|
-// w[0]=1.*M_PI/180.0;
|
|
|
|
-// w[1]=1.*M_PI/180.0;
|
|
|
|
-// w[2]=1.*M_PI/180.0;
|
|
|
|
-// }else{
|
|
|
|
-// w[0]=-1.*M_PI/180.0;
|
|
|
|
-// w[1]=-1.*M_PI/180.0;
|
|
|
|
-// w[2]=-1.*M_PI/180.0;
|
|
|
|
-// }
|
|
|
|
- SendMoveCmd(move_mode_, eRotation, v, w);
|
|
|
|
|
|
+
|
|
|
|
+ SendMoveCmd(0, move_mode_, eRotation, v, w);
|
|
actionType_ = eRotation;
|
|
actionType_ = eRotation;
|
|
double input_w = timedA_.Get();
|
|
double input_w = timedA_.Get();
|
|
|
|
+ /*
|
|
for (int i = 0; i < down_count; ++i) {
|
|
for (int i = 0; i < down_count; ++i) {
|
|
printf(" MPC_rotate |P[%d], input anguar:%f, down:%f(%f), diff:%f anyDirect:%d\n",
|
|
printf(" MPC_rotate |P[%d], input anguar:%f, down:%f(%f), diff:%f anyDirect:%d\n",
|
|
i, input_w, w[i], w[i] / M_PI * 180, target_yaw_diff, directions);
|
|
i, input_w, w[i], w[i] / M_PI * 180, target_yaw_diff, directions);
|
|
- }
|
|
|
|
|
|
+ }*/
|
|
}
|
|
}
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -572,8 +586,7 @@ Navigation::MpcResult Navigation::RotateReferToTarget(NavMessage::PathNode node,
|
|
}
|
|
}
|
|
|
|
|
|
bool Navigation::MoveToTarget(NavMessage::PathNode node, Navigation::stLimit limit_v, Navigation::stLimit limit_w,
|
|
bool Navigation::MoveToTarget(NavMessage::PathNode node, Navigation::stLimit limit_v, Navigation::stLimit limit_w,
|
|
- bool anyDirect, bool enable_rotate) {
|
|
|
|
-// LogWriter("MoveToTarget beg");
|
|
|
|
|
|
+ bool anyDirect, bool enable_rotate, int clampLifterAction) {
|
|
if (IsArrived(node)) {
|
|
if (IsArrived(node)) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -600,9 +613,12 @@ bool Navigation::MoveToTarget(NavMessage::PathNode node, Navigation::stLimit lim
|
|
Pose2d target(node.x(), node.y(), 0);
|
|
Pose2d target(node.x(), node.y(), 0);
|
|
Pose2d targetInCurrent = Pose2d::relativePose(target, current);
|
|
Pose2d targetInCurrent = Pose2d::relativePose(target, current);
|
|
|
|
|
|
- if (enableTotarget == false ) {
|
|
|
|
- bool adjustRet=AdjustReferToTarget(target,limit_w);
|
|
|
|
- if(adjustRet==false)
|
|
|
|
|
|
+ if (enableTotarget == false) {
|
|
|
|
+ int directions = Direction::eForward;
|
|
|
|
+ if(anyDirect)
|
|
|
|
+ directions = Direction::eForward | Direction::eRight | Direction::eLeft | Direction::eBackward;
|
|
|
|
+ bool adjustRet = AdjustReferToTarget(target, limit_w,directions);
|
|
|
|
+ if (adjustRet == false)
|
|
return false;
|
|
return false;
|
|
/*if (already_in_mpc && enable_rotate == false) {
|
|
/*if (already_in_mpc && enable_rotate == false) {
|
|
printf(" Move to node failed ,impossible to target and rotate is not enabled\n");
|
|
printf(" Move to node failed ,impossible to target and rotate is not enabled\n");
|
|
@@ -623,7 +639,7 @@ bool Navigation::MoveToTarget(NavMessage::PathNode node, Navigation::stLimit lim
|
|
}
|
|
}
|
|
|
|
|
|
already_in_mpc = true;
|
|
already_in_mpc = true;
|
|
- MpcResult ret = MpcToTarget(node, limit_v, anyDirect);
|
|
|
|
|
|
+ MpcResult ret = MpcToTarget(node, limit_v, anyDirect, clampLifterAction);
|
|
if (ret == eMpcSuccess) {
|
|
if (ret == eMpcSuccess) {
|
|
printf(" MPC to target:%f %f l:%f,w:%f theta:%f completed\n",
|
|
printf(" MPC to target:%f %f l:%f,w:%f theta:%f completed\n",
|
|
node.x(), node.y(), node.l(), node.w(), node.theta());
|
|
node.x(), node.y(), node.l(), node.w(), node.theta());
|
|
@@ -655,9 +671,11 @@ bool Navigation::execute_nodes(NavMessage::NewAction action, int space_id) {
|
|
stLimit mpc_velocity = {parameter_.nodevelocitylimit().min(), parameter_.nodevelocitylimit().max()};
|
|
stLimit mpc_velocity = {parameter_.nodevelocitylimit().min(), parameter_.nodevelocitylimit().max()};
|
|
|
|
|
|
/////////////////////////////////////////
|
|
/////////////////////////////////////////
|
|
-
|
|
|
|
- if(move_mode_==eSingle) {
|
|
|
|
- clamp_half_open();
|
|
|
|
|
|
+ int clampLifterAction = 0;
|
|
|
|
+ if (move_mode_ == eSingle) {
|
|
|
|
+ clampLifterAction |= eByteClampHalfOpen;
|
|
|
|
+ }else{
|
|
|
|
+ clampLifterAction |= eByteLifterDown;
|
|
}
|
|
}
|
|
////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////
|
|
for (int i = 0; i < action.pathnodes_size(); ++i) {
|
|
for (int i = 0; i < action.pathnodes_size(); ++i) {
|
|
@@ -685,7 +703,7 @@ bool Navigation::execute_nodes(NavMessage::NewAction action, int space_id) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
}*/
|
|
}*/
|
|
- if (MoveToTarget(node, mpc_velocity, wmg_limit, anyDirect, true) == false)
|
|
|
|
|
|
+ if (MoveToTarget(node, mpc_velocity, wmg_limit, anyDirect, true, clampLifterAction) == false)
|
|
return false;
|
|
return false;
|
|
else
|
|
else
|
|
isInSpace_ = false;
|
|
isInSpace_ = false;
|
|
@@ -701,7 +719,51 @@ bool Navigation::execute_nodes(NavMessage::NewAction action, int space_id) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
-Navigation::MpcResult Navigation::RotateAfterOutSpace() {
|
|
|
|
|
|
+Navigation::MpcResult Navigation::DoubleOutSpaceCorrectTheta() {
|
|
|
|
+ if (move_mode_ != eDouble)
|
|
|
|
+ return eMpcSuccess;
|
|
|
|
+ Pose2d init = timedPose_.Get();
|
|
|
|
+ double diff1 = fabs(M_PI / 2.0 - init.theta());
|
|
|
|
+ double diff2 = fabs(-M_PI / 2.0 - init.theta());
|
|
|
|
+ double target = diff1 < diff2 ? M_PI / 2.0 : -M_PI / 2.0;
|
|
|
|
+ stLimit limit_rotate = {3 * M_PI / 180.0, 15 * M_PI / 180.0};
|
|
|
|
+ while (cancel_ == false) {
|
|
|
|
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
|
|
|
+ Pose2d current = timedPose_.Get();
|
|
|
|
+ double yawDiff = (target - current.theta());
|
|
|
|
+
|
|
|
|
+ //一次变速
|
|
|
|
+ std::vector<double> out;
|
|
|
|
+ bool ret;
|
|
|
|
+ TimerRecord::Execute([&, this]() {
|
|
|
|
+ ret = Rotation_mpc_once(Pose2d(0, 0, yawDiff), limit_rotate, out);
|
|
|
|
+ }, "Rotation_mpc_once");
|
|
|
|
+ if (ret == false) {
|
|
|
|
+ Stop();
|
|
|
|
+ return eMpcFailed;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //下发速度
|
|
|
|
+ if (fabs(yawDiff) < 0.2 * M_PI / 180.0 && fabs(timedA_.Get()) < 5 * M_PI / 180.0) {
|
|
|
|
+ printf(" DoubleOutSpaceCorrectTheta refer target completed\\n,cuv:%f\n", yawDiff);
|
|
|
|
+ Stop();
|
|
|
|
+ return eMpcSuccess;
|
|
|
|
+ } else {
|
|
|
|
+ const int down_count = 3;
|
|
|
|
+ double v[down_count] = {0, 0, 0};
|
|
|
|
+ double w[down_count] = {out[0], out[1], out[2]};
|
|
|
|
+ SendMoveCmd(0, move_mode_, eRotation, v, w);
|
|
|
|
+ actionType_ = eRotation;
|
|
|
|
+ printf(" DoubleOutSpaceCorrectTheta | input anguar:%f, down:%f(%f), diff:%f anyDirect:false\n",
|
|
|
|
+ timedA_.Get(), out[0], out[0] / M_PI * 180, yawDiff);
|
|
|
|
+ }
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ return eMpcFailed;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+Navigation::MpcResult Navigation::RotateBeforeIntoExport() {
|
|
if (move_mode_ != eDouble)
|
|
if (move_mode_ != eDouble)
|
|
return eMpcSuccess;
|
|
return eMpcSuccess;
|
|
Pose2d init = timedPose_.Get();
|
|
Pose2d init = timedPose_.Get();
|
|
@@ -726,7 +788,7 @@ Navigation::MpcResult Navigation::RotateAfterOutSpace() {
|
|
}
|
|
}
|
|
|
|
|
|
//下发速度
|
|
//下发速度
|
|
- if (fabs(yawDiff) < 0.3 * M_PI / 180.0 && fabs(timedA_.Get()) < 5 * M_PI / 180.0) {
|
|
|
|
|
|
+ if (fabs(yawDiff) < 0.2 * M_PI / 180.0 && fabs(timedA_.Get()) < 5 * M_PI / 180.0) {
|
|
printf(" RotateBeforeEnterSpace refer target completed\\n,cuv:%f\n", yawDiff);
|
|
printf(" RotateBeforeEnterSpace refer target completed\\n,cuv:%f\n", yawDiff);
|
|
Stop();
|
|
Stop();
|
|
return eMpcSuccess;
|
|
return eMpcSuccess;
|
|
@@ -734,10 +796,10 @@ Navigation::MpcResult Navigation::RotateAfterOutSpace() {
|
|
const int down_count = 3;
|
|
const int down_count = 3;
|
|
double v[down_count] = {0, 0, 0};
|
|
double v[down_count] = {0, 0, 0};
|
|
double w[down_count] = {out[0], out[1], out[2]};
|
|
double w[down_count] = {out[0], out[1], out[2]};
|
|
- SendMoveCmd(move_mode_, eRotation, v, w);
|
|
|
|
|
|
+ SendMoveCmd(0, move_mode_, eRotation, v, w);
|
|
actionType_ = eRotation;
|
|
actionType_ = eRotation;
|
|
- printf(" RotateBeforeEnterSpace | input anguar:%f, down:%f(%f), diff:%f anyDirect:false\n",
|
|
|
|
- timedA_.Get(), out[0], out[0] / M_PI * 180, yawDiff);
|
|
|
|
|
|
+// printf(" RotateBeforeEnterSpace | input anguar:%f, down:%f(%f), diff:%f anyDirect:false\n",
|
|
|
|
+// timedA_.Get(), out[0], out[0] / M_PI * 180, yawDiff);
|
|
}
|
|
}
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -745,8 +807,8 @@ Navigation::MpcResult Navigation::RotateAfterOutSpace() {
|
|
}
|
|
}
|
|
|
|
|
|
Navigation::MpcResult
|
|
Navigation::MpcResult
|
|
-Navigation::RotateBeforeEnterSpace(NavMessage::PathNode space,
|
|
|
|
- double wheelbase, NavMessage::PathNode &target) {
|
|
|
|
|
|
+Navigation::RotateBeforeEnterSpace(NavMessage::PathNode space, double wheelbase,
|
|
|
|
+ NavMessage::PathNode &target, int clampLifterAction) {
|
|
// if (timedBrotherNavStatu_.timeout() || timedPose_.timeout()) {
|
|
// if (timedBrotherNavStatu_.timeout() || timedPose_.timeout()) {
|
|
if (timedPose_.timeout()) {
|
|
if (timedPose_.timeout()) {
|
|
printf(" rotate failed : timedBrotherNavStatu_ or pose timeout\n");
|
|
printf(" rotate failed : timedBrotherNavStatu_ or pose timeout\n");
|
|
@@ -828,10 +890,10 @@ Navigation::RotateBeforeEnterSpace(NavMessage::PathNode space,
|
|
const int down_count = 3;
|
|
const int down_count = 3;
|
|
double v[down_count] = {0, 0, 0};
|
|
double v[down_count] = {0, 0, 0};
|
|
double w[down_count] = {out[0], out[1], out[2]};
|
|
double w[down_count] = {out[0], out[1], out[2]};
|
|
- SendMoveCmd(move_mode_, eRotation, v, w);
|
|
|
|
|
|
+ SendMoveCmd(clampLifterAction, move_mode_, eRotation, v, w);
|
|
actionType_ = eRotation;
|
|
actionType_ = eRotation;
|
|
- printf(" RotateBeforeEnterSpace | input anguar:%f, down:%f(%f), diff:%f anyDirect:false\n",
|
|
|
|
- timedA_.Get(), out[0], out[0] / M_PI * 180, yawDiff);
|
|
|
|
|
|
+// printf(" RotateBeforeEnterSpace | input anguar:%f, down:%f(%f), diff:%f anyDirect:false\n",
|
|
|
|
+// timedA_.Get(), out[0], out[0] / M_PI * 180, yawDiff);
|
|
}
|
|
}
|
|
continue;
|
|
continue;
|
|
|
|
|
|
@@ -840,9 +902,36 @@ Navigation::RotateBeforeEnterSpace(NavMessage::PathNode space,
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-bool Navigation::execute_InOut_space(NavMessage::NewAction action) {
|
|
|
|
-// LogWriter("execute_InOut_space beg");
|
|
|
|
|
|
+bool Navigation::IsUperSpace(NavMessage::PathNode spaceNode) {
|
|
|
|
+ if (spaceNode.id().find("S") < 0)
|
|
|
|
+ return false;
|
|
|
|
+ std::string id = spaceNode.id().substr(1, spaceNode.id().length() - 1);
|
|
|
|
+ int space_id = stoi(id);
|
|
|
|
+ if (space_id > 99 && space_id < 1000) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+}
|
|
|
|
|
|
|
|
+int Navigation::GetSpaceId(NavMessage::PathNode spaceNode) {
|
|
|
|
+ if (spaceNode.id().find("S") >= 0) {
|
|
|
|
+ std::string id = spaceNode.id().substr(1, spaceNode.id().length() - 1);
|
|
|
|
+ int space_id = stoi(id);
|
|
|
|
+ return space_id;
|
|
|
|
+ } else {
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool Navigation::TargetIsEntrance(NavMessage::PathNode node) {
|
|
|
|
+ return node.id().find("S1101") != -1;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool Navigation::TargetIsExport(NavMessage::PathNode node) {
|
|
|
|
+ return node.id().find("S1101") != -1;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool Navigation::execute_InOut_space(NavMessage::NewAction action) {
|
|
if (action.type() != 1 && action.type() != 2) {
|
|
if (action.type() != 1 && action.type() != 2) {
|
|
printf(" Inout_space failed : msg action type must ==1\n ");
|
|
printf(" Inout_space failed : msg action type must ==1\n ");
|
|
return false;
|
|
return false;
|
|
@@ -861,38 +950,79 @@ bool Navigation::execute_InOut_space(NavMessage::NewAction action) {
|
|
stLimit limit_w = {2 * M_PI / 180.0, 20 * M_PI / 180.0};
|
|
stLimit limit_w = {2 * M_PI / 180.0, 20 * M_PI / 180.0};
|
|
//入库,起点为streetNode
|
|
//入库,起点为streetNode
|
|
if (action.type() == 1) {
|
|
if (action.type() == 1) {
|
|
-// LogWriter("In space beg-");
|
|
|
|
-
|
|
|
|
Pose2d vec(action.spacenode().x() - action.streetnode().x(),
|
|
Pose2d vec(action.spacenode().x() - action.streetnode().x(),
|
|
action.spacenode().y() - action.streetnode().y(),
|
|
action.spacenode().y() - action.streetnode().y(),
|
|
0);
|
|
0);
|
|
action.mutable_streetnode()->set_l(0.02);
|
|
action.mutable_streetnode()->set_l(0.02);
|
|
action.mutable_streetnode()->set_w(0.2);
|
|
action.mutable_streetnode()->set_w(0.2);
|
|
- action.mutable_streetnode()->set_theta(Pose2d::vector2yaw(vec.x(), vec.y())+M_PI/2.0);
|
|
|
|
|
|
+ action.mutable_streetnode()->set_theta(Pose2d::vector2yaw(vec.x(), vec.y()) + M_PI / 2.0);
|
|
/*
|
|
/*
|
|
* 是否需要添加判断,距离较远才先运动到马路点=============================
|
|
* 是否需要添加判断,距离较远才先运动到马路点=============================
|
|
*/
|
|
*/
|
|
-
|
|
|
|
- if (MoveToTarget(action.streetnode(), limit_v, limit_w, true, true) == false) {
|
|
|
|
|
|
+ int clampLifterAction = 0;
|
|
|
|
+ if (IsUperSpace(action.spacenode())) { //进载车板库前提升机构上升
|
|
|
|
+ clampLifterAction |= eByteLifterUp;
|
|
|
|
+ } else { //否则下降
|
|
|
|
+ clampLifterAction |= eByteLifterDown;
|
|
|
|
+ }
|
|
|
|
+ if (move_mode_ == eSingle)
|
|
|
|
+ clampLifterAction |= eByteClampHalfOpen;
|
|
|
|
+ if (MoveToTarget(action.streetnode(), limit_v, limit_w, true, true, clampLifterAction) == false) {
|
|
printf(" Enter space failed type:%d: MoveTo StreetNode failed\n", action.type());
|
|
printf(" Enter space failed type:%d: MoveTo StreetNode failed\n", action.type());
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
//移动到库位点, 禁止任意方向// 不允许巡线中停下旋转(当无法到达目标点时,返回false)
|
|
//移动到库位点, 禁止任意方向// 不允许巡线中停下旋转(当无法到达目标点时,返回false)
|
|
printf("inout ----------------------------------------\n");
|
|
printf("inout ----------------------------------------\n");
|
|
|
|
+
|
|
|
|
+ //取车流程,送车到出口前旋转180
|
|
|
|
+ if (move_mode_ == eDouble && TargetIsExport(action.spacenode())) {
|
|
|
|
+ Pose2d current_pose = timedPose_.Get();
|
|
|
|
+ double current_theta = current_pose.theta();
|
|
|
|
+ if (RotateBeforeIntoExport() != eMpcSuccess) {
|
|
|
|
+ printf("Rotate before in entrance failed\n");
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
//计算车位朝向
|
|
//计算车位朝向
|
|
action.mutable_spacenode()->set_theta(Pose2d::vector2yaw(vec.x(), vec.y()));
|
|
action.mutable_spacenode()->set_theta(Pose2d::vector2yaw(vec.x(), vec.y()));
|
|
- //计算当前车是进入车位1点还是2点, 提升下降动作与旋转调整并行
|
|
|
|
- if (IsUperSpace(action.spacenode())) { //进载车板库前提升机构上升
|
|
|
|
- lifter_rise();
|
|
|
|
- } else { //否则下降
|
|
|
|
- lifter_down();
|
|
|
|
- }
|
|
|
|
|
|
+ //计算当前车是进入车位1点还是2点,
|
|
NavMessage::PathNode new_target;
|
|
NavMessage::PathNode new_target;
|
|
- bool retRotate=RotateBeforeEnterSpace(action.spacenode(), action.wheelbase(), new_target) == eMpcSuccess;
|
|
|
|
|
|
+ bool retRotate = RotateBeforeEnterSpace(action.spacenode(), action.wheelbase(),
|
|
|
|
+ new_target, clampLifterAction) == eMpcSuccess;
|
|
|
|
|
|
- if(retRotate==false){
|
|
|
|
|
|
+ if (retRotate == false) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
+ //去出入口,等内门打开
|
|
|
|
+ if (TargetIsExport(action.spacenode()) || TargetIsEntrance(action.spacenode())) {
|
|
|
|
+ printf(" Wait Inside door opened.......\n");
|
|
|
|
+ if (WaitInsideDoorOpen(action.spacenode().id()) == false) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ printf(" Wait Inside door opened completed!!!\n");
|
|
|
|
+ } else {
|
|
|
|
+ //去车位点
|
|
|
|
+ if (IsUperSpace(action.spacenode())) {
|
|
|
|
+ printf(" Wait Carrier down.......\n");
|
|
|
|
+ if (WaitCarrierCompleted(0/*待修改*/, eCarrierDown) == false) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ printf(" Wait Carrier down completed!!!\n");
|
|
|
|
+ } else {
|
|
|
|
+ printf(" Wait Carrier up.......\n");
|
|
|
|
+ if (WaitCarrierCompleted(0/*待修改*/, eCarrierUp) == false) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ printf(" Wait Carrier up completed!!!\n");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (IsUperSpace(action.spacenode())) {
|
|
|
|
+ if(lifter_rise()== false){
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
//入库
|
|
//入库
|
|
Pose2d rotated = timedPose_.Get();
|
|
Pose2d rotated = timedPose_.Get();
|
|
@@ -904,20 +1034,20 @@ bool Navigation::execute_InOut_space(NavMessage::NewAction action) {
|
|
if (rotated.theta() < 0.)
|
|
if (rotated.theta() < 0.)
|
|
isFront = !isFront;
|
|
isFront = !isFront;
|
|
// 后进车,且单车,且先进车已过后进车的目标点
|
|
// 后进车,且单车,且先进车已过后进车的目标点
|
|
- Pose2d target(new_target.x(),new_target.y(),0);
|
|
|
|
|
|
+ Pose2d target(new_target.x(), new_target.y(), 0);
|
|
if (isFront == false && move_mode_ == eSingle) {
|
|
if (isFront == false && move_mode_ == eSingle) {
|
|
- while(true) {
|
|
|
|
|
|
+ while (true) {
|
|
if (cancel_) {
|
|
if (cancel_) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
- Pose2d current=timedPose_.Get();
|
|
|
|
|
|
+ Pose2d current = timedPose_.Get();
|
|
Pose2d brother_pose = timedBrotherPose_.Get();
|
|
Pose2d brother_pose = timedBrotherPose_.Get();
|
|
- Pose2d vecCurent2T=current-target;
|
|
|
|
- Pose2d vecBrother2T=brother_pose-target;
|
|
|
|
- double dot=vecCurent2T.x()*vecBrother2T.x()+vecCurent2T.y()*vecBrother2T.y();
|
|
|
|
- if (timedBrotherNavStatu_.Get().in_space() == true && dot<0.) {
|
|
|
|
- printf("先进车已经过后进车目标点,后进车停止等待 dot=%f\n",dot);
|
|
|
|
- break;
|
|
|
|
|
|
+ Pose2d vecCurent2T = current - target;
|
|
|
|
+ Pose2d vecBrother2T = brother_pose - target;
|
|
|
|
+ double dot = vecCurent2T.x() * vecBrother2T.x() + vecCurent2T.y() * vecBrother2T.y();
|
|
|
|
+ if (timedBrotherNavStatu_.Get().in_space() == true && dot < 0.) {
|
|
|
|
+ printf("先进车已经过后进车目标点,后进车停止等待 dot=%f\n", dot);
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
printf(" 后车 等待 先车先入库。。。\n");
|
|
printf(" 后车 等待 先车先入库。。。\n");
|
|
usleep(1000 * 500);
|
|
usleep(1000 * 500);
|
|
@@ -926,14 +1056,26 @@ bool Navigation::execute_InOut_space(NavMessage::NewAction action) {
|
|
}
|
|
}
|
|
isInSpace_ = true;
|
|
isInSpace_ = true;
|
|
printf("Enter space beg...\n");
|
|
printf("Enter space beg...\n");
|
|
- if(move_mode_==eSingle)
|
|
|
|
- clamp_half_open(); //////// 后续再改为全打开位
|
|
|
|
- bool retMove=MoveToTarget(new_target, limit_v, limit_w, true, false);
|
|
|
|
|
|
+ clampLifterAction = 0;
|
|
|
|
+ if (IsUperSpace(action.spacenode())) { //进载车板库前提升机构上升
|
|
|
|
+ clampLifterAction |= eByteLifterUp;
|
|
|
|
+ } else { //否则下降
|
|
|
|
+ clampLifterAction |= eByteLifterDown;
|
|
|
|
+ }
|
|
|
|
+ printf(" clampLifter_statu1 :%d\n", clampLifterAction);
|
|
|
|
+ if (move_mode_ == eSingle)
|
|
|
|
+ clampLifterAction |= eByteClampFullyOpen; //////// 后续再改为全打开位
|
|
|
|
+ else
|
|
|
|
+ clampLifterAction |= eByteCLampClose;
|
|
|
|
+
|
|
|
|
+ printf(" clampLifter_statu2 :%d\n", clampLifterAction);
|
|
|
|
+ bool retMove = MoveToTarget(new_target, limit_v, limit_w, true, false, clampLifterAction);
|
|
|
|
|
|
- if(retMove==false){
|
|
|
|
|
|
+ if (retMove == false) {
|
|
printf(" Enter space:%s failed. type:%d\n", action.spacenode().id().data(), action.type());
|
|
printf(" Enter space:%s failed. type:%d\n", action.spacenode().id().data(), action.type());
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
+
|
|
} else if (action.type() == 2) {
|
|
} else if (action.type() == 2) {
|
|
// LogWriter("Out space beg-");
|
|
// LogWriter("Out space beg-");
|
|
// 计算当前位置,在车位点到马路点的连线方向上,与车位点的相对位姿
|
|
// 计算当前位置,在车位点到马路点的连线方向上,与车位点的相对位姿
|
|
@@ -959,16 +1101,12 @@ bool Navigation::execute_InOut_space(NavMessage::NewAction action) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
isInSpace_ = false;
|
|
isInSpace_ = false;
|
|
- lifter_down();
|
|
|
|
- //从入口出库旋转180
|
|
|
|
- if (move_mode_ == eDouble && action.spacenode().id().find("S1101") != -1) {
|
|
|
|
- Pose2d current_pose = timedPose_.Get();
|
|
|
|
- double current_theta = current_pose.theta();
|
|
|
|
- if (RotateAfterOutSpace() != eMpcSuccess) {
|
|
|
|
- printf("Rotate after out entrance failed\n");
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ if (!lifter_down())
|
|
|
|
+ return false;
|
|
|
|
+ //摆正
|
|
|
|
+ if (DoubleOutSpaceCorrectTheta() != eMpcSuccess)
|
|
|
|
+ return false;
|
|
|
|
+
|
|
}
|
|
}
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -1166,10 +1304,10 @@ void Navigation::SendMoveCmd(int mode, ActionType type,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-void Navigation::SendMoveCmd(int mode, ActionType type,
|
|
|
|
|
|
+void Navigation::SendMoveCmd(int clampLifterAction, int mode, ActionType type,
|
|
double v[], double angular[]) {
|
|
double v[], double angular[]) {
|
|
if (monitor_) {
|
|
if (monitor_) {
|
|
- monitor_->set_ToAgvCmd(mode, type, v, angular);
|
|
|
|
|
|
+ monitor_->set_ToAgvCmd(clampLifterAction, mode, type, v, angular);
|
|
if (type == eRotation)
|
|
if (type == eRotation)
|
|
RWheel_position_ = eR;
|
|
RWheel_position_ = eR;
|
|
if (type == eVertical)
|
|
if (type == eVertical)
|
|
@@ -1179,7 +1317,7 @@ void Navigation::SendMoveCmd(int mode, ActionType type,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-void Navigation::SendMoveCmd(int mode, ActionType type, double v[], double angular[],
|
|
|
|
|
|
+/*void Navigation::SendMoveCmd(int mode, ActionType type, double v[], double angular[],
|
|
int space_id, double distance,double Y1,double Y2) {
|
|
int space_id, double distance,double Y1,double Y2) {
|
|
if (monitor_) {
|
|
if (monitor_) {
|
|
monitor_->set_ToAgvCmd(mode, type, v, angular, 0, space_id, distance,Y1,Y2);
|
|
monitor_->set_ToAgvCmd(mode, type, v, angular, 0, space_id, distance,Y1,Y2);
|
|
@@ -1190,6 +1328,19 @@ void Navigation::SendMoveCmd(int mode, ActionType type, double v[], double angul
|
|
if (type == eHorizontal)
|
|
if (type == eHorizontal)
|
|
RWheel_position_ = eY;
|
|
RWheel_position_ = eY;
|
|
}
|
|
}
|
|
|
|
+}*/
|
|
|
|
+
|
|
|
|
+void Navigation::SendMoveCmd(int clampLifterAction, int mode, ActionType type, double v[], double angular[],
|
|
|
|
+ int space_id, double distance, double Y1, double Y2) {
|
|
|
|
+ if (monitor_) {
|
|
|
|
+ monitor_->set_ToAgvCmd(clampLifterAction, mode, type, v, angular, 0, space_id, distance, Y1, Y2);
|
|
|
|
+ if (type == eRotation)
|
|
|
|
+ RWheel_position_ = eR;
|
|
|
|
+ if (type == eVertical)
|
|
|
|
+ RWheel_position_ = eX;
|
|
|
|
+ if (type == eHorizontal)
|
|
|
|
+ RWheel_position_ = eY;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
//void Navigation::SendMoveCmd(int mode, ActionType type, double v[], double angular[], double yaw_diff[] ,int space_id, double distance) {
|
|
//void Navigation::SendMoveCmd(int mode, ActionType type, double v[], double angular[], double yaw_diff[] ,int space_id, double distance) {
|
|
@@ -1246,28 +1397,17 @@ bool Navigation::clamp_half_open() {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
-bool Navigation::IsUperSpace(NavMessage::PathNode spaceNode) {
|
|
|
|
- if(spaceNode.id().find("S")<0)
|
|
|
|
- return false;
|
|
|
|
- std::string id = spaceNode.id().substr(1, spaceNode.id().length() - 1);
|
|
|
|
- int space_id = stoi(id);
|
|
|
|
- if (space_id > 99 && space_id < 1000) {
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- return false;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-bool Navigation::singleClamp_fullyOpen_until_inspaceBegin(){
|
|
|
|
- if(move_mode_==eDouble){
|
|
|
|
|
|
+bool Navigation::singleClamp_fullyOpen_until_inspaceBegin() {
|
|
|
|
+ if (move_mode_ == eDouble) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
- while(cancel_==false){
|
|
|
|
- if(timedV_.timeout()){
|
|
|
|
|
|
+ while (cancel_ == false) {
|
|
|
|
+ if (timedV_.timeout()) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
- if(fabs(timedV_.Get())<0.02){
|
|
|
|
|
|
+ if (fabs(timedV_.Get()) < 0.02) {
|
|
|
|
|
|
- usleep(1000*300);
|
|
|
|
|
|
+ usleep(1000 * 300);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
@@ -1369,9 +1509,80 @@ bool Navigation::lifter_down() {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
-Navigation::MpcResult Navigation::MpcToTarget(NavMessage::PathNode node, stLimit limit_v, bool autoDirect) {
|
|
|
|
-// LogWriter("MpcToTarget beg");
|
|
|
|
|
|
+bool Navigation::WaitInsideDoorOpen(std::string doorID) {
|
|
|
|
+ return true;
|
|
|
|
+ while (cancel_ == false) {
|
|
|
|
+ if (timed_insideDoor_.timeout()) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ InsideDoorStatu current = timed_insideDoor_.Get();
|
|
|
|
+ /*
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ usleep(1000 * 100);
|
|
|
|
+ }
|
|
|
|
+ if (cancel_ == true) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool Navigation::WaitCarrierCompleted(int carrierID, CarrierStatu statu) {
|
|
|
|
+ return true;
|
|
|
|
+ while (cancel_ == false) {
|
|
|
|
+ if (timed_Carrier_.timeout()) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+// CarrierStatu current = timed_Carrier_.Get();
|
|
|
|
+ /* */
|
|
|
|
+
|
|
|
|
+ usleep(1000 * 100);
|
|
|
|
+ }
|
|
|
|
+ if (cancel_ == true) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool Navigation::WaitClampLifterStatu(int clampLifterAction) {
|
|
|
|
+ int currentStatu = 0;
|
|
|
|
+ while (cancel_ == false) {
|
|
|
|
+ if (timed_clamp_.timeout() || timed_lifter_.timeout()) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ if (timed_clamp_.Get() == eClosed) {
|
|
|
|
+ currentStatu |= eByteCLampClose;
|
|
|
|
+ }
|
|
|
|
+ if (timed_clamp_.Get() == eHalfOpened) {
|
|
|
|
+ currentStatu |= eByteClampHalfOpen;
|
|
|
|
+ }
|
|
|
|
+ if (timed_clamp_.Get() == eFullyOpened) {
|
|
|
|
+ currentStatu |= eByteClampFullyOpen;
|
|
|
|
+ }
|
|
|
|
+ if (timed_lifter_.Get() == eRose) {
|
|
|
|
+ currentStatu |= eByteLifterUp;
|
|
|
|
+ }
|
|
|
|
+ if (timed_lifter_.Get() == eDowned) {
|
|
|
|
+ currentStatu |= eByteLifterDown;
|
|
|
|
+ }
|
|
|
|
+ printf(" current statu:%d action status:%d last:%d\n",
|
|
|
|
+ currentStatu,clampLifterAction,currentStatu&clampLifterAction);
|
|
|
|
+ if((currentStatu&clampLifterAction) == clampLifterAction)
|
|
|
|
+ return true;
|
|
|
|
+
|
|
|
|
+ double down_v[3] = {0, 0, 0};//下发线速度0
|
|
|
|
+ double down_w[3] = {0, 0, 0};//下发角速度0
|
|
|
|
+ SendMoveCmd(clampLifterAction, move_mode_, actionType_, down_v, down_w);
|
|
|
|
+ usleep(1000 * 100);
|
|
|
|
+ }
|
|
|
|
+ if (cancel_ == true) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+Navigation::MpcResult Navigation::MpcToTarget(NavMessage::PathNode node, stLimit limit_v,
|
|
|
|
+ bool autoDirect, int clampLifterAction) {
|
|
if (IsArrived(node)) {
|
|
if (IsArrived(node)) {
|
|
printf(" current already in target completed !!!\n");
|
|
printf(" current already in target completed !!!\n");
|
|
return eMpcSuccess;
|
|
return eMpcSuccess;
|
|
@@ -1400,8 +1611,8 @@ Navigation::MpcResult Navigation::MpcToTarget(NavMessage::PathNode node, stLimit
|
|
} else {
|
|
} else {
|
|
std::cout << " MPC X axis target_relative:" << target_relative << std::endl;
|
|
std::cout << " MPC X axis target_relative:" << target_relative << std::endl;
|
|
}
|
|
}
|
|
- if(!PossibleToTarget(node, directY)){
|
|
|
|
- directY=!directY;
|
|
|
|
|
|
+ if (!PossibleToTarget(node, directY)) {
|
|
|
|
+ directY = !directY;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1438,7 +1649,9 @@ Navigation::MpcResult Navigation::MpcToTarget(NavMessage::PathNode node, stLimit
|
|
if (Stop()) {
|
|
if (Stop()) {
|
|
printf(" exec along completed !!!\n");
|
|
printf(" exec along completed !!!\n");
|
|
ofs.close();//关闭文件
|
|
ofs.close();//关闭文件
|
|
- return eMpcSuccess;
|
|
|
|
|
|
+ bool waited = WaitClampLifterStatu(clampLifterAction);
|
|
|
|
+ if (waited) return eMpcSuccess;
|
|
|
|
+ else return eMpcFailed;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1450,7 +1663,7 @@ Navigation::MpcResult Navigation::MpcToTarget(NavMessage::PathNode node, stLimit
|
|
ret = mpc_once(traj, limit_v, out, directY);
|
|
ret = mpc_once(traj, limit_v, out, directY);
|
|
}, "mpc_once");
|
|
}, "mpc_once");
|
|
if (ret == false) {
|
|
if (ret == false) {
|
|
- Stop();
|
|
|
|
|
|
+ SlowlyStop();
|
|
ofs.close();//关闭文件
|
|
ofs.close();//关闭文件
|
|
return eMpcFailed;
|
|
return eMpcFailed;
|
|
}
|
|
}
|
|
@@ -1507,16 +1720,19 @@ Navigation::MpcResult Navigation::MpcToTarget(NavMessage::PathNode node, stLimit
|
|
std::string id = node.id().substr(1, node.id().length() - 1);
|
|
std::string id = node.id().substr(1, node.id().length() - 1);
|
|
space_id = stoi(id);
|
|
space_id = stoi(id);
|
|
}
|
|
}
|
|
- double Y1=0.0,Y2=0.0;
|
|
|
|
- if(move_mode_==eDouble){
|
|
|
|
- double dy=-timeYawDiff1_.Get();
|
|
|
|
- Y1=0.2*(1.0/(1+exp(-16.*dy))-0.5)*1.0;
|
|
|
|
- Y2=timeYawDiff2_.Get();
|
|
|
|
|
|
+ double Y1 = 0.0, Y2 = 0.0;
|
|
|
|
+ if (move_mode_ == eDouble) {
|
|
|
|
+ double dy = -timeYawDiff1_.Get();
|
|
|
|
+ Y1 = 0.2 * (1.0 / (1 + exp(-16. * dy)) - 0.5) * 1.0;
|
|
|
|
+ Y2 = timeYawDiff2_.Get();
|
|
|
|
+ if (directY == false) {
|
|
|
|
+ Y1 = 0;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
if (directY == false)
|
|
if (directY == false)
|
|
- SendMoveCmd(move_mode_, eVertical, down_v, down_w, space_id, distance,Y1,Y2);
|
|
|
|
|
|
+ SendMoveCmd(clampLifterAction, move_mode_, eVertical, down_v, down_w, space_id, distance, Y1, Y2);
|
|
else
|
|
else
|
|
- SendMoveCmd(move_mode_, eHorizontal, down_v, down_w, space_id, distance,Y1,Y2);
|
|
|
|
|
|
+ SendMoveCmd(clampLifterAction, move_mode_, eHorizontal, down_v, down_w, space_id, distance, Y1, Y2);
|
|
actionType_ = directY ? eHorizontal : eVertical;
|
|
actionType_ = directY ? eHorizontal : eVertical;
|
|
|
|
|
|
//日志打印
|
|
//日志打印
|
|
@@ -1815,3 +2031,61 @@ void Navigation::ManualOperation(const NavMessage::ManualCmd &cmd, NavMessage::N
|
|
// running_ = false;
|
|
// running_ = false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+bool Navigation::IsMasterAGV() {
|
|
|
|
+ return is_master_AGV;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void Navigation::ResetInsideDoor(int32_t status) {
|
|
|
|
+ if ((status & eInsideDoorOpened) == eInsideDoorOpened){
|
|
|
|
+ timed_insideDoor_.reset(eInsideDoorOpened);
|
|
|
|
+ } else if ((status & eInsideDoorClosed) == eInsideDoorClosed){
|
|
|
|
+ timed_insideDoor_.reset(eInsideDoorClosed);
|
|
|
|
+ } else{
|
|
|
|
+ timed_insideDoor_.reset(eInsideDoorInvalid);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void Navigation::anasisCarierStatu(int& regionID, CarrierStatuRegionMap& status, int32_t bytes){
|
|
|
|
+ int bytesize=sizeof(int32_t)*8;
|
|
|
|
+ regionID = (bytes>>((bytesize-1)*8));
|
|
|
|
+ for (int i = 0; i < (bytesize-8)/2; ++i) {
|
|
|
|
+ int statu =(bytes>>(i*2) & 0x03);
|
|
|
|
+
|
|
|
|
+ if ((statu & eCarrierUp) == eCarrierUp) {
|
|
|
|
+ status[i]=eCarrierUp;
|
|
|
|
+ }
|
|
|
|
+ else if ((statu & eCarrierDown) == eCarrierDown){
|
|
|
|
+ status[i]=eCarrierDown;
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ status[i]=eCarrierInvalid;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void Navigation::ResetCarrier(std::vector<int32_t> status) {
|
|
|
|
+ std::map<int,CarrierStatuRegionMap> regionStatus;
|
|
|
|
+ for(int32_t statu : status){
|
|
|
|
+ int regionID;
|
|
|
|
+ CarrierStatuRegionMap region;
|
|
|
|
+ anasisCarierStatu(regionID,region,statu);
|
|
|
|
+ regionStatus[regionID]=region;
|
|
|
|
+ }
|
|
|
|
+ timed_Carrier_.reset(regionStatus);
|
|
|
|
+
|
|
|
|
+ printf("---------------------------------------\n");
|
|
|
|
+ for(std::map<int,CarrierStatuRegionMap>::iterator it=regionStatus.begin();
|
|
|
|
+ it!=regionStatus.end();it++){
|
|
|
|
+ int regionID=it->first;
|
|
|
|
+ printf(">>>>>>> Region ID :%d\n",regionID);
|
|
|
|
+ for(std::map<int,CarrierStatu>::iterator it1=it->second.begin();
|
|
|
|
+ it1!=it->second.end();++it1){
|
|
|
|
+ int id=it1->first;
|
|
|
|
+ CarrierStatu sta=it1->second;
|
|
|
|
+ printf("\t \tcarrier id :%d statu:%d\n",id,sta);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|