feat(perception): map vegetation provider labels
This commit is contained in:
@@ -8,6 +8,8 @@ import pytest
|
||||
from k1link.laboratory.vegetation_mission_policy import (
|
||||
VegetationMissionPolicyError,
|
||||
load_vegetation_mission_policy,
|
||||
load_vegetation_provider_label_map,
|
||||
map_provider_material,
|
||||
resolve_terrain_policy,
|
||||
)
|
||||
|
||||
@@ -21,12 +23,23 @@ CANDIDATE_MANIFEST_PATH = (
|
||||
/ "perception"
|
||||
/ "lab-v1-vegetation-candidate-manifest-v1.json"
|
||||
)
|
||||
PROVIDER_LABEL_MAP_PATH = (
|
||||
REPOSITORY_ROOT
|
||||
/ "config"
|
||||
/ "perception"
|
||||
/ "lab-v1-vegetation-provider-label-map-v1.json"
|
||||
)
|
||||
|
||||
|
||||
def _policy() -> dict[str, object]:
|
||||
return load_vegetation_mission_policy(POLICY_PATH, repository_root=REPOSITORY_ROOT)
|
||||
|
||||
|
||||
def _provider_label_map() -> dict[str, object]:
|
||||
policy = _policy()
|
||||
return load_vegetation_provider_label_map(PROVIDER_LABEL_MAP_PATH, policy=policy)
|
||||
|
||||
|
||||
def test_presets_are_defaults_and_explicit_mission_rule_wins() -> None:
|
||||
policy = _policy()
|
||||
|
||||
@@ -147,3 +160,65 @@ def test_candidate_manifest_freezes_unique_assets_sources_and_no_authority() ->
|
||||
assert manifest["invariants"]["missing_or_unknown_is_free"] is False
|
||||
assert manifest["invariants"]["navigation_authority"] is False
|
||||
assert manifest["invariants"]["actuation_authority"] is False
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("provider_id", "provider_label", "material"),
|
||||
[
|
||||
("goose-fine-64", "low_grass", "grass"),
|
||||
("goose-fine-64", "high_grass", "herbaceous_vegetation"),
|
||||
("goose-fine-64", "bush", "woody_shrub"),
|
||||
("goose-fine-64", "tree_trunk", "tree_or_trunk"),
|
||||
("wildscenes-19", "tree-trunk", "tree_or_trunk"),
|
||||
("rellis-20", "tree", "tree_or_trunk"),
|
||||
],
|
||||
)
|
||||
def test_fine_provider_labels_map_to_separate_material_claims(
|
||||
provider_id: str,
|
||||
provider_label: str,
|
||||
material: str,
|
||||
) -> None:
|
||||
assert (
|
||||
map_provider_material(
|
||||
_provider_label_map(),
|
||||
provider_id=provider_id,
|
||||
provider_label=provider_label,
|
||||
)
|
||||
== material
|
||||
)
|
||||
|
||||
|
||||
def test_coarse_vegetation_never_becomes_grass_permission() -> None:
|
||||
material = map_provider_material(
|
||||
_provider_label_map(),
|
||||
provider_id="goose-category-12",
|
||||
provider_label="vegetation",
|
||||
)
|
||||
assert material == "vegetation_unknown"
|
||||
decision = resolve_terrain_policy(
|
||||
_policy(),
|
||||
preset_id="offroad",
|
||||
material_class=material,
|
||||
evidence_state="SUPPORTED_GROUND",
|
||||
)
|
||||
assert decision.effective_action == "NO_GO"
|
||||
|
||||
|
||||
def test_binary_freespace_and_unmapped_labels_make_no_material_claim() -> None:
|
||||
label_map = _provider_label_map()
|
||||
assert (
|
||||
map_provider_material(
|
||||
label_map,
|
||||
provider_id="orfd-binary-freespace",
|
||||
provider_label="freespace",
|
||||
)
|
||||
is None
|
||||
)
|
||||
assert (
|
||||
map_provider_material(
|
||||
label_map,
|
||||
provider_id="goose-fine-64",
|
||||
provider_label="person",
|
||||
)
|
||||
is None
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user