Update warehouse digital twin and robot fleet optimization
This commit is contained in:
@@ -49,7 +49,7 @@ def sim_env_builder(project_config_dir: Path, tmp_path: Path):
|
||||
|
||||
def test_simulation_environment_creation(sim_env_builder):
|
||||
env = sim_env_builder(seed=42)
|
||||
assert len(env.robots) == 4
|
||||
assert len(env.robots) == 10
|
||||
assert env.env.now == 0.0
|
||||
assert len(env.all_tasks) == 0
|
||||
|
||||
@@ -104,4 +104,55 @@ def test_metrics_serialization(sim_env_builder):
|
||||
assert "throughput_tasks_per_hour" in data
|
||||
assert "fleet_utilization_percent" in data
|
||||
assert "robot_metrics" in data
|
||||
assert len(data["robot_metrics"]) == 4
|
||||
assert len(data["robot_metrics"]) == 10
|
||||
|
||||
|
||||
def test_robot_moves_away_from_rack_after_picking(sim_env_builder):
|
||||
"""Verify that robots picking from storage racks move away into the aisle before loaded transit."""
|
||||
env = sim_env_builder(seed=42)
|
||||
env.run(until=300.0)
|
||||
|
||||
# Filter for move_away_from_rack events
|
||||
move_away_events = [
|
||||
e for e in env.events
|
||||
if e.metadata.get("action") == "move_away_from_rack"
|
||||
]
|
||||
assert len(move_away_events) > 0, "No move_away_from_rack events were recorded after picking"
|
||||
|
||||
# Verify each move-away event details
|
||||
for ev in move_away_events:
|
||||
source_rack = ev.metadata.get("source_rack")
|
||||
aisle_wp = ev.metadata.get("aisle_waypoint")
|
||||
assert source_rack in env.warehouse.storage_locations
|
||||
assert env.graph.has_node(aisle_wp)
|
||||
assert env.graph.nodes[aisle_wp].get("node_type") != "storage_rack"
|
||||
|
||||
# The aisle waypoint must be at a distance >= 1.0m from the source rack
|
||||
rack_pos = env.warehouse.storage_locations[source_rack].position
|
||||
wp_pos = env.path_planner.get_node_position(aisle_wp)
|
||||
assert rack_pos.distance_to(wp_pos) >= 1.0
|
||||
|
||||
|
||||
def test_multi_task_traffic_coordination_and_unoptimized_charging(sim_env_builder):
|
||||
"""Verify that multi-task execution with unoptimized charging stations triggers collision avoidance, yielding, and charging visits."""
|
||||
env = sim_env_builder(seed=42)
|
||||
|
||||
# Configure robots with operational battery levels to trigger visits to the unoptimized charging bays
|
||||
env.robots["amr_light_01"].battery_level = (55.0 / 100.0) * env.robots["amr_light_01"].battery_capacity
|
||||
env.robots["amr_heavy_01"].battery_level = (48.0 / 100.0) * env.robots["amr_heavy_01"].battery_capacity
|
||||
|
||||
metrics = env.run(until=1800.0)
|
||||
|
||||
# 1. Multiple tasks completed across warehouse zones
|
||||
assert metrics.tasks_completed >= 35
|
||||
assert metrics.throughput_tasks_per_hour >= 70.0
|
||||
|
||||
# 2. Collision avoidance and traffic coordination active
|
||||
assert metrics.conflicts_detected > 0
|
||||
assert metrics.yield_waits_count > 0
|
||||
assert metrics.total_wait_time_seconds > 0.0
|
||||
|
||||
# 3. Charging visits executed at unoptimized bays
|
||||
assert (metrics.opportunity_charges + metrics.mandatory_charges) >= 1
|
||||
assert metrics.total_energy_charged_kwh > 0.0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user