This commit is contained in:
2026-08-10 21:50:42 +07:00
parent 65f8c7ce1c
commit a2a2ea2829
12 changed files with 713 additions and 74 deletions

View File

@@ -10,6 +10,7 @@
#include <cmath>
#include <mission_adapters/mission_request.h>
#include <robot_nav_2d_utils/conversions.h>
namespace move_base2
@@ -746,7 +747,11 @@ bool NavigationServer::removeAllData()
}
// ================================================================================================
// Sáu entry point di chuyển -> một NavigationRequest
// Hai entry point di chuyển -> một NavigationRequest
//
// Bốn entry point mang profile riêng (`dockTo` ×2, `moveStraightTo`, `rotateTo`) đã bị gỡ khỏi
// contract host: chúng submit thẳng vào lõi, bỏ qua mission layer. Docking/go-straight/rotate giờ
// đi qua `profile:` và `marker` của từng chặng trong order — xem MissionAdapterBridge::toProfile.
// ================================================================================================
bool NavigationServer::submit(const NavigationRequest& request)
@@ -814,51 +819,28 @@ bool NavigationServer::moveTo(const robot_protocol_msgs::Order& msg,
return submit(request);
}
bool NavigationServer::dockTo(const std::string& maker,
const robot_geometry_msgs::PoseStamped& goal,
double xy_goal_tolerance, double yaw_goal_tolerance)
bool NavigationServer::executeInstantActions(
const std::vector<robot_protocol_msgs::Action>& actions)
{
(void)xy_goal_tolerance;
(void)yaw_goal_tolerance;
NavigationRequest request;
request.profile = MotionProfile::kDocking;
request.goal = goal;
request.marker = maker;
return submit(request);
}
// KHÔNG có đường rơi xuống `submit()` như `moveTo`. Một instantAction chỉ có nghĩa khi mission
// layer nở nó theo bảng compound: đẩy thẳng xuống lõi sẽ biến `PickUp` thành một chặng chỉ-action
// không có bước dò và không có bước tiến vào, tức robot báo "đã nâng kệ" khi càng còn chưa tới
// gần kệ. Layer tắt thì phải từ chối để host báo FAILED ngay, thay vì chờ một kết quả không đến.
if (runtime_ == nullptr || !runtime_->missionLayer().submitInstantActions(actions))
{
const std::string first = actions.empty() ? std::string("<empty>") : actions.front().actionType;
bool NavigationServer::dockTo(const robot_protocol_msgs::Order& msg, const std::string& marker,
const robot_geometry_msgs::PoseStamped& goal,
double xy_goal_tolerance, double yaw_goal_tolerance)
{
(void)xy_goal_tolerance;
(void)yaw_goal_tolerance;
NavigationRequest request;
request.profile = MotionProfile::kDocking;
request.goal = goal;
request.marker = marker;
request.order = std::make_shared<robot_protocol_msgs::Order>(msg);
return submit(request);
}
last_reject_reason_ = "mission layer cannot accept instant actions";
nav_feedback_->feed_back_str =
"instant action '" + first + "' rejected: " + last_reject_reason_;
robot::log_error("[move_base2] instantActions message rejected (%zu action(s), first '%s') — "
"mission layer not running, empty message, or no source declares schema '%s'.",
actions.size(), first.c_str(), mission_adapters::schema::kInstantAction);
return false;
}
bool NavigationServer::moveStraightTo(const robot_geometry_msgs::PoseStamped& goal,
double xy_goal_tolerance)
{
(void)xy_goal_tolerance;
NavigationRequest request;
request.profile = MotionProfile::kGoStraight;
request.goal = goal;
return submit(request);
}
bool NavigationServer::rotateTo(const robot_geometry_msgs::PoseStamped& goal,
double yaw_goal_tolerance)
{
(void)yaw_goal_tolerance;
NavigationRequest request;
request.profile = MotionProfile::kRotate;
request.goal = goal;
return submit(request);
last_reject_reason_.clear();
return true;
}
// ================================================================================================