feat: route a profile to the matcher its pattern names, and add an arc dock model
The handler held one concrete VPatternMatcher, so a profile declaring pattern: arc could not reach the arc matcher at all. It now picks by pattern at start(), reads the arc_* keys from YAML, and calls whichever matcher the profile named. An explicit switch, not a virtual interface: the set of patterns is a closed enum, each matcher weighs one DockProfile, and adding a shape is one member and two branches - cheaper than an abstraction layer over two implementations. Each matcher refuses a profile that is not its own, so a branch missing from that switch shows up at BOOT with the pattern named, not at runtime as "it never detects". Intensities go only to the V matcher. findTape walks the ray span of a fitted line segment and an arc produces none, so an arc profile that sets tape_enabled is already refused when the config loads. sim/models/dock_cradle_arc is a concave cradle, radius 0.40 m over 2.0 rad, for testing this in Gazebo. Its origin sits ON the deepest point, unlike dock_plate_v whose origin is 0.2121 m off the apex and has caused confusion: the detector reports the deepest point, so here that is the same number you spawn at, with nothing to subtract. It is 24 flat facets rather than a mesh, because Gazebo classic has no arc primitive and a mesh means a binary file in the repo. The approximation error is the sagitta of one chord, 0.35 mm - an order below the 3 mm range noise, so the circle fit cannot tell it from a real curve. Two tests pin the routing rather than the matching rules, which have their own tests in dock_pattern_detector: a cradle under an arc profile writes the goal frame at the deepest point, and a V plate under the same arc profile is rejected. Without the second one, a change that broke arc detection outright would look exactly like the gate doing its job.
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include <tf3/buffer_core.h>
|
||||
|
||||
#include <action_core/pose_sample_filter.h>
|
||||
#include <dock_pattern_detector/arc_pattern_matcher.h>
|
||||
#include <dock_pattern_detector/v_pattern_matcher.h>
|
||||
#include <robot_line_extraction/line_extractor.h>
|
||||
#include <robot_sensor_ports/sensor_reader.h>
|
||||
@@ -217,8 +218,19 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
// Chọn bộ khớp theo biên dạng của profile. Một switch tường minh chứ không phải interface ảo:
|
||||
// tập biên dạng là một enum ĐÓNG, mỗi bộ khớp chỉ nặng bằng một DockProfile, và thêm dạng mới
|
||||
// là thêm một member cộng hai nhánh — rẻ hơn một tầng ảo cho hai hiện thực.
|
||||
//
|
||||
// Mỗi bộ khớp tự từ chối profile không thuộc về nó, nên nếu switch này quên một nhánh thì lỗi
|
||||
// hiện ra lúc BOOT kèm tên biên dạng, không phải lúc chạy dưới dạng "dò mãi không ra".
|
||||
std::string error;
|
||||
if (!matcher_.configure(found->second, error))
|
||||
active_pattern_ = found->second.pattern;
|
||||
const bool configured =
|
||||
(active_pattern_ == dock_pattern_detector::PatternType::kArc)
|
||||
? arc_matcher_.configure(found->second, error)
|
||||
: v_matcher_.configure(found->second, error);
|
||||
if (!configured)
|
||||
{
|
||||
robot::log_error("[dock_pattern] '%s': profile '%s' is invalid: %s", name_.c_str(),
|
||||
profile_name.c_str(), error.c_str());
|
||||
@@ -350,6 +362,16 @@ private:
|
||||
nh_param(p_nh, "offset_yaw", profile.offset_yaw);
|
||||
nh_param(p_nh, "min_confidence", profile.min_confidence);
|
||||
|
||||
nh_param(p_nh, "arc_radius", profile.arc_radius);
|
||||
nh_param(p_nh, "arc_radius_tolerance", profile.arc_radius_tolerance);
|
||||
nh_param(p_nh, "arc_span", profile.arc_span);
|
||||
nh_param(p_nh, "arc_min_span", profile.arc_min_span);
|
||||
nh_param(p_nh, "arc_max_rms", profile.arc_max_rms);
|
||||
|
||||
int min_arc_points = static_cast<int>(profile.min_arc_points);
|
||||
nh_param(p_nh, "min_arc_points", min_arc_points);
|
||||
profile.min_arc_points = static_cast<std::size_t>(std::max(0, min_arc_points));
|
||||
|
||||
nh_param(p_nh, "tape_enabled", profile.tape_enabled);
|
||||
nh_param(p_nh, "tape_spacing", profile.tape_spacing);
|
||||
nh_param(p_nh, "tape_width", profile.tape_width);
|
||||
@@ -470,7 +492,13 @@ private:
|
||||
|
||||
// `intensities` đi thẳng, không đổi kiểu: message đã là std::vector<float>. Rỗng khi driver
|
||||
// không gửi cường độ — matcher tự nói ra điều đó nếu profile lại đang đòi dải phản quang.
|
||||
const dock_pattern_detector::Detection detection = matcher_.match(lines_, scan->intensities);
|
||||
//
|
||||
// Cung tròn không nhận cường độ: `findTape` quét theo chỉ số tia của một ĐOẠN THẲNG, mà cung
|
||||
// không sinh ra đoạn nào. Profile `arc` bật `tape_enabled` đã bị từ chối từ lúc boot.
|
||||
const dock_pattern_detector::Detection detection =
|
||||
(active_pattern_ == dock_pattern_detector::PatternType::kArc)
|
||||
? arc_matcher_.match(lines_)
|
||||
: v_matcher_.match(lines_, scan->intensities);
|
||||
if (!detection.valid)
|
||||
{
|
||||
noteReason(now, detection.reason);
|
||||
@@ -483,16 +511,17 @@ private:
|
||||
// quang đang bật. Đây là số người lắp trạm cần để đặt dung sai: dán dải lệch vài centimet vẫn
|
||||
// dò ra hôm nay rồi trượt hẳn khi trời ẩm hoặc dải bẩn bớt sáng, mà không có dòng này thì
|
||||
// không ai biết nó vốn đã sát mép. Chỉ in một lần vì nó là số hiệu chỉnh, không phải nhịp chạy.
|
||||
if (matcher_.profile().tape_enabled && !tape_reported_)
|
||||
if (active_pattern_ != dock_pattern_detector::PatternType::kArc &&
|
||||
v_matcher_.profile().tape_enabled && !tape_reported_)
|
||||
{
|
||||
tape_reported_ = true;
|
||||
robot::log_info("[dock_pattern] '%s': reflective tape: %zu + %zu bright ray(s), spacing "
|
||||
"%.3f m (profile %.3f+-%.3f), widths %.3f / %.3f m (profile %.3f+-%.3f).",
|
||||
name_.c_str(), detection.tape_points[0], detection.tape_points[1],
|
||||
detection.measured_tape_spacing, matcher_.profile().tape_spacing,
|
||||
matcher_.profile().tape_spacing_tolerance, detection.measured_tape_width[0],
|
||||
detection.measured_tape_width[1], matcher_.profile().tape_width,
|
||||
matcher_.profile().tape_width_tolerance);
|
||||
detection.measured_tape_spacing, v_matcher_.profile().tape_spacing,
|
||||
v_matcher_.profile().tape_spacing_tolerance,
|
||||
detection.measured_tape_width[0], detection.measured_tape_width[1],
|
||||
v_matcher_.profile().tape_width, v_matcher_.profile().tape_width_tolerance);
|
||||
}
|
||||
|
||||
pending_ = detection;
|
||||
@@ -645,7 +674,9 @@ private:
|
||||
std::map<std::string, dock_pattern_detector::DockProfile> profiles_;
|
||||
|
||||
robot_line_extraction::LineExtractor extractor_;
|
||||
dock_pattern_detector::VPatternMatcher matcher_;
|
||||
dock_pattern_detector::VPatternMatcher v_matcher_;
|
||||
dock_pattern_detector::ArcPatternMatcher arc_matcher_;
|
||||
dock_pattern_detector::PatternType active_pattern_ = dock_pattern_detector::PatternType::kV;
|
||||
PoseSampleFilter filter_;
|
||||
|
||||
robot::Time started_at_;
|
||||
|
||||
37
sim/launch/spawn_dock_cradle.launch
Normal file
37
sim/launch/spawn_dock_cradle.launch
Normal file
@@ -0,0 +1,37 @@
|
||||
<!--
|
||||
Dựng một máng cong LÕM vào world Gazebo đang chạy.
|
||||
|
||||
Chạy SAU khi world đã lên:
|
||||
roslaunch dock_pattern_action spawn_dock_cradle.launch x:=3.0 y:=0.0 yaw:=3.14159
|
||||
|
||||
⚠ Gazebo TỪ CHỐI spawn đè lên model cùng tên: "SpawnModel: Failure - entity already exists".
|
||||
Đã spawn một lần rồi thì phải xoá trước, nếu không thứ nằm trong world vẫn là BẢN CŨ:
|
||||
|
||||
rosservice call /gazebo/delete_model "model_name: 'dock_cradle_arc'"
|
||||
|
||||
KHÁC `spawn_dock_plate.launch` ở một điểm đáng nhớ: gốc model của máng đặt ĐÚNG TẠI ĐIỂM SÂU
|
||||
NHẤT. Bộ dò báo toạ độ điểm sâu nhất, nên nó trùng luôn với `x`/`y` khai ở đây — không phải trừ
|
||||
đi một khoảng như với tấm chữ V (gốc tấm V lệch 0.2121 m so với đỉnh).
|
||||
|
||||
`yaw` quay máng; lòng máng mở về phía -X của chính nó, nên mặc định 3.14159 để lòng hướng về +X
|
||||
của world, tức robot đứng phía +X nhìn vào.
|
||||
|
||||
Hình học của model KHỚP một profile `pattern: arc` với `arc_radius: 0.40` và `arc_span: 2.0`.
|
||||
Đổi model thì phải đổi profile theo, nếu không cổng `arc_radius` sẽ loại đúng cái máng vừa dựng.
|
||||
-->
|
||||
<launch>
|
||||
<arg name="x" default="3.0" />
|
||||
<arg name="y" default="0.0" />
|
||||
<arg name="z" default="0.0" />
|
||||
<arg name="yaw" default="3.14159" />
|
||||
<arg name="name" default="dock_cradle_arc" />
|
||||
|
||||
<!-- Gazebo tìm model theo GAZEBO_MODEL_PATH; trỏ thẳng vào thư mục sim/models của gói này. -->
|
||||
<env name="GAZEBO_MODEL_PATH"
|
||||
value="$(find dock_pattern_action)/sim/models:$(optenv GAZEBO_MODEL_PATH)" />
|
||||
|
||||
<node name="spawn_$(arg name)" pkg="gazebo_ros" type="spawn_model" output="screen"
|
||||
args="-sdf -file $(find dock_pattern_action)/sim/models/dock_cradle_arc/model.sdf
|
||||
-model $(arg name)
|
||||
-x $(arg x) -y $(arg y) -z $(arg z) -Y $(arg yaw)" />
|
||||
</launch>
|
||||
9
sim/models/dock_cradle_arc/model.config
Normal file
9
sim/models/dock_cradle_arc/model.config
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0"?>
|
||||
<model>
|
||||
<name>dock_cradle_arc</name>
|
||||
<version>1.0</version>
|
||||
<sdf version="1.6">model.sdf</sdf>
|
||||
<description>
|
||||
Mang cong lom ban kinh 0.40 m, mo 2.0 rad. Goc model dat tai DIEM SAU NHAT cua mang.
|
||||
</description>
|
||||
</model>
|
||||
283
sim/models/dock_cradle_arc/model.sdf
Normal file
283
sim/models/dock_cradle_arc/model.sdf
Normal file
@@ -0,0 +1,283 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
Máng cong LÕM — biên dạng `arc`.
|
||||
|
||||
Hình học phải KHỚP profile arc trong action_handlers_params.yaml:
|
||||
arc_radius = 0.40 m
|
||||
arc_span = 2.00 rad (115 độ)
|
||||
|
||||
GỐC MODEL ĐẶT ĐÚNG TẠI ĐIỂM SÂU NHẤT của máng — khác hẳn `dock_plate_v`, nơi gốc lệch 0.2121 m
|
||||
so với đỉnh và đã gây nhầm lẫn. Ở đây bộ dò báo toạ độ điểm sâu nhất, và đó chính là chỗ anh
|
||||
spawn model. Hai con số trùng nhau, không phải trừ đi cái gì.
|
||||
|
||||
tâm đường tròn = (-0.40, 0) trong hệ model, tức nằm PHÍA ROBOT so với mặt cong.
|
||||
|
||||
Đó là điều phân biệt máng lõm với trụ tròn, và matcher kiểm đúng chỗ đó: nhận nhầm trụ thành
|
||||
máng là pose đích rơi ra SAU mặt trụ, tức robot được lệnh lái vào trong vật.
|
||||
|
||||
Máng mở về phía -X của model. Launch spawn mặc định `yaw:=3.14159` để lật lại, khi đó lòng máng
|
||||
hướng về +X của world và robot đứng phía +X nhìn vào.
|
||||
|
||||
DỰNG BẰNG 24 TẤM PHẲNG thay vì một mặt cong: Gazebo classic không có primitive cung tròn, và
|
||||
dùng mesh thì phải kèm một file nhị phân vào repo. Sai lệch của phép xấp xỉ là độ võng của một
|
||||
dây cung:
|
||||
|
||||
s = R * (1 - cos(span/2N)) = 0.35 mm
|
||||
|
||||
Nhỏ hơn nhiễu tầm của nanoscan3 (3 mm) một bậc, nên phép khớp tròn không phân biệt được nó với
|
||||
một mặt cong thật — đúng ý đồ. Tăng 24 lên thì nhỏ hơn nữa nhưng nặng thêm cho engine vật lý.
|
||||
|
||||
⚠ KHÔNG khai `laser_retro`: profile `arc` TỪ CHỐI `tape_enabled` ngay lúc boot, vì `findTape`
|
||||
quét theo chỉ số tia của một ĐOẠN THẲNG mà cung không sinh ra đoạn nào. Dán dải lên máng thì
|
||||
phải viết lại đường tìm vệt theo chuỗi điểm của cung trước đã.
|
||||
|
||||
Cao 0.6 m và đáy sát sàn: LiDAR phẳng gắn ở độ cao nào trong khoảng đó cũng cắt qua máng. Dày
|
||||
0.02 m để `min_split_dist` (0.02 m) không nhầm hai mặt của cùng một tấm thành hai đoạn.
|
||||
-->
|
||||
<sdf version="1.6">
|
||||
<model name="dock_cradle_arc">
|
||||
<static>true</static>
|
||||
<link name="cradle">
|
||||
<collision name="c0">
|
||||
<pose>-0.170046 -0.327294 0.300 0 0 -0.958333</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<laser_retro>0</laser_retro>
|
||||
</collision>
|
||||
<visual name="v0">
|
||||
<pose>-0.170046 -0.327294 0.300 0 0 -0.958333</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
|
||||
</visual>
|
||||
<collision name="c1">
|
||||
<pose>-0.143601 -0.307017 0.300 0 0 -0.875000</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<laser_retro>0</laser_retro>
|
||||
</collision>
|
||||
<visual name="v1">
|
||||
<pose>-0.143601 -0.307017 0.300 0 0 -0.875000</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
|
||||
</visual>
|
||||
<collision name="c2">
|
||||
<pose>-0.118936 -0.284610 0.300 0 0 -0.791667</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<laser_retro>0</laser_retro>
|
||||
</collision>
|
||||
<visual name="v2">
|
||||
<pose>-0.118936 -0.284610 0.300 0 0 -0.791667</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
|
||||
</visual>
|
||||
<collision name="c3">
|
||||
<pose>-0.096221 -0.260228 0.300 0 0 -0.708333</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<laser_retro>0</laser_retro>
|
||||
</collision>
|
||||
<visual name="v3">
|
||||
<pose>-0.096221 -0.260228 0.300 0 0 -0.708333</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
|
||||
</visual>
|
||||
<collision name="c4">
|
||||
<pose>-0.075615 -0.234039 0.300 0 0 -0.625000</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<laser_retro>0</laser_retro>
|
||||
</collision>
|
||||
<visual name="v4">
|
||||
<pose>-0.075615 -0.234039 0.300 0 0 -0.625000</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
|
||||
</visual>
|
||||
<collision name="c5">
|
||||
<pose>-0.057260 -0.206226 0.300 0 0 -0.541667</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<laser_retro>0</laser_retro>
|
||||
</collision>
|
||||
<visual name="v5">
|
||||
<pose>-0.057260 -0.206226 0.300 0 0 -0.541667</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
|
||||
</visual>
|
||||
<collision name="c6">
|
||||
<pose>-0.041284 -0.176982 0.300 0 0 -0.458333</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<laser_retro>0</laser_retro>
|
||||
</collision>
|
||||
<visual name="v6">
|
||||
<pose>-0.041284 -0.176982 0.300 0 0 -0.458333</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
|
||||
</visual>
|
||||
<collision name="c7">
|
||||
<pose>-0.027797 -0.146509 0.300 0 0 -0.375000</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<laser_retro>0</laser_retro>
|
||||
</collision>
|
||||
<visual name="v7">
|
||||
<pose>-0.027797 -0.146509 0.300 0 0 -0.375000</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
|
||||
</visual>
|
||||
<collision name="c8">
|
||||
<pose>-0.016894 -0.115020 0.300 0 0 -0.291667</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<laser_retro>0</laser_retro>
|
||||
</collision>
|
||||
<visual name="v8">
|
||||
<pose>-0.016894 -0.115020 0.300 0 0 -0.291667</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
|
||||
</visual>
|
||||
<collision name="c9">
|
||||
<pose>-0.008649 -0.082732 0.300 0 0 -0.208333</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<laser_retro>0</laser_retro>
|
||||
</collision>
|
||||
<visual name="v9">
|
||||
<pose>-0.008649 -0.082732 0.300 0 0 -0.208333</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
|
||||
</visual>
|
||||
<collision name="c10">
|
||||
<pose>-0.003121 -0.049870 0.300 0 0 -0.125000</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<laser_retro>0</laser_retro>
|
||||
</collision>
|
||||
<visual name="v10">
|
||||
<pose>-0.003121 -0.049870 0.300 0 0 -0.125000</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
|
||||
</visual>
|
||||
<collision name="c11">
|
||||
<pose>-0.000347 -0.016662 0.300 0 0 -0.041667</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<laser_retro>0</laser_retro>
|
||||
</collision>
|
||||
<visual name="v11">
|
||||
<pose>-0.000347 -0.016662 0.300 0 0 -0.041667</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
|
||||
</visual>
|
||||
<collision name="c12">
|
||||
<pose>-0.000347 0.016662 0.300 0 0 0.041667</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<laser_retro>0</laser_retro>
|
||||
</collision>
|
||||
<visual name="v12">
|
||||
<pose>-0.000347 0.016662 0.300 0 0 0.041667</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
|
||||
</visual>
|
||||
<collision name="c13">
|
||||
<pose>-0.003121 0.049870 0.300 0 0 0.125000</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<laser_retro>0</laser_retro>
|
||||
</collision>
|
||||
<visual name="v13">
|
||||
<pose>-0.003121 0.049870 0.300 0 0 0.125000</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
|
||||
</visual>
|
||||
<collision name="c14">
|
||||
<pose>-0.008649 0.082732 0.300 0 0 0.208333</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<laser_retro>0</laser_retro>
|
||||
</collision>
|
||||
<visual name="v14">
|
||||
<pose>-0.008649 0.082732 0.300 0 0 0.208333</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
|
||||
</visual>
|
||||
<collision name="c15">
|
||||
<pose>-0.016894 0.115020 0.300 0 0 0.291667</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<laser_retro>0</laser_retro>
|
||||
</collision>
|
||||
<visual name="v15">
|
||||
<pose>-0.016894 0.115020 0.300 0 0 0.291667</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
|
||||
</visual>
|
||||
<collision name="c16">
|
||||
<pose>-0.027797 0.146509 0.300 0 0 0.375000</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<laser_retro>0</laser_retro>
|
||||
</collision>
|
||||
<visual name="v16">
|
||||
<pose>-0.027797 0.146509 0.300 0 0 0.375000</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
|
||||
</visual>
|
||||
<collision name="c17">
|
||||
<pose>-0.041284 0.176982 0.300 0 0 0.458333</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<laser_retro>0</laser_retro>
|
||||
</collision>
|
||||
<visual name="v17">
|
||||
<pose>-0.041284 0.176982 0.300 0 0 0.458333</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
|
||||
</visual>
|
||||
<collision name="c18">
|
||||
<pose>-0.057260 0.206226 0.300 0 0 0.541667</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<laser_retro>0</laser_retro>
|
||||
</collision>
|
||||
<visual name="v18">
|
||||
<pose>-0.057260 0.206226 0.300 0 0 0.541667</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
|
||||
</visual>
|
||||
<collision name="c19">
|
||||
<pose>-0.075615 0.234039 0.300 0 0 0.625000</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<laser_retro>0</laser_retro>
|
||||
</collision>
|
||||
<visual name="v19">
|
||||
<pose>-0.075615 0.234039 0.300 0 0 0.625000</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
|
||||
</visual>
|
||||
<collision name="c20">
|
||||
<pose>-0.096221 0.260228 0.300 0 0 0.708333</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<laser_retro>0</laser_retro>
|
||||
</collision>
|
||||
<visual name="v20">
|
||||
<pose>-0.096221 0.260228 0.300 0 0 0.708333</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
|
||||
</visual>
|
||||
<collision name="c21">
|
||||
<pose>-0.118936 0.284610 0.300 0 0 0.791667</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<laser_retro>0</laser_retro>
|
||||
</collision>
|
||||
<visual name="v21">
|
||||
<pose>-0.118936 0.284610 0.300 0 0 0.791667</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
|
||||
</visual>
|
||||
<collision name="c22">
|
||||
<pose>-0.143601 0.307017 0.300 0 0 0.875000</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<laser_retro>0</laser_retro>
|
||||
</collision>
|
||||
<visual name="v22">
|
||||
<pose>-0.143601 0.307017 0.300 0 0 0.875000</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
|
||||
</visual>
|
||||
<collision name="c23">
|
||||
<pose>-0.170046 0.327294 0.300 0 0 0.958333</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<laser_retro>0</laser_retro>
|
||||
</collision>
|
||||
<visual name="v23">
|
||||
<pose>-0.170046 0.327294 0.300 0 0 0.958333</pose>
|
||||
<geometry><box><size>0.02 0.033324 0.6</size></box></geometry>
|
||||
<material><ambient>0.15 0.35 0.6 1</ambient><diffuse>0.2 0.45 0.75 1</diffuse></material>
|
||||
</visual>
|
||||
</link>
|
||||
</model>
|
||||
</sdf>
|
||||
@@ -68,6 +68,18 @@ actions_dock:
|
||||
tape_width_tolerance: 0.05
|
||||
tape_min_intensity: 500.0
|
||||
|
||||
# Máng cong lõm — biên dạng thứ hai, đi qua ArcPatternMatcher chứ không phải VPatternMatcher.
|
||||
cradle:
|
||||
pattern: arc
|
||||
arc_radius: 0.40 # [m]
|
||||
arc_radius_tolerance: 0.06 # [m]
|
||||
arc_span: 2.2 # [rad] góc mở toàn phần của máng
|
||||
arc_min_span: 0.52 # [rad] sàn để tin phép khớp
|
||||
arc_max_rms: 0.010 # [m] cổng chính chống nhầm góc tường thành cung
|
||||
min_arc_points: 8
|
||||
min_confidence: 0.3
|
||||
offset_x: 0.60 # [m] lùi ra trước mặt máng
|
||||
|
||||
# scan_topic không có trong kho -> phải từ chối LÚC BOOT kèm danh sách topic có thật.
|
||||
actions_dock_bad_topic:
|
||||
handlers:
|
||||
|
||||
@@ -64,6 +64,20 @@ std::vector<Segment> vPlate(double apex_x, double half_angle, double wing)
|
||||
return { { apex_x, 0.0, tip_x, tip_y }, { apex_x, 0.0, tip_x, -tip_y } };
|
||||
}
|
||||
|
||||
/// @brief Máng cong LÕM: tâm ở @p center_x trên trục x, mặt cong ở XA hơn tâm.
|
||||
std::vector<Segment> concaveCradle(double center_x, double r, double span, int facets = 300)
|
||||
{
|
||||
std::vector<Segment> out;
|
||||
for (int i = 0; i + 1 < facets; ++i)
|
||||
{
|
||||
const double t0 = -span / 2.0 + span * i / (facets - 1);
|
||||
const double t1 = -span / 2.0 + span * (i + 1) / (facets - 1);
|
||||
out.push_back({ center_x + r * std::cos(t0), r * std::sin(t0), center_x + r * std::cos(t1),
|
||||
r * std::sin(t1) });
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/// @brief [m] Cự ly từ điểm (@p px, @p py) tới đoạn @p s.
|
||||
double distToSegment(double px, double py, const Segment& s)
|
||||
{
|
||||
@@ -542,6 +556,38 @@ TEST(DockPatternAction, ATapeProfileRefusesAPlateThatCarriesNoTape)
|
||||
EXPECT_NE(rig.last_message.find("reflective tape"), std::string::npos) << rig.last_message;
|
||||
}
|
||||
|
||||
TEST(DockPatternAction, DispatchesToTheArcMatcherWhenTheProfileAsksForOne)
|
||||
{
|
||||
// Kiểm ĐƯỜNG ĐỊNH TUYẾN, không phải luật khớp — luật đã có test riêng bên dock_pattern_detector.
|
||||
// Câu hỏi ở đây: profile khai `pattern: arc` có thật sự chạy qua ArcPatternMatcher không, hay
|
||||
// handler vẫn đưa nó cho bộ khớp chữ V. Nếu đưa nhầm, bộ khớp chữ V nay TỪ CHỐI ngay lúc start,
|
||||
// nên test này fail ở dòng start chứ không phải im lặng không dò ra gì.
|
||||
Rig rig;
|
||||
ASSERT_TRUE(rig.store_ok_);
|
||||
ASSERT_TRUE(rig.loaded);
|
||||
|
||||
ASSERT_TRUE(rig.handler->start(makeAction("cradle"), robot::Time(10.0)));
|
||||
EXPECT_EQ(rig.feed(concaveCradle(1.20, 0.40, 2.0), 8), ActionStatus::kSucceeded)
|
||||
<< rig.last_message;
|
||||
|
||||
// Tâm ở 1.20, bán kính 0.40 -> điểm sâu nhất ở 1.60; profile lùi 0.60 m ra phía robot.
|
||||
const tf3::TransformStampedMsg out = rig.tf.lookupTransform(kGlobalFrame, kOutFrame, tf3::Time());
|
||||
EXPECT_NEAR(out.transform.translation.x, 1.00, 0.05);
|
||||
EXPECT_NEAR(out.transform.translation.y, 0.00, 0.05);
|
||||
}
|
||||
|
||||
TEST(DockPatternAction, AnArcProfileRefusesAVPlate)
|
||||
{
|
||||
// Mặt kia: cùng handler, cùng profile arc, nhưng trong tầm là một tấm chữ V. Không có cặp này
|
||||
// thì một lỗi làm hỏng hẳn phép dò cung cũng trông y hệt "cổng đang làm việc".
|
||||
Rig rig;
|
||||
ASSERT_TRUE(rig.store_ok_);
|
||||
ASSERT_TRUE(rig.loaded);
|
||||
|
||||
ASSERT_TRUE(rig.handler->start(makeAction("cradle"), robot::Time(10.0)));
|
||||
EXPECT_EQ(rig.feed(vPlate(1.20, M_PI / 4.0, 0.30), 60), ActionStatus::kFailed);
|
||||
}
|
||||
|
||||
TEST(DockPatternAction, RefusesADefaultProfileThatDoesNotExist)
|
||||
{
|
||||
Rig rig("actions_dock_bad_default");
|
||||
|
||||
Reference in New Issue
Block a user