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:
+16
-18
@@ -1,32 +1,30 @@
|
||||
"""Central configuration dataclasses for the herding simulation.
|
||||
|
||||
Every tunable constant that previously lived as a module-level literal in
|
||||
perception/lidar_sim.py, perception/lidar_perception.py,
|
||||
perception/sheep_tracker.py, world/geometry.py, or training/herding_env.py
|
||||
is now represented here as a field with its original default value.
|
||||
Every tunable parameter lives here as a frozen dataclass field — LiDAR
|
||||
spec, cluster detection thresholds, tracker gates, robot kinematics,
|
||||
and domain-randomisation knobs — composed into :class:`HerdingConfig`.
|
||||
|
||||
Usage — use the module defaults unchanged::
|
||||
Usage — accept the defaults::
|
||||
|
||||
env = HerdingEnv() # same behaviour as before
|
||||
env = HerdingEnv()
|
||||
|
||||
Override a subset of parameters::
|
||||
Override a subset::
|
||||
|
||||
from herding.config import HerdingConfig, TrackerConfig
|
||||
cfg = HerdingConfig(tracker=TrackerConfig(forget_steps=60))
|
||||
env = HerdingEnv(herding_cfg=cfg)
|
||||
|
||||
Use a named preset for Webots-matched training::
|
||||
Use a named preset::
|
||||
|
||||
from herding.config import HERDING_WEBOTS
|
||||
env = HerdingEnv(herding_cfg=HERDING_WEBOTS)
|
||||
env = HerdingEnv(herding_cfg=HERDING_WEBOTS) # 140° FOV
|
||||
env = HerdingEnv(herding_cfg=HERDING_MEC_WEBOTS) # + mecanum slip
|
||||
|
||||
Design notes
|
||||
------------
|
||||
* All dataclasses are frozen — instances are immutable after construction.
|
||||
* This module must not import from other ``herding.*`` packages to avoid
|
||||
import cycles. Field-geometry constants (pen coordinates, field size)
|
||||
stay in ``herding.world.geometry`` because they depend on the world
|
||||
variant selected at runtime via ``HERDING_WORLD``.
|
||||
* All dataclasses are frozen so instances are immutable after construction.
|
||||
* This module must not import from other ``herding.*`` packages —
|
||||
field-geometry constants live in ``herding.world.geometry`` because
|
||||
they depend on the world variant selected at runtime via
|
||||
``HERDING_WORLD``, which would create an import cycle here.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -257,7 +255,7 @@ class RobotConfig:
|
||||
|
||||
``1.0`` (default) = perfect mecanum kinematics. ``0.4`` matches the
|
||||
Webots roller-hinge mecanum proto calibration (62% slip on strafe,
|
||||
11% on forward). Used by ``mecanum_kinematics_step`` only — has no
|
||||
11% on forward). Used by ``mecanum_step`` only — has no
|
||||
effect on differential drive.
|
||||
"""
|
||||
|
||||
@@ -266,7 +264,7 @@ class RobotConfig:
|
||||
|
||||
``0.0`` (default) = no bleed. ``-0.28`` matches the Webots proto's
|
||||
consistent backward push under strafe commands. Used by
|
||||
``mecanum_kinematics_step`` only.
|
||||
``mecanum_step`` only.
|
||||
"""
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
|
||||
Reference in New Issue
Block a user