Rename multi-segment functions to two-concept names; polish docstrings
Naming pass: rename functions whose third+ segment is redundant or implementation-detail, sticking to the codebase's preferred ``noun_verb`` / ``verb_noun`` two-concept idiom. Renames are atomic across definitions, callers, and tests. is_penned_position → is_penned modulate_speed_near_sheep → modulate_speed mecanum_kinematics_step → mecanum_step policy_forward_mean → forward_mean Two-concept patterns like ``velocity_to_wheels`` / ``detections_from_scan`` / ``make_strombom_predictor`` are left alone — they're idiomatic converters / factories that read as a single concept, and the longer form aids grep-ability. Docstring polish: * ``herding/config.py`` header drops the "previously lived as a module-level literal" historical framing — we ship as a single thing, so the refactor anecdote no longer earns its keep. The usage examples now mention both ``HERDING_WEBOTS`` and ``HERDING_MEC_WEBOTS`` presets. 126 pytest cases still pass. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -12,7 +12,7 @@ exploration behaviours:
|
||||
beyond the 12 m LiDAR range).
|
||||
|
||||
When the tracker has detections the base teacher's action is used,
|
||||
post-processed by ``modulate_speed_near_sheep`` so the dog doesn't
|
||||
post-processed by ``modulate_speed`` so the dog doesn't
|
||||
charge the flock.
|
||||
"""
|
||||
|
||||
@@ -20,7 +20,7 @@ from __future__ import annotations
|
||||
|
||||
import math
|
||||
|
||||
from herding.control.modulation import modulate_speed_near_sheep
|
||||
from herding.control.modulation import modulate_speed
|
||||
|
||||
|
||||
INITIAL_SCAN_STEPS = 80 # ≈1.3 s — covers one full rotation
|
||||
@@ -117,6 +117,6 @@ class ActiveScanTeacher:
|
||||
else:
|
||||
vx, vy, mode = result
|
||||
omega = 0.0
|
||||
vx, vy = modulate_speed_near_sheep(vx, vy, dog_xy, sheep_positions)
|
||||
vx, vy = modulate_speed(vx, vy, dog_xy, sheep_positions)
|
||||
self.last_action = (vx, vy)
|
||||
return vx, vy, omega, mode
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Shared action post-processing.
|
||||
|
||||
Every dog mode routes its action through ``modulate_speed_near_sheep``
|
||||
Every dog mode routes its action through ``modulate_speed``
|
||||
so the magnitude is reduced near sheep — direction (intent) is
|
||||
preserved.
|
||||
"""
|
||||
@@ -14,7 +14,7 @@ SLOW_NEAR_SHEEP = 2.5 # m — distance below which action norm is scaled down
|
||||
MIN_SPEED = 0.30 # action norm at zero distance
|
||||
|
||||
|
||||
def modulate_speed_near_sheep(
|
||||
def modulate_speed(
|
||||
vx: float, vy: float,
|
||||
dog_xy: tuple[float, float],
|
||||
sheep_positions,
|
||||
|
||||
Reference in New Issue
Block a user