Fast & cheap simulator for a robotic warehouse: the same code in prod and the simulator

Renat Iuldashev

· updated
Abstract

We run production warehouse control software and a simulator from a single codebase. Good old event-driven simulation keeps runs cheap and fast, and robot models simple.


The robotic warehouse

At Volume DIVE, we build warehouses where wheeled robots move plastic containers along a shared rail grid, carrying them between storage stacks and stations where people pick or replenish goods.

Volume DIVE robots moving containers across a rail grid between storage and picking stations

Three months wasted

… trying to use pre-built warehouse simulation software. The problems I recall:

  • Popular simulators used in robotics, such as Gazebo and NVIDIA Isaac Sim, are glorified physics engines. I need to compute throughput, analyze robot routes, and simulate delays, rather than calculate the friction that keeps a plastic container in place.
  • Warehouse and logistics simulators, such as AnyLogic and Visual Components, are literally visual and have closed ecosystems. You need to assemble both the grid and the robots in a 3D editor. That’s a lot of manual work.
  • Built-in UIs are only good for sim. And I want to have the same visualization for the simulator and production.
  • Most of the simulators are expensive. Ready to spend $10k+?

Grappling with “easy-to-use” simulators helped me figure out what we need.

Requirements

  1. The same code in production and simulation.
  2. Faster-than-real-time simulation.
  3. A web server and browser-based UI.
  4. Primitive physics, complicated behaviour where we want it.

Implementing from scratch: architecture & ideas

The same warehouse control software connects to real robots using a real-time clock, or simulated robots using a virtual clock.

Basically, the design flows from the requirements. Single code base controls robots and records container locations. For simulation we change only two things:

  • Real-time clock -> virtual clock
  • Real robots -> simulated robots

Virtual clock

The simulator keeps a queue of events, each with a virtual time: a robot starts moving, arrives, or finishes lifting. It processes all events at the current time, updating the warehouse and scheduling what happens next, then jumps to the earliest pending event.

Try the simulation below of two robots driving simultaneously on the grid: click Process until no events are ready, then Advance time.

PICK UPARRIVEAB
Now: 0 s4 s7 s10 s
ReadyReady
Pending events
Queue empty
Queue empty

Start the simulation to emit the first events.

The robots move concurrently in the model, though the computer processes events one by one. B’s journey takes ten virtual seconds without ten seconds of real waiting. Simple, fast, and cheap.

Open-source libraries supporting discrete-event simulation are readily available: SimPy (Python), OMNeT++ (C++), and JSL (Java). Or you can build a custom event queue.

Conclusions

It’s better to use a ready-made solution, but none fit our project. Implementing one from scratch turned out not to be that hard.

P.S. It’s not new

The “virtual clock” approach here is called discrete-event simulation. Early descriptions include Tocher and Owen’s The Automatic Programming of Simulations (1960), Gordon’s A General Purpose Systems Simulation Program (1961), and Markowitz, Hausner, and Karr’s SIMSCRIPT: A Simulation Programming Language (1962).

References

  1. Volume DIVE
  2. Visual Components
  3. AnyLogic: Warehouse Operations
  4. Gazebo: Physics
  5. NVIDIA Isaac Sim: Simulation Fundamentals
  6. K. D. Tocher and D. G. Owen: The Automatic Programming of Simulations (1960; republished 2008)
  7. Geoffrey Gordon: A General Purpose Systems Simulation Program (1961)
  8. Harry M. Markowitz, Bernard Hausner, and H. W. Karr: SIMSCRIPT: A Simulation Programming Language (1962)
  9. SimPy documentation
  10. OMNeT++ documentation
  11. JSL