update
This commit is contained in:
@@ -209,6 +209,22 @@ void readMoveBase2Fields(robot::NodeHandle& nh, MoveBase2Config& config)
|
||||
readInt(nh, "max_planning_retries", config.state_machine.max_planning_retries);
|
||||
readBool(nh, "recovery_behavior_enabled", config.state_machine.recovery_enabled);
|
||||
|
||||
// Nghĩa của Twist đi qua arbiter — quyết định đơn vị của cả cụm giới hạn bên dưới. "steering"
|
||||
// (linear.x = tốc độ bánh steer, angular.z = GÓC lái) là convention của robot lái một bánh
|
||||
// trong workspace; để mặc định "twist" cho robot vi sai. Giá trị lạ giữ nguyên mặc định và
|
||||
// cảnh báo, không chết boot — nhưng validate() của VelocityLimits sẽ chặn tổ hợp vô nghĩa.
|
||||
{
|
||||
std::string semantics = toString(config.velocity.semantics);
|
||||
readString(nh, "command_semantics", semantics);
|
||||
if (semantics == "steering")
|
||||
config.velocity.semantics = CommandSemantics::kSteering;
|
||||
else if (semantics == "twist")
|
||||
config.velocity.semantics = CommandSemantics::kTwist;
|
||||
else
|
||||
robot::log_warning("[move_base2] unknown command_semantics '%s', keeping '%s'",
|
||||
semantics.c_str(), toString(config.velocity.semantics));
|
||||
}
|
||||
|
||||
readDouble(nh, "max_vel_x", config.velocity.max_vel_x);
|
||||
readDouble(nh, "min_vel_x", config.velocity.min_vel_x);
|
||||
readDouble(nh, "max_vel_theta", config.velocity.max_vel_theta);
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#include <cmath>
|
||||
#include <sstream>
|
||||
|
||||
#include <robot/robot.h>
|
||||
|
||||
namespace move_base2
|
||||
{
|
||||
namespace
|
||||
@@ -45,6 +47,11 @@ double clampTo(double value, double lower, double upper, bool& clamped)
|
||||
// VelocityLimits
|
||||
// ================================================================================================
|
||||
|
||||
const char* toString(CommandSemantics semantics)
|
||||
{
|
||||
return semantics == CommandSemantics::kSteering ? "steering" : "twist";
|
||||
}
|
||||
|
||||
bool VelocityLimits::validate(std::string& error) const
|
||||
{
|
||||
if (!(max_vel_x > 0.0))
|
||||
@@ -60,7 +67,17 @@ bool VelocityLimits::validate(std::string& error) const
|
||||
}
|
||||
if (!(max_vel_theta > 0.0))
|
||||
{
|
||||
error = "max_vel_theta must be > 0 [rad/s]";
|
||||
error = semantics == CommandSemantics::kSteering
|
||||
? "max_vel_theta must be > 0 [rad] (steering semantics: mechanical steer limit)"
|
||||
: "max_vel_theta must be > 0 [rad/s]";
|
||||
return false;
|
||||
}
|
||||
if (semantics == CommandSemantics::kSteering && max_vel_theta > M_PI)
|
||||
{
|
||||
// Một GÓC lái quá pi không tồn tại về cơ khí — gần như chắc chắn là người vận hành đang điền
|
||||
// yaw-rate vào profile steering, tức chọn nhầm semantics. Chết ở boot rẻ hơn kẹt giữa ca.
|
||||
error = "max_vel_theta must be <= pi [rad] under steering semantics (it is the MECHANICAL "
|
||||
"steering-angle limit; a larger value means the wrong command_semantics is selected)";
|
||||
return false;
|
||||
}
|
||||
if (!(max_accel_x > 0.0))
|
||||
@@ -83,14 +100,21 @@ bool VelocityLimits::validate(std::string& error) const
|
||||
|
||||
std::string VelocityLimits::describe() const
|
||||
{
|
||||
// In đúng đơn vị theo semantics: dòng log lúc boot là chỗ duy nhất người vận hành đối chiếu
|
||||
// được con số với thực tế cơ khí; in "rad/s" cho một góc lái là giấu đúng cái lỗi cần thấy.
|
||||
const bool steering = semantics == CommandSemantics::kSteering;
|
||||
|
||||
std::ostringstream out;
|
||||
out << "VelocityLimits:\n";
|
||||
out << " max_vel_x : " << max_vel_x << " m/s (forward)\n";
|
||||
out << "VelocityLimits (" << toString(semantics) << " semantics):\n";
|
||||
out << " max_vel_x : " << max_vel_x
|
||||
<< (steering ? " m/s (steer-wheel speed, forward)" : " m/s (forward)") << '\n';
|
||||
out << " min_vel_x : " << min_vel_x << " m/s (reverse"
|
||||
<< (min_vel_x == 0.0 ? ", reversing forbidden" : "") << ")\n";
|
||||
out << " max_vel_theta : " << max_vel_theta << " rad/s\n";
|
||||
out << " max_vel_theta : " << max_vel_theta
|
||||
<< (steering ? " rad (MECHANICAL steering-angle limit)" : " rad/s") << '\n';
|
||||
out << " max_accel_x : " << max_accel_x << " m/s^2\n";
|
||||
out << " max_accel_theta : " << max_accel_theta << " rad/s^2\n";
|
||||
out << " max_accel_theta : " << max_accel_theta
|
||||
<< (steering ? " rad/s (steering slew limit)" : " rad/s^2") << '\n';
|
||||
out << " zero_velocity_epsilon: " << zero_velocity_epsilon << '\n';
|
||||
return out.str();
|
||||
}
|
||||
@@ -126,6 +150,7 @@ void VelocityArbiter::reset()
|
||||
velocity_clamps_ = 0;
|
||||
acceleration_clamps_ = 0;
|
||||
handover_cycles_ = 0;
|
||||
steering_angle_clamps_ = 0;
|
||||
}
|
||||
|
||||
bool VelocityArbiter::stopped() const
|
||||
@@ -151,8 +176,28 @@ robot_geometry_msgs::Twist VelocityArbiter::sanitize(const robot_geometry_msgs::
|
||||
|
||||
bool clamped = false;
|
||||
clean.linear.x = clampTo(candidate.linear.x, limits_.min_vel_x, limits_.max_vel_x, clamped);
|
||||
|
||||
bool angular_clamped = false;
|
||||
clean.angular.z =
|
||||
clampTo(candidate.angular.z, -limits_.max_vel_theta, limits_.max_vel_theta, clamped);
|
||||
clampTo(candidate.angular.z, -limits_.max_vel_theta, limits_.max_vel_theta, angular_clamped);
|
||||
clamped = clamped || angular_clamped;
|
||||
|
||||
// Dưới steering semantics, angular.z là GÓC LÁI: một lệnh vượt trần không phải nhiễu mà là
|
||||
// xung đột cấu hình (trần khai sai so với cơ khí, hoặc planner xin góc không tồn tại). Phiên
|
||||
// bản không có tiếng hét này đã kẹt pivot 40 giây trong câm lặng: lệnh 1.5708 bị kẹp còn 1.0,
|
||||
// servo tới 1.0 rồi đứng, gate align không bao giờ mở. Hét lần đầu ngay, sau đó thưa dần —
|
||||
// không spam control loop nhưng không bao giờ im hẳn khi lỗi còn đó.
|
||||
if (angular_clamped && limits_.semantics == CommandSemantics::kSteering)
|
||||
{
|
||||
++steering_angle_clamps_;
|
||||
if (steering_angle_clamps_ == 1 || steering_angle_clamps_ % 300 == 0)
|
||||
{
|
||||
robot::log_error("[move_base2] steering-angle command %.4f rad exceeds max_vel_theta %.4f "
|
||||
"rad and was clamped (%zu times so far) — either raise max_vel_theta to "
|
||||
"the mechanical steering limit or fix the planner's align/steer config",
|
||||
candidate.angular.z, limits_.max_vel_theta, steering_angle_clamps_);
|
||||
}
|
||||
}
|
||||
|
||||
// Robot của workspace là phi holonomic ở mức contract cmd_vel: mọi thành phần còn lại bị bỏ, cố
|
||||
// ý không truyền tiếp để tránh một plugin lạ đẩy ra trục mà tầng dưới không kiểm.
|
||||
|
||||
Reference in New Issue
Block a user