fix(pybot): 录制时改用同步 capture() 按需抓帧,避免帧重复

_grab_frame 从 camera.latest()(读后台队列)改为 camera.capture()
(直接调 grabber 同步抓帧),确保每个微动作拿到独立帧而非队列中
可能重复的旧帧。Camera 新增 capture() 方法。
This commit is contained in:
qing committed 2026-08-13 16:38:15 +08:00
1 parent 3fc213e7b9
commit bfa6d8deb6
3 files changed
+25 -5

No files matched your search

+14
View File
@@ -82,6 +82,20 @@ def test_dry_run_no_hardware():
assert cam.latest() is None
def test_capture_on_demand():
"""capture() 同步按需抓帧,每个微步一帧"""
cam = Camera(grabber=FakeGrabber())
assert cam.capture() == 1
assert cam.capture() == 2 # 每次调用递增,不复用队列
assert cam.capture() == 3
def test_capture_no_grabber():
"""dry_run 或未 setup 时 capture() 返回 None"""
cam = Camera(dry_run=True)
assert cam.capture() is None
def test_camera_var_from_matrix():
robot = RobotStruct(CAMERA_MT, dry_run=True)
cam = robot.M["cam0"].camera