精度実験用スクリプトに角度知らせ機能を追加.

回頭時間のデフォルトをaccuracy_report.pyに反映
This commit is contained in:
agomizi1cm committed 2026-10-05 15:50:03 +09:00
1 parent 737044eeb7
commit 38bdea0c2a
2 files changed
+31 -1

No files matched your search

+1 -1
View File
@@ -431,7 +431,7 @@ def main(argv: Sequence[str] | None = None, out=print) -> int: # type: ignore[n
parser.add_argument("--out", type=Path, default=Path("data/analysis/accuracy/report"))
parser.add_argument("--signal", choices=("yaw", "raw_yaw"), default="yaw")
parser.add_argument("--flip-sign", action="store_true")
parser.add_argument("--settle", type=float, default=1.5, help="seconds after the cue ignored (turn in progress)")
parser.add_argument("--settle", type=float, default=3.0, help="seconds after the cue ignored (turn in progress)")
parser.add_argument("--baseline-trim", type=float, default=0.5)
parser.add_argument("--min-frames", type=int, default=10)
parser.add_argument("--face-every", type=int, default=1, help="face.process_every_n_frames of the run")
+30
View File
@@ -44,6 +44,21 @@ INTERVAL_AUDIO = {
"block": Path("assets/audio/block.wav"),
"auto": Path("assets/audio/auto_interval.wav"),
}
# One prepared announcement file per target yaw angle.
# Prepare these files under assets/audio/ using exactly these names.
ANGLE_AUDIO = {
0.0: Path("assets/audio/yaw_0.wav"),
5.0: Path("assets/audio/yaw_plus_5.wav"),
-5.0: Path("assets/audio/yaw_minus_5.wav"),
10.0: Path("assets/audio/yaw_plus_10.wav"),
-10.0: Path("assets/audio/yaw_minus_10.wav"),
15.0: Path("assets/audio/yaw_plus_15.wav"),
-15.0: Path("assets/audio/yaw_minus_15.wav"),
20.0: Path("assets/audio/yaw_plus_20.wav"),
-20.0: Path("assets/audio/yaw_minus_20.wav"),
30.0: Path("assets/audio/yaw_plus_30.wav"),
-30.0: Path("assets/audio/yaw_minus_30.wav"),
}
LOGGER = logging.getLogger(__name__)
DEFAULT_ANGLES = (0.0, 5.0, -5.0, 10.0, -10.0, 15.0, -15.0, 20.0, -20.0, 30.0, -30.0)
PLAN_FIELDS = ["seq", "block", "condition_id", "distance_m", "true_yaw_deg", "pitch_deg", "repeat", "subject"]
@@ -170,6 +185,14 @@ class IntervalAudioPlayer:
self._sounds[kind] = mixer.Sound(str(path))
except Exception as exc:
LOGGER.error("Failed to load interval audio %s: %s", path, exc)
for angle, path in ANGLE_AUDIO.items():
if not path.is_file():
LOGGER.warning("Angle announcement audio file does not exist (%+g deg): %s", angle, path)
continue
try:
self._sounds[f"angle:{angle:g}"] = mixer.Sound(str(path))
except Exception as exc:
LOGGER.error("Failed to load angle announcement audio (%+g deg) %s: %s", angle, path, exc)
except Exception as exc:
LOGGER.error("Failed to initialize pygame mixer for interval audio: %s", exc)
self._initialized = False
@@ -186,6 +209,11 @@ class IntervalAudioPlayer:
LOGGER.error("Failed to play interval audio %s: %s", kind, exc)
return False
def play_angle(self, angle: float) -> bool:
"""Announce the target yaw angle using the prepared per-angle WAV file."""
key = f"angle:{angle:g}"
return self.play(key)
def close(self) -> None:
if self._closed:
return
@@ -265,6 +293,7 @@ class SessionRunner:
try:
if self.auto_interval > 0 and not new_block:
self.interval_audio.play("auto")
self.interval_audio.play_angle(row.true_yaw_deg)
self._countdown(self.auto_interval)
command = ""
else:
@@ -294,6 +323,7 @@ class SessionRunner:
first_trial_move_pending = False
elif block_change and self.block_interval > 0:
self.interval_audio.play("block")
self.interval_audio.play_angle(row.true_yaw_deg)
self._countdown(self.block_interval, label="moving to next block")
try:
stamps = self._execute(row)