|
@@ -292,11 +292,11 @@ bool Navigation::SlowlyStop() {
|
|
|
if (v > 0) {
|
|
|
double new_v = v - acc * dt;
|
|
|
new_v = new_v > 0 ? new_v : 0;
|
|
|
- SendMoveCmd(move_mode_, Monitor_emqx::ActionType(actionType_), new_v, 0);
|
|
|
+ SendMoveCmd(move_mode_, actionType_, new_v, 0);
|
|
|
} else {
|
|
|
double new_v = v + acc * dt;
|
|
|
new_v = new_v < 0 ? new_v : 0;
|
|
|
- SendMoveCmd(move_mode_, Monitor_emqx::ActionType(actionType_), new_v, 0);
|
|
|
+ SendMoveCmd(move_mode_, actionType_, new_v, 0);
|
|
|
}
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
|
|
} else {
|
|
@@ -312,7 +312,7 @@ bool Navigation::SlowlyStop() {
|
|
|
Navigation::Navigation() {
|
|
|
isInSpace_ = false; //是否在车位或者正在进入车位
|
|
|
RWheel_position_ = eUnknow;
|
|
|
- move_mode_ = Monitor_emqx::eSingle;
|
|
|
+ move_mode_ = eSingle;
|
|
|
monitor_ = nullptr;
|
|
|
terminator_ = nullptr;
|
|
|
|
|
@@ -386,7 +386,7 @@ bool Navigation::RotateReferToTarget(const Pose2d &target, stLimit limit_rotate,
|
|
|
double angular = next_speed(timedA_.Get(), theta, acc_angular, dt);
|
|
|
double limit_angular = limit(angular, limit_rotate.min, limit_rotate.max);
|
|
|
|
|
|
- SendMoveCmd(move_mode_, Monitor_emqx::eRotate, 0, limit_angular);
|
|
|
+ SendMoveCmd(move_mode_, eRotation, 0, limit_angular);
|
|
|
actionType_ = eRotation;
|
|
|
printf(" Rotate | input angular:%f,next angular:%f,down:%f diff:%f anyDirect:%d\n",
|
|
|
timedA_.Get(), angular, limit_angular, minYawdiff, anyDirect);
|
|
@@ -475,8 +475,8 @@ Navigation::MpcResult Navigation::RotateReferToTarget(NavMessage::PathNode node,
|
|
|
}
|
|
|
|
|
|
//下发速度
|
|
|
- if (fabs(target_yaw_diff) > 1 * M_PI / 180.0) {
|
|
|
- SendMoveCmd(move_mode_, Monitor_emqx::eRotate, 0, out[0]);
|
|
|
+ if (fabs(target_yaw_diff) > 2 * M_PI / 180.0) {
|
|
|
+ SendMoveCmd(move_mode_, eRotation, 0, out[0]);
|
|
|
actionType_ = eRotation;
|
|
|
printf(" MPC_rotate | input angular_v:%f, down:%f, diff:%f autoDirect:%d\n",
|
|
|
timedA_.Get(), out[0], target_yaw_diff, directions);
|
|
@@ -619,7 +619,7 @@ Navigation::RotateBeforeEnterSpace(NavMessage::PathNode space, double wheelbase,
|
|
|
target.set_id(space.id());
|
|
|
|
|
|
//整车协调的时候,保持前后与车位一致即可
|
|
|
- if (move_mode_ == Monitor_emqx::eMain) {
|
|
|
+ if (move_mode_ == eDouble) {
|
|
|
double yawDiff1 = (rotated - timedPose_.Get()).theta();
|
|
|
double yawDiff2 = (rotated + Pose2d(0, 0, M_PI) - timedPose_.Get()).theta();
|
|
|
if (fabs(yawDiff1) < fabs(yawDiff2)) {
|
|
@@ -645,7 +645,7 @@ Navigation::RotateBeforeEnterSpace(NavMessage::PathNode space, double wheelbase,
|
|
|
|
|
|
//下发速度
|
|
|
if (fabs(yawDiff) > 1 * M_PI / 180.0) {
|
|
|
- SendMoveCmd(move_mode_, Monitor_emqx::eRotate, 0, out[0]);
|
|
|
+ SendMoveCmd(move_mode_, eRotation, 0, out[0]);
|
|
|
actionType_ = eRotation;
|
|
|
printf(" RotateBeforeEnterSpace | input anguar:%f, down:%f diff:%f anyDirect:false\n",
|
|
|
timedA_.Get(), out[0], yawDiff);
|
|
@@ -661,7 +661,7 @@ Navigation::RotateBeforeEnterSpace(NavMessage::PathNode space, double wheelbase,
|
|
|
// double angular = next_speed(timedA_.Get(), theta, acc_angular, dt);
|
|
|
// double limit_angular = limit(angular, limit_rotate.min, limit_rotate.max);
|
|
|
//
|
|
|
-// SendMoveCmd(move_mode_, Monitor_emqx::eRotate, 0, limit_angular);
|
|
|
+// SendMoveCmd(move_mode_, Monitor_emqx::eRotation, 0, limit_angular);
|
|
|
// actionType_ = eRotation;
|
|
|
// printf(" RotateBeforeEnterSpace | input anguar:%f,next angular:%f,down:%f diff:%f anyDirect:false\n",
|
|
|
// timedA_.Get(), angular, limit_angular, yawDiff);
|
|
@@ -774,9 +774,9 @@ bool Navigation::Rotation_mpc_once(Pose2d current_to_target, Navigation::stLimit
|
|
|
|
|
|
MpcError ret = failed;
|
|
|
Pose2d brother = timedBrotherPose_.Get();
|
|
|
- Pose2d relative2brother = Pose2d::relativePose(brother, pose);
|
|
|
-// std::cout<<" relative2brother: "<<relative2brother<<std::endl;
|
|
|
- RotateMPC MPC(relative2brother, obs_w, obs_h, limit_wmg.min, limit_wmg.max);
|
|
|
+ Pose2d brother_in_self = Pose2d::relativePose(brother, pose);
|
|
|
+// std::cout<<" brother_in_self: "<<brother_in_self<<std::endl;
|
|
|
+ RotateMPC MPC(brother_in_self, obs_w, obs_h, limit_wmg.min, limit_wmg.max);
|
|
|
RotateMPC::MPC_parameter parameter = {mpc_parameter.shortest_radius(), mpc_parameter.dt(),
|
|
|
mpc_parameter.acc_velocity(), mpc_parameter.acc_angular()};
|
|
|
ret = MPC.solve(current_to_target, statu, parameter, out);
|
|
@@ -836,7 +836,7 @@ bool Navigation::mpc_once(Trajectory traj, stLimit limit_v, std::vector<double>
|
|
|
relative = Pose2d::relativePose(brother.rotate(brother.x(), brother.y(), M_PI / 2),
|
|
|
pose.rotate(pose.x(), pose.y(), M_PI / 2));//计算另一节在当前小车坐标系下的坐标
|
|
|
//std::cout<<"pose:"<<pose<<", brother:"<<brother<<", relative:"<<relative<<std::endl;
|
|
|
- if (move_mode_ == Monitor_emqx::ActionMode::eMain)
|
|
|
+ if (move_mode_ == ActionMode::eDouble)
|
|
|
relative = Pose2d(-1e8, -1e8, 0);
|
|
|
|
|
|
MpcError ret = failed;
|
|
@@ -892,15 +892,15 @@ bool Navigation::IsArrived(NavMessage::PathNode targetNode) {
|
|
|
|
|
|
}
|
|
|
|
|
|
-void Navigation::SendMoveCmd(Monitor_emqx::ActionMode mode, Monitor_emqx::ActionType type,
|
|
|
+void Navigation::SendMoveCmd(int mode, ActionType type,
|
|
|
double v, double angular) {
|
|
|
if (monitor_) {
|
|
|
monitor_->set_speed(mode, type, v, angular);
|
|
|
- if (mode == ActionType::eRotation)
|
|
|
+ if (type == eRotation)
|
|
|
RWheel_position_ = eR;
|
|
|
- if (mode == ActionType::eVertical)
|
|
|
+ if (type == eVertical)
|
|
|
RWheel_position_ = eX;
|
|
|
- if (mode == ActionType::eHorizon)
|
|
|
+ if (type == eHorizontal)
|
|
|
RWheel_position_ = eY;
|
|
|
}
|
|
|
}
|
|
@@ -1024,11 +1024,12 @@ Navigation::MpcResult Navigation::MpcToTarget(NavMessage::PathNode node, stLimit
|
|
|
out[0] = -limit_v.min;
|
|
|
}
|
|
|
//下发速度
|
|
|
+ printf(" nav input :%f out:%f\n",timedV_.Get(),out[0]);
|
|
|
if (directY == false)
|
|
|
- SendMoveCmd(move_mode_, Monitor_emqx::eVertical, out[0], out[1]);
|
|
|
+ SendMoveCmd(move_mode_, eVertical, out[0], out[1]);
|
|
|
else
|
|
|
- SendMoveCmd(move_mode_, Monitor_emqx::eHorizontal, out[0], out[1]);
|
|
|
- actionType_ = directY ? eHorizon : eVertical;
|
|
|
+ SendMoveCmd(move_mode_, eHorizontal, out[0], out[1]);
|
|
|
+ actionType_ = directY ? eHorizontal : eVertical;
|
|
|
/*
|
|
|
* 判断车辆是否在终点附近徘徊,无法到达终点
|
|
|
*/
|
|
@@ -1059,8 +1060,8 @@ bool Navigation::PossibleToTarget(NavMessage::PathNode targetNode, bool directY)
|
|
|
|
|
|
double W = 2.45;
|
|
|
double L = 1.3;
|
|
|
- double minYaw = 5 * M_PI / 180.0;
|
|
|
- if (move_mode_ == Monitor_emqx::eMain) {
|
|
|
+ double minYaw = 3 * M_PI / 180.0;
|
|
|
+ if (move_mode_ == eDouble) {
|
|
|
L = 1.3 + 2.7;
|
|
|
|
|
|
}
|
|
@@ -1164,7 +1165,7 @@ void Navigation::Start(const NavMessage::NavCmd &cmd, NavMessage::NavResponse &r
|
|
|
break;
|
|
|
}
|
|
|
} else if (act.type() == 8) { //切换模式
|
|
|
- SwitchMode(Monitor_emqx::ActionMode(act.changedmode()), act.wheelbase());
|
|
|
+ SwitchMode(ActionMode(act.changedmode()), act.wheelbase());
|
|
|
} else {
|
|
|
printf(" action type invalid not handled !!\n");
|
|
|
break;
|
|
@@ -1195,7 +1196,7 @@ void Navigation::Start(const NavMessage::NavCmd &cmd, NavMessage::NavResponse &r
|
|
|
running_ = false;
|
|
|
}
|
|
|
|
|
|
-void Navigation::SwitchMode(Monitor_emqx::ActionMode mode, float wheelBase) {
|
|
|
+void Navigation::SwitchMode(int mode, float wheelBase) {
|
|
|
printf("Child AGV can not Switch Mode\n");
|
|
|
}
|
|
|
|
|
@@ -1220,22 +1221,22 @@ void Navigation::ManualOperation(const NavMessage::ManualCmd &cmd, NavMessage::N
|
|
|
switch (cmd.operation_type()) {
|
|
|
case 1: // 旋转
|
|
|
velocity = 2.0 * M_PI / 180.0 * symbol;
|
|
|
- SendMoveCmd(move_mode_, Monitor_emqx::eRotate, 0, velocity);
|
|
|
+ SendMoveCmd(move_mode_, eRotation, 0, velocity);
|
|
|
actionType_ = eRotation;
|
|
|
printf(" ManualOperation: %d | input angular_v: %f, down: %f\n",
|
|
|
cmd.operation_type(), timedA_.Get(), velocity);
|
|
|
break;
|
|
|
case 2: // X平移
|
|
|
velocity = 1.0 * symbol;
|
|
|
- SendMoveCmd(move_mode_, Monitor_emqx::eVertical, velocity, 0);
|
|
|
+ SendMoveCmd(move_mode_, eVertical, velocity, 0);
|
|
|
actionType_ = eVertical;
|
|
|
printf(" ManualOperation: %d | input line_v : %f, down: %f\n",
|
|
|
cmd.operation_type(), timedV_.Get(), velocity);
|
|
|
break;
|
|
|
case 3: // Y平移
|
|
|
velocity = 1.0 * symbol;
|
|
|
- SendMoveCmd(move_mode_, Monitor_emqx::eHorizontal, velocity, 0);
|
|
|
- actionType_ = eHorizon;
|
|
|
+ SendMoveCmd(move_mode_, eHorizontal, velocity, 0);
|
|
|
+ actionType_ = eHorizontal;
|
|
|
printf(" ManualOperation: %d | input line_v: %f, down: %f\n",
|
|
|
cmd.operation_type(), timedV_.Get(), velocity);
|
|
|
break;
|