Drop the separate calibration terms, keep one set of offsets
The split existed to stop a footprint change from silently discarding a field correction tuned into the same number. Two knobs per axis is a cost paid on every read of the config, and the person tuning these is the one who knows which part is which, so the simpler shape wins. The derivation stays where it matters: the formula for offset_x - half the robot, the padding, the wing projection, the clearance - is written out in the runtime config next to the value, so recomputing it after a footprint change does not start from a guess.
This commit is contained in:
@@ -13,12 +13,6 @@ namespace dock_pattern_detector
|
||||
namespace
|
||||
{
|
||||
|
||||
/// [m] Trần hiệu chỉnh tịnh tiến. Xem lý do ở validate().
|
||||
constexpr double kMaxCalibXy = 0.30;
|
||||
|
||||
/// [rad] Trần hiệu chỉnh góc, ~11 độ.
|
||||
constexpr double kMaxCalibYaw = 0.20;
|
||||
|
||||
bool positive(double value)
|
||||
{
|
||||
return std::isfinite(value) && value > 0.0;
|
||||
@@ -130,26 +124,6 @@ bool DockProfile::validate(std::string& error) const
|
||||
error = "offset_x/offset_y/offset_yaw must be finite";
|
||||
return false;
|
||||
}
|
||||
if (!std::isfinite(calib_x) || !std::isfinite(calib_y) || !std::isfinite(calib_yaw))
|
||||
{
|
||||
error = "calib_x/calib_y/calib_yaw must be finite";
|
||||
return false;
|
||||
}
|
||||
// Chặn trên có chủ đích. Hiệu chỉnh hiện trường là centimet và độ; ai gõ 0.5 m vào đây thì thứ
|
||||
// họ đang bù không phải sai số cảm biến mà là một lỗi hình học ở `offset_*` — và dán băng dính
|
||||
// lên nó bằng calib là giấu mất nguyên nhân.
|
||||
if (std::fabs(calib_x) > kMaxCalibXy || std::fabs(calib_y) > kMaxCalibXy)
|
||||
{
|
||||
error = "calib_x/calib_y must be within +-" + std::to_string(kMaxCalibXy) +
|
||||
" m; a larger correction means offset_x/offset_y is wrong, not miscalibrated";
|
||||
return false;
|
||||
}
|
||||
if (std::fabs(calib_yaw) > kMaxCalibYaw)
|
||||
{
|
||||
error = "calib_yaw must be within +-" + std::to_string(kMaxCalibYaw) +
|
||||
" rad; a larger correction means the pattern geometry is wrong";
|
||||
return false;
|
||||
}
|
||||
if (min_wing_points < 2)
|
||||
{
|
||||
// Hai điểm là tối thiểu tuyệt đối để có một đoạn; dưới đó không có gì để khớp.
|
||||
|
||||
@@ -273,17 +273,13 @@ Detection VPatternMatcher::match(const std::vector<Line>& lines) const
|
||||
best.measured_wing_length[1] = len2;
|
||||
|
||||
// Pose đích = đỉnh dịch theo offset của profile, trong hệ của CHÍNH hình: x dọc pháp tuyến
|
||||
// hướng ra phía robot, y sang trái. `calib_*` cộng thẳng vào offset — cùng hệ quy chiếu, chỉ
|
||||
// khác nguồn gốc: offset suy ra từ hình học, calib đo được ngoài hiện trường.
|
||||
const double dx = profile_.offset_x + profile_.calib_x;
|
||||
const double dy = profile_.offset_y + profile_.calib_y;
|
||||
const double dyaw = profile_.offset_yaw + profile_.calib_yaw;
|
||||
|
||||
// hướng ra phía robot, y sang trái.
|
||||
const double cos_y = std::cos(yaw);
|
||||
const double sin_y = std::sin(yaw);
|
||||
best.x = apex.x + cos_y * dx - sin_y * dy;
|
||||
best.y = apex.y + sin_y * dx + cos_y * dy;
|
||||
best.yaw = std::atan2(std::sin(yaw + dyaw), std::cos(yaw + dyaw));
|
||||
best.x = apex.x + cos_y * profile_.offset_x - sin_y * profile_.offset_y;
|
||||
best.y = apex.y + sin_y * profile_.offset_x + cos_y * profile_.offset_y;
|
||||
best.yaw = std::atan2(std::sin(yaw + profile_.offset_yaw),
|
||||
std::cos(yaw + profile_.offset_yaw));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user