Orchestrating Robot Swarms with Java / OcadoTechnology < image - - PowerPoint PPT Presentation

orchestrating robot swarms with java
SMART_READER_LITE
LIVE PREVIEW

Orchestrating Robot Swarms with Java / OcadoTechnology < image - - PowerPoint PPT Presentation

Orchestrating Robot Swarms with Java / OcadoTechnology < image of food - maybe a basket of fruit or a christmas hamper > / OcadoTechnology < image of consumer at an empty fridge > / OcadoTechnology < Person getting in car, or


slide-1
SLIDE 1 / OcadoTechnology

Orchestrating Robot Swarms with Java

slide-2
SLIDE 2 / OcadoTechnology < image of food - maybe a basket of fruit or a christmas hamper >
slide-3
SLIDE 3 / OcadoTechnology < image of consumer at an empty fridge >
slide-4
SLIDE 4 / OcadoTechnology < Person getting in car, or driving car >
slide-5
SLIDE 5 / OcadoTechnology < Parking at supermarket >
slide-6
SLIDE 6 / OcadoTechnology < Person with trolley walking around supermarket >
slide-7
SLIDE 7 / OcadoTechnology < Long queue at supermarket >
slide-8
SLIDE 8 / OcadoTechnology < Parking at supermarket >
slide-9
SLIDE 9 / OcadoTechnology < Person getting in car, or driving car >
slide-10
SLIDE 10 / OcadoTechnology < Long queue at supermarket >
slide-11
SLIDE 11 / OcadoTechnology < Screenshot of Ocado.com >
slide-12
SLIDE 12 / OcadoTechnology

Matthew Cornford

Technology Lead Ocado Technology
slide-13
SLIDE 13 / OcadoTechnology

@OcadoTechnology @bofalot

slide-14
SLIDE 14 / OcadoTechnology

The Problem to Solve

<picture of webshop with 50 item £100 basket>
slide-15
SLIDE 15 / OcadoTechnology

The Problem to Solve

<picture of screen showing delivery slots>
slide-16
SLIDE 16 / OcadoTechnology Automated Fulfilment Solutions <picture of outside or inside of supermarket>
slide-17
SLIDE 17 / OcadoTechnology

Automated Fulfilment

<picture of UK with hubs and spokes indicated>
slide-18
SLIDE 18 / OcadoTechnology

Customer Fulfilment Centres

slide-19
SLIDE 19 / OcadoTechnology

Automated Fulfilment

<picture of personal shopper at a MASOPS station>
slide-20
SLIDE 20 / OcadoTechnology

Original Solution

<video of Dordon showing conveyor and MASOPS>
slide-21
SLIDE 21 / OcadoTechnology
slide-22
SLIDE 22 / OcadoTechnology

Robot Swarms

<video of rainbow, some drone footage over the grid would be good>
slide-23
SLIDE 23 / OcadoTechnology

Robot Stats

Grid the size of 3 football pitches Up to 3000 robots at any one time 4m/s bot speed 5mm clearance 35kg load Communicating 10 times a second over an unlicensed part of the 4G spectrum
slide-24
SLIDE 24 / OcadoTechnology
slide-25
SLIDE 25 / OcadoTechnology

System Overview

Why Java? Simulation Determinism Low Latency Communication
slide-26
SLIDE 26 / OcadoTechnology System Overview

Why Java?

Simulation Determinism Low Latency Communication
slide-27
SLIDE 27 / OcadoTechnology System Overview Why Java?

Simulation

Determinism Low Latency Communication
slide-28
SLIDE 28 / OcadoTechnology System Overview Why Java? Simulation

Determinism

Low Latency Communication
slide-29
SLIDE 29 / OcadoTechnology System Overview Why Java? Simulation Determinism

Low Latency Communication

slide-30
SLIDE 30 / OcadoTechnology

System Overview

Why Java? Simulation Determinism Low Latency Communication
slide-31
SLIDE 31 / OcadoTechnology

System Overview

<graphic showing high-level system. Basically a box to represent Dash (Java) wirelessly communicating with multiple bots (C)>
slide-32
SLIDE 32 / OcadoTechnology

Premature optimization is the root of all evil

System Overview

Donald Knuth

“ ”

slide-33
SLIDE 33 / OcadoTechnology System Overview

Why Java?

Simulation Determinism Low Latency Communication
slide-34
SLIDE 34 / OcadoTechnology

Why Java?

Speed of Development vs Performance

slide-35
SLIDE 35 / OcadoTechnology
slide-36
SLIDE 36 / OcadoTechnology System Overview Why Java?

Simulation

Determinism Low Latency Communication
slide-37
SLIDE 37 / OcadoTechnology

A simulation is an approximate imitation of the

  • peration of a process or system; the act of

simulating first requires a model is developed

Simulation

slide-38
SLIDE 38 / OcadoTechnology

Simulation

slide-39
SLIDE 39 / OcadoTechnology

Why use Simulation?

Hardware <maybe a graphic of a bot and a person>
slide-40
SLIDE 40 / OcadoTechnology

What Do We Simulate?

Java Control System Simulated Software Systems Simulated Bot Simulated People
slide-41
SLIDE 41 / OcadoTechnology

Simulation Example

Speed Time
slide-42
SLIDE 42 / OcadoTechnology A discrete-event simulation (DES) models the operation of a system as a discrete sequence of events in time. Each event occurs at a particular instant in time and marks a change of state in the
  • system. Between consecutive events, no change in the system is
assumed to occur; thus the simulation can directly jump in time from one event next.

