Initial commit: Autonomous Mobile Robot (AMR) warehouse fleet simulator & OpenUSD digital twin

This commit is contained in:
om_karande
2026-10-26 12:38:52 +05:30
commit eee8d11800
12 changed files with 10986 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
import numpy as np
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation, PillowWriter
from matplotlib.lines import Line2D
from fleet_sim import run, make_grid, W, H, CHARGERS, DROP, PICKUPS
N, STRATEGY, SKIP = 6, "optimized", 10
res = run(N, STRATEGY, seed=1, record=True)
COL = {"TO_PICK": "tab:blue", "LOADING": "tab:purple", "TO_DROP": "tab:green",
"UNLOADING": "tab:red", "TO_CHARGER": "tab:orange", "CHARGING": "gold", "IDLE": "gray"}
fig, (ax, axh) = plt.subplots(1, 2, figsize=(14, 5))
ax.imshow(np.array(make_grid()), cmap="Greys", alpha=0.6)
ax.scatter(*zip(*CHARGERS), marker="s", s=150, c="gold", edgecolors="k")
ax.scatter(*DROP, marker="s", s=150, c="limegreen", edgecolors="k")
ax.scatter(*zip(*PICKUPS), marker=".", s=15, c="saddlebrown")
sc = ax.scatter([], [], s=140, edgecolors="k")
ax.set_title(f"{STRATEGY} strategy, {N} robots")
ax.legend(handles=[Line2D([0], [0], marker="o", color="w", markerfacecolor=c, markeredgecolor="k",
markersize=9, label=s) for s, c in COL.items()],
loc="upper center", bbox_to_anchor=(0.5, -0.12), ncol=4, fontsize=8)
heat = np.zeros((H, W))
for (x, y), v in res["heat"].items():
heat[y, x] = v
im = axh.imshow(heat, cmap="hot")
axh.set_title("Congestion heatmap (seconds spent waiting per cell)")
fig.colorbar(im, ax=axh, shrink=0.8)
def update(i):
frame = res["frames"][i * SKIP]
sc.set_offsets(np.c_[[p[0][0] for p in frame], [p[0][1] for p in frame]])
sc.set_color([COL[p[1]] for p in frame])
ax.set_xlabel(f"t={i*SKIP}s battery %: " + " ".join(f"R{k}:{p[2]}" for k, p in enumerate(frame)),
fontsize=8)
return (sc,)
ani = FuncAnimation(fig, update, frames=len(res["frames"]) // SKIP, interval=50)
fig.tight_layout()
ani.save("results/demo.gif", writer=PillowWriter(fps=20))
# plt.show()