feat(rotate): áp relative_yaw trong resolveDeferredGoal, đổi binding rotate

- NavigationRequest: thêm relative_yaw [rad], NaN = không dùng, đi kèm
  được với goal_frame/relative_distance thay vì loại trừ.

- resolveDeferredGoal(): thêm nhánh has_yaw. Trước đây relative_distance
  = 0 khiến goal CHÉP NGUYÊN pose hiện tại kể cả orientation — chặng
  rotate coi như đã tới đích ngay khi nhận, không quay độ nào. Giờ tính
  yaw nền (từ pose hiện tại, hoặc từ frame nếu goal_frame có) rồi cộng
  relative_yaw, dựng lại quaternion đủ 4 thành phần. Log "Goal received"
  thêm yaw= để chặng quay không còn trông giống hệt chặng vị trí.

- mission_adapter_bridge.cpp: chở relative_yaw qua nguyên vẹn.

- Thêm 3 dòng debug (nhóm debug_plan, mặc định bật) trong
  runController(): kết quả isGoalReached() khi true (candidate=0, chưa
  từng tính lệnh), v/omega trước arbiter, v/omega sau arbiter — phân
  biệt "chưa từng có lệnh" / "lệnh bị cắt" / "lỗi ngoài move_base2".
  Bật khối log đã có sẵn nhưng bị comment từ trước.

- Binding rotate: PNKXRotateLocalPlanner -> HybridRotateLocalPlanner.

- 13 test mới (deferred_goal_test.cpp + 2 ca bridge): quay giữ nguyên
  x/y chỉ đổi yaw, góc là delta theo hướng hiện tại, dấu âm quay ngược,
  quaternion chuẩn hoá, go_straight không bị đụng hướng, distance+yaw
  đi cùng nhau, frame+yaw lấy nền là hướng robot chứ không phải hướng
  frame đích, mất pose bị từ chối, NaN passthrough.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-11 10:46:58 +07:00
parent 180c0e1cd4
commit 7d00c5ab66
10 changed files with 606 additions and 30 deletions

View File

@@ -132,12 +132,49 @@ public:
pose_.pose.orientation.w = 1.0;
}
/// @param yaw [rad] hướng robot; cần cho mọi chặng quy từ pose tương đối.
void setYaw(double yaw)
{
pose_.header.frame_id = "map";
pose_.pose.orientation.x = 0.0;
pose_.pose.orientation.y = 0.0;
pose_.pose.orientation.z = std::sin(0.5 * yaw);
pose_.pose.orientation.w = std::cos(0.5 * yaw);
}
/// @brief false = mô phỏng TF thiếu/stale.
void setAvailable(bool available)
{
available_ = available;
}
/**
* @brief Đăng một frame mà @ref lookupPose tra được.
* @param x,y [m] ; @param yaw [rad] hướng của CHÍNH frame đó, không phải của robot.
*/
void setFramePose(const std::string& frame, double x, double y, double yaw)
{
robot_geometry_msgs::PoseStamped pose;
pose.header.frame_id = "map";
pose.pose.position.x = x;
pose.pose.position.y = y;
pose.pose.orientation.z = std::sin(0.5 * yaw);
pose.pose.orientation.w = std::cos(0.5 * yaw);
frames_[frame] = pose;
}
bool lookupPose(const std::string& frame,
robot_geometry_msgs::PoseStamped& pose) const override
{
const auto it = frames_.find(frame);
if (it == frames_.end())
{
return false;
}
pose = it->second;
return true;
}
std::size_t callCount() const
{
return call_count_;
@@ -145,6 +182,7 @@ public:
private:
robot_geometry_msgs::PoseStamped pose_;
std::map<std::string, robot_geometry_msgs::PoseStamped> frames_;
bool available_ = true;
mutable std::size_t call_count_ = 0;
};
@@ -191,6 +229,12 @@ public:
return in_flight_;
}
/// @brief Goal mà lõi đã trao cho lượt lập plan gần nhất — đích SAU khi đã quy từ dạng tương đối.
const robot_geometry_msgs::PoseStamped& pendingGoal() const
{
return pending_goal_;
}
bool pollPlan(PlanResult& result) override
{
if (!in_flight_)