Discrete Event Simulation

slide-43
SLIDE 43 / OcadoTechnology Act on position event 0 Bot reports position 0 T Simulation time Real time Act on position event 1 Bot reports position 1 Act on position event 2 Bot reports position 2 Act on position event 3 Bot reports position 3 2T 3T

Discrete Event Simulation

slide-44
SLIDE 44 / OcadoTechnology System Overview Why Java? Simulation

Determinism

Low Latency Communication
slide-45
SLIDE 45 / OcadoTechnology

Determinism

  • Real-time systems are not deterministic
  • We want determinism in our discrete event simulations
  • We test for it in our CI pipeline
  • Three areas:
○ Time ○ Scheduling ○ Iteration
slide-46
SLIDE 46 / OcadoTechnology @FunctionalInterface public interface TimeProvider { long getTime(); }

Determinism - Time

slide-47
SLIDE 47 / OcadoTechnology public class AdjustableTimeProvider implements TimeProvider { private long currentTime; @Override public long getTime() { return this.currentTime; } public void setTime(long time) { this.currentTime = time; } }

Determinism - Time

slide-48
SLIDE 48 / OcadoTechnology public class SystemTimeProvider implements TimeProvider { @Override public long getTime() { return System.currentTimeMillis(); } }

Determinism - Time

slide-49
SLIDE 49 / OcadoTechnology public interface Event { long getTime(); void run(); void cancel(); }

Determinism - Scheduling

public interface EventScheduler { Event doNow(Runnable r); Event doAt(long time, Runnable r) }
slide-50
SLIDE 50 / OcadoTechnology public class DiscreteEventScheduler implements EventScheduler { private final AdjustableTimeProvider timeProvider; private final EventQueue queue; private void executeEvents() { Event nextEvent = queue.getNextEvent(); while (nextEvent != null) { timeProvider.setTime(nextEvent.getTime()); nextEvent.run(); nextEvent = queue.getNextEvent(); } } }

Determinism - Scheduling

slide-51
SLIDE 51 / OcadoTechnology public class RealTimeEventScheduler implements EventScheduler { ... }

Determinism - Scheduling

slide-52
SLIDE 52 / OcadoTechnology private Set<String> mySet = Set.of("a", "b", "c"); for (String entry : mySet) { doStuff(); }

Determinism - Iteration

“The iteration order of set elements is unspecified and is subject to change.”
slide-53
SLIDE 53 / OcadoTechnology private ImmutableSet<String> mySet = ImmutableSet.of("a", "b", "c"); for (String entry : mySet) { doStuff(); }

Determinism - Iteration

“Except for sorted collections, order is preserved from construction time.”
slide-54
SLIDE 54 / OcadoTechnology System Overview Why Java? Simulation Determinism

Low Latency Communication

slide-55
SLIDE 55 / OcadoTechnology

Event Scheduling

Requirements:
  • To schedule events for specific times
  • Individual events can’t be arbitrarily delayed
  • The system can’t allow the events to arbitrarily backup
slide-56
SLIDE 56 / OcadoTechnology
slide-57
SLIDE 57 / OcadoTechnology
slide-58
SLIDE 58 / OcadoTechnology public class RealTimeEventScheduler implements EventScheduler { private final TimeProvider timeProvider; private final EventQueue queue; private void executeEvents() { Event nextEvent = queue.getNextEvent(); while (true) { if (nextEvent.getTime() <= timeProvider.getTime()) { nextEvent.run(); nextEvent = queue.getNextEvent(); } } } }

Event Scheduling - Busy Loop

slide-59
SLIDE 59 / OcadoTechnology

Advantages

  • Lower latency for individual
events - from <5ms down to effectively 0
  • Supports up to 3 times higher
throughput of events

Disadvantages

  • 100% CPU utilisation
  • Can reduce clock speed due to
the processor heating up

Event Scheduling - Busy Loop

slide-60
SLIDE 60 / OcadoTechnology

Memoization

We use two main flavours:
  • “Standard”
  • Object caching
slide-61
SLIDE 61 / OcadoTechnology

Garbage Collection

GC is a primary source of application pauses
  • Remove java.util.Optional from APIs that are heavily used
  • Use for loops instead of the Streams API
  • Use an Array backed data structure instead of java.util.HashSet or
java.util.LinkedList
  • Avoid primitive boxing, especially in unexpected places such as log lines, for
example: log.debug("{}", d)
slide-62
SLIDE 62 / OcadoTechnology

Garbage Collection Tips

  • Enable GC logs by default!
  • Understand the different collectors
  • Don’t just take the latest and “greatest” garbage collector
slide-63
SLIDE 63 / OcadoTechnology G1GC
  • Used in production
  • Can specify target pause time
with
  • XX:MaxGCPauseMillis=200
  • Trade-off with lower throughput
and higher use of CPU by GC

G1GC vs ZGC

ZGC
  • New in Java 11
  • Experimental
  • Promises very low pause times
slide-64
SLIDE 64 / OcadoTechnology

G1GC vs ZGC

slide-65
SLIDE 65 / OcadoTechnology
slide-66
SLIDE 66 / OcadoTechnology

Summary

  • Grocery is a difficult retail sector to run online profitably
  • We use Java within our Customer Fulfilment Centres to help us do this
  • Within our warehouses, simulation is used extensively
  • Many abstractions added to satisfy our need for determinism
  • We start simple, test and measure, then optimise where necessary
slide-67
SLIDE 67 / OcadoTechnology

We’re Hiring https://careers.oca.do

@OcadoTechnology @bofalot