feat(phase2): implement AMR robot state machine, task lifecycles, inventory catalog, and Phase 2 OpenUSD scene
This commit is contained in:
Vendored
+183
@@ -0,0 +1,183 @@
|
||||
"""Deterministic test fixtures and model factories for unit and scenario tests."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Dict, List
|
||||
|
||||
from warehouse_twin.domain.inventory import InventoryCatalog, InventoryItem
|
||||
from warehouse_twin.domain.robot import Robot, RobotState, RobotTypeSpec
|
||||
from warehouse_twin.domain.task import Task, TaskStatus, TaskType
|
||||
from warehouse_twin.domain.warehouse import Position3D
|
||||
|
||||
|
||||
def create_sample_robot_types() -> Dict[str, RobotTypeSpec]:
|
||||
"""Return standard AMR type specifications."""
|
||||
light_spec = RobotTypeSpec(
|
||||
type_id="light_amr",
|
||||
name="Agile Lightweight AMR",
|
||||
description="Zone A fast parts and transit",
|
||||
payload_capacity_kg=150.0,
|
||||
max_speed_mps=1.8,
|
||||
acceleration_mps2=0.8,
|
||||
battery_capacity_kwh=3.0,
|
||||
power_consumption_kw={
|
||||
"idle": 0.05,
|
||||
"moving_empty": 0.35,
|
||||
"moving_loaded": 0.65,
|
||||
"handling": 0.15,
|
||||
},
|
||||
allowed_zones={"zone_a", "zone_c"}, # Prohibited from Zone B
|
||||
dimensions=(0.8, 0.6, 0.35),
|
||||
)
|
||||
|
||||
heavy_spec = RobotTypeSpec(
|
||||
type_id="heavy_amr",
|
||||
name="Heavy-Duty Pallet AMR",
|
||||
description="Zone B heavy parts and Zone C raw materials",
|
||||
payload_capacity_kg=1500.0,
|
||||
max_speed_mps=1.1,
|
||||
acceleration_mps2=0.4,
|
||||
battery_capacity_kwh=15.0,
|
||||
power_consumption_kw={
|
||||
"idle": 0.12,
|
||||
"moving_empty": 0.90,
|
||||
"moving_loaded": 2.20,
|
||||
"handling": 0.50,
|
||||
},
|
||||
allowed_zones={"zone_a", "zone_b", "zone_c"},
|
||||
dimensions=(1.4, 1.0, 0.45),
|
||||
)
|
||||
|
||||
return {"light_amr": light_spec, "heavy_amr": heavy_spec}
|
||||
|
||||
|
||||
def create_sample_light_robot(robot_id: str = "amr_light_01") -> Robot:
|
||||
"""Create a standard Light AMR for tests."""
|
||||
specs = create_sample_robot_types()
|
||||
spec = specs["light_amr"]
|
||||
return Robot(
|
||||
robot_id=robot_id,
|
||||
robot_type="light_amr",
|
||||
position=Position3D(2.0, 36.0, 0.0),
|
||||
maximum_speed=spec.max_speed_mps,
|
||||
payload_capacity=spec.payload_capacity_kg,
|
||||
battery_level=spec.battery_capacity_kwh,
|
||||
battery_capacity=spec.battery_capacity_kwh,
|
||||
energy_consumption=dict(spec.power_consumption_kw),
|
||||
allowed_zones=set(spec.allowed_zones),
|
||||
)
|
||||
|
||||
|
||||
def create_sample_heavy_robot(robot_id: str = "amr_heavy_01") -> Robot:
|
||||
"""Create a standard Heavy AMR for tests."""
|
||||
specs = create_sample_robot_types()
|
||||
spec = specs["heavy_amr"]
|
||||
return Robot(
|
||||
robot_id=robot_id,
|
||||
robot_type="heavy_amr",
|
||||
position=Position3D(6.0, 36.0, 0.0),
|
||||
maximum_speed=spec.max_speed_mps,
|
||||
payload_capacity=spec.payload_capacity_kg,
|
||||
battery_level=spec.battery_capacity_kwh,
|
||||
battery_capacity=spec.battery_capacity_kwh,
|
||||
energy_consumption=dict(spec.power_consumption_kw),
|
||||
allowed_zones=set(spec.allowed_zones),
|
||||
)
|
||||
|
||||
|
||||
def create_sample_tasks() -> Dict[str, Task]:
|
||||
"""Create a dictionary of representative tasks across all zones."""
|
||||
return {
|
||||
"light_order": Task(
|
||||
task_id="task_ord_001",
|
||||
task_type=TaskType.ORDER_PICK,
|
||||
source="rack_a_01",
|
||||
destination="picking_station_a1",
|
||||
priority=2,
|
||||
release_time=10.0,
|
||||
required_payload=12.5,
|
||||
item_id="filter_hydraulic_hf1",
|
||||
quantity=5,
|
||||
target_zone="zone_a",
|
||||
),
|
||||
"heavy_order": Task(
|
||||
task_id="task_ord_002",
|
||||
task_type=TaskType.ORDER_PICK,
|
||||
source="rack_b_01",
|
||||
destination="picking_station_b1",
|
||||
priority=2,
|
||||
release_time=25.0,
|
||||
required_payload=650.0,
|
||||
item_id="transmission_combine_ct8",
|
||||
quantity=1,
|
||||
target_zone="zone_b",
|
||||
),
|
||||
"production_feed": Task(
|
||||
task_id="task_feed_001",
|
||||
task_type=TaskType.PRODUCTION_LINE_FEED,
|
||||
source="rack_c_01",
|
||||
destination="production_dropoff_c1",
|
||||
priority=1,
|
||||
release_time=50.0,
|
||||
deadline=350.0,
|
||||
required_payload=1100.0,
|
||||
item_id="raw_steel_coil_sc5",
|
||||
quantity=1,
|
||||
target_zone="zone_c",
|
||||
),
|
||||
"replenishment": Task(
|
||||
task_id="task_replen_001",
|
||||
task_type=TaskType.REPLENISHMENT,
|
||||
source="dock_inbound_1",
|
||||
destination="rack_a_03",
|
||||
priority=3,
|
||||
release_time=100.0,
|
||||
required_payload=75.0,
|
||||
item_id="hardware_bolt_pack_m12",
|
||||
quantity=15,
|
||||
target_zone="zone_a",
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
def create_sample_inventory_catalog() -> InventoryCatalog:
|
||||
"""Create a deterministic catalog containing items from Zones A, B, and C."""
|
||||
items = {
|
||||
"filter_hydraulic_hf1": InventoryItem(
|
||||
item_id="filter_hydraulic_hf1",
|
||||
name="Hydraulic Oil Filter HF-1",
|
||||
category="Fast-moving Inventory",
|
||||
zone="zone_a",
|
||||
unit_weight_kg=2.5,
|
||||
initial_stock=200,
|
||||
current_stock=200,
|
||||
minimum_stock=50,
|
||||
replenishment_batch=100,
|
||||
storage_location="rack_a_01",
|
||||
),
|
||||
"transmission_combine_ct8": InventoryItem(
|
||||
item_id="transmission_combine_ct8",
|
||||
name="Heavy Combine Transmission Unit CT-8",
|
||||
category="Slow-moving and Specialized",
|
||||
zone="zone_b",
|
||||
unit_weight_kg=650.0,
|
||||
initial_stock=8,
|
||||
current_stock=8,
|
||||
minimum_stock=2,
|
||||
replenishment_batch=4,
|
||||
storage_location="rack_b_01",
|
||||
),
|
||||
"raw_steel_coil_sc5": InventoryItem(
|
||||
item_id="raw_steel_coil_sc5",
|
||||
name="Hot-Rolled Sheet Steel Coil SC-5",
|
||||
category="Raw Materials and Production Supply",
|
||||
zone="zone_c",
|
||||
unit_weight_kg=1100.0,
|
||||
initial_stock=10,
|
||||
current_stock=10,
|
||||
minimum_stock=3,
|
||||
replenishment_batch=5,
|
||||
storage_location="rack_c_01",
|
||||
),
|
||||
}
|
||||
return InventoryCatalog(items)
|
||||
Reference in New Issue
Block a user