修正示例中的三轴力单位显示
避免未标定读数被示例标成 N,并让 Finger 示例读取 SDK 的每轴单位。已通过相关测试和语法检查。
This commit is contained in:
@@ -77,13 +77,13 @@ def main() -> int:
|
||||
break
|
||||
|
||||
# ------------------------------------------------------ use the results
|
||||
# Scalars are calibrated Newtons when the bundle ships a calibration; the *_raw
|
||||
# pair is always the unfiltered integrator output.
|
||||
# The *_raw pair is always the unfiltered integrator output.
|
||||
touching = "yes" if snap.centroid is not None else "no"
|
||||
fn_unit, fx_unit, fy_unit = sensor.force_units
|
||||
print(
|
||||
f"FPS={snap.fps:5.1f} "
|
||||
f"normal={snap.normal_force:8.4f} N (raw {snap.normal_force_raw:10.2f}) "
|
||||
f"shear=({snap.shear_x:7.4f}, {snap.shear_y:7.4f}) "
|
||||
f"normal={snap.normal_force:8.4f} {fn_unit} (raw {snap.normal_force_raw:10.2f}) "
|
||||
f"shear=({snap.shear_x:7.4f} {fx_unit}, {snap.shear_y:7.4f} {fy_unit}) "
|
||||
f"contact={touching} age={snap.age_ms:4.1f} ms",
|
||||
end="\r",
|
||||
)
|
||||
|
||||
@@ -75,10 +75,11 @@ def main() -> int:
|
||||
# ------------------------------------------------------ use the results
|
||||
coverage = runtime.tactile.mask_stats.get("coverage")
|
||||
coverage_text = f"{coverage:.2f}" if isinstance(coverage, float) else "n/a"
|
||||
fn_unit, fx_unit, fy_unit = runtime.tactile.force_units
|
||||
print(
|
||||
f"FPS={snap.fps:5.1f} "
|
||||
f"normal={snap.normal_force:8.4f} N "
|
||||
f"shear=({snap.shear_x:7.4f}, {snap.shear_y:7.4f}) "
|
||||
f"normal={snap.normal_force:8.4f} {fn_unit} "
|
||||
f"shear=({snap.shear_x:7.4f} {fx_unit}, {snap.shear_y:7.4f} {fy_unit}) "
|
||||
f"mask={coverage_text} age={snap.age_ms:4.1f} ms",
|
||||
end="\r",
|
||||
)
|
||||
|
||||
@@ -95,9 +95,10 @@ def main():
|
||||
cv2.imshow("depth", cv2.applyColorMap(div_normalized, cv2.COLORMAP_JET))
|
||||
|
||||
# 步骤 3.4:打印关键结果
|
||||
fn_unit, fx_unit, fy_unit = sensor.force_units
|
||||
print(
|
||||
f"FPS={fps:.2f}, 法向力={fnormal:.4f}, 切向力X={fshearx:.4f}, "
|
||||
f"切向力Y={fsheary:.4f}, 深度图尺寸={depth_map.shape}, 原始分辨率={sensor.img_size_raw}"
|
||||
f"FPS={fps:.2f}, 法向力={fnormal:.4f} {fn_unit}, 切向力X={fshearx:.4f} {fx_unit}, "
|
||||
f"切向力Y={fsheary:.4f} {fy_unit}, 深度图尺寸={depth_map.shape}, 原始分辨率={sensor.img_size_raw}"
|
||||
)
|
||||
|
||||
# 步骤 3.5:键盘控制
|
||||
|
||||
@@ -65,7 +65,11 @@ def main():
|
||||
sensor.info.VRAW,
|
||||
sensor.info.DEPTH,
|
||||
)
|
||||
print(f"FPS={fps:.2f}, 法向力={fn:.4f}, 切向力X={fx:.4f}, 切向力Y={fy:.4f}")
|
||||
fn_unit, fx_unit, fy_unit = sensor.force_units
|
||||
print(
|
||||
f"FPS={fps:.2f}, 法向力={fn:.4f} {fn_unit}, "
|
||||
f"切向力X={fx:.4f} {fx_unit}, 切向力Y={fy:.4f} {fy_unit}"
|
||||
)
|
||||
|
||||
arrows = orisys.util.draw_arrows(sensor.img, flow, threshold=5, grid_spacing=10, arrow_scale=1.0)
|
||||
cv2.imshow("形变矢量场", arrows)
|
||||
|
||||
@@ -101,6 +101,10 @@ class TactileProcessor:
|
||||
def valid_mask(self):
|
||||
return self._sensor.valid_mask
|
||||
|
||||
@property
|
||||
def force_units(self) -> tuple[str, str, str]:
|
||||
return self._sensor.force_units
|
||||
|
||||
def push_frame(self, frame, *, already_gray=False, valid_mask=None):
|
||||
"""Feed one processed tactile frame into the analysis pipeline."""
|
||||
mask = self._default_valid_mask if valid_mask is None else valid_mask
|
||||
|
||||
@@ -123,6 +123,7 @@ def test_tactile_processor_push_frame_uses_default_valid_mask():
|
||||
|
||||
def __init__(self):
|
||||
self.calls = []
|
||||
self.force_units = ("N", "raw", "raw")
|
||||
self.frame = None
|
||||
self.img = None
|
||||
self.flow = None
|
||||
@@ -146,6 +147,7 @@ def test_tactile_processor_push_frame_uses_default_valid_mask():
|
||||
result = tactile.push_frame(frame, already_gray=True)
|
||||
|
||||
assert result == "ok"
|
||||
assert tactile.force_units == ("N", "raw", "raw")
|
||||
assert sensor.calls[0]["frame"] is frame
|
||||
assert sensor.calls[0]["already_processed"] is True
|
||||
assert sensor.calls[0]["already_gray"] is True
|
||||
|
||||
Reference in New Issue
Block a user