Update warehouse digital twin and robot fleet optimization
This commit is contained in:
@@ -204,3 +204,84 @@ def test_closest_node_lookup(planner_setup):
|
||||
|
||||
# Light AMR node must NOT be inside Zone B internal aisles
|
||||
assert planner.graph.nodes[closest_light].get("zone") != "zone_b"
|
||||
|
||||
|
||||
def test_paths_never_pass_through_intermediate_racks(planner_setup):
|
||||
"""Verify that paths from racks to stations never pass through other storage racks."""
|
||||
planner, builder, graph = planner_setup
|
||||
warehouse = builder.model
|
||||
rack_positions = {k: (v.position.x, v.position.y) for k, v in warehouse.storage_locations.items()}
|
||||
|
||||
for loc_id, pos in rack_positions.items():
|
||||
src = f"rack_{loc_id}"
|
||||
for st_id in warehouse.stations.keys():
|
||||
dest = f"station_{st_id}"
|
||||
for rtype in ["heavy_amr", "light_amr"]:
|
||||
if rtype == "light_amr" and ("_b_" in loc_id or "picking_station_b1" in st_id):
|
||||
continue
|
||||
path = planner.find_shortest_path(src, dest, robot_type=rtype)
|
||||
assert len(path) >= 2
|
||||
assert path[0] in (src, planner.resolve_node_id(src))
|
||||
assert path[-1] == dest
|
||||
|
||||
# Check intermediate nodes: must not coincide with any other rack
|
||||
for intermediate_nid in path[1:-1]:
|
||||
assert graph.nodes[intermediate_nid].get("node_type") != "storage_rack"
|
||||
int_pos = (graph.nodes[intermediate_nid]["pos"][0], graph.nodes[intermediate_nid]["pos"][1])
|
||||
for other_loc_id, other_pos in rack_positions.items():
|
||||
if other_loc_id != loc_id:
|
||||
dist = (
|
||||
(int_pos[0] - other_pos[0]) ** 2 + (int_pos[1] - other_pos[1]) ** 2
|
||||
) ** 0.5
|
||||
assert dist >= 0.5, (
|
||||
f"Path from {src} to {dest} ({rtype}) improperly cuts through {other_loc_id} "
|
||||
f"at node {intermediate_nid} {int_pos}"
|
||||
)
|
||||
|
||||
|
||||
def test_rack_aisle_waypoint_lookup(planner_setup):
|
||||
"""Verify get_rack_aisle_waypoint identifies traversable aisle waypoint outside rack footprint."""
|
||||
planner, builder, graph = planner_setup
|
||||
warehouse = builder.model
|
||||
|
||||
for loc_id, loc in warehouse.storage_locations.items():
|
||||
rnid = f"rack_{loc_id}"
|
||||
aisle_wp = planner.get_rack_aisle_waypoint(rnid)
|
||||
assert aisle_wp is not None
|
||||
assert graph.has_node(aisle_wp)
|
||||
assert graph.nodes[aisle_wp].get("node_type") != "storage_rack"
|
||||
|
||||
wp_pos = planner.get_node_position(aisle_wp)
|
||||
dist = loc.position.distance_to(wp_pos)
|
||||
# Aisle waypoint must be at least 1.0m away from the rack structure
|
||||
assert dist >= 1.0
|
||||
|
||||
|
||||
def test_paths_never_pass_through_intermediate_stations(planner_setup):
|
||||
"""Verify that paths between stations/chargers never pass through intermediate docking stations."""
|
||||
planner, builder, graph = planner_setup
|
||||
warehouse = builder.model
|
||||
station_nodes = [f"station_{s}" for s in warehouse.stations.keys()]
|
||||
|
||||
# Test routes between station pairs and between stations and chargers
|
||||
for src in station_nodes:
|
||||
for dst in station_nodes:
|
||||
if src == dst:
|
||||
continue
|
||||
path = planner.find_shortest_path(src, dst, robot_type="heavy_amr")
|
||||
assert len(path) >= 2
|
||||
assert path[0] == src
|
||||
assert path[-1] == dst
|
||||
|
||||
# Intermediate nodes must not be any other station or coincident station waypoint
|
||||
for intermediate_nid in path[1:-1]:
|
||||
assert intermediate_nid not in station_nodes
|
||||
for other_st in station_nodes:
|
||||
if other_st != src and other_st != dst:
|
||||
coinc = planner._nodes_at_station_locations.get(other_st, set())
|
||||
assert intermediate_nid not in coinc, (
|
||||
f"Path from {src} to {dst} improperly passed through intermediate dock {other_st} "
|
||||
f"at node {intermediate_nid}"
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user