Upload
miroslav-kopecky
View
257
Download
1
Embed Size (px)
DESCRIPTION
Way How To connect LegoEV3 (Robot with sensors) to highly concurrent JavaEE system based on spring by solving well know Consumer Producer paradigm.
Citation preview
LET’S SHIFT THETHE WORLD
Miroslav Kopecky
23rd October 2014
MOTIVATION: I HAVE A DREAM
Karel Capek ROBOT
Miroslav Kopecky Prague, 23rd October 2014
© Martin Luther King
CZECH WORD
BEGINNING: HOW IT LOOKED LIKE?
Miroslav Kopecky Prague, 23rd October 2014
DREAM EVOLUTION
Miroslav Kopecky Prague, 23rd October 2014
DREAM REDEFINITION
LET’S CREATE/FIND PROBLEMSand try to provide some set of solutions
Miroslav Kopecky Prague, 23rd October 2014
The Robot under dictate of the LegoMindStorm Java Concurrency API
DO YOU KNOW THE MEANING?
Miroslav Kopecky Prague, 23rd October 2014
AGENDA:• ROBOT INITIATION SEQUENCE INJAVA SPACE
• PRODUCER / CONSUMER PROBLEM • SYNCHRONIZED (demo) • CONCURRENCY API FEATURE (demo) • CONNECT ALL UNITS TOGETHER (demo)
• ROBOT GOES ONLINE (demo)
Miroslav Kopecky Prague, 23rd October 2014
ROBOT INITIATION SEQUENCE
Miroslav Kopecky Prague, 23rd October 2014
LegoMindStorm Java Concurrency APINetwork Communication
Install LeJOS 8.1maven B tool
Compile Libraries (ev3classes)Connect The Brick
(WiFi, Bluetooth,UBS)
EVEN SMALL DREAM IS COMPLEX
Miroslav Kopecky Prague, 23rd October 2014
EVEN SMALL DREAM IS COMPLEX
Miroslav Kopecky Prague, 23rd October 2014
RMI
brick = new RemoteEV3(EV3BRICK_IP); brick.setDefault();
…STILL ONE LegoBRICK…
ProdCons
THE ARE some RULEZ again
Miroslav Kopecky Prague, 23rd October 2014
1. brick.createRegulatedMotor(“A", "M".charAt(0));
2. Port portTouchSensor = brick.getPort("S1"); return new EV3TouchSensor(portTouchSensor);
possible monitor lock
return raw data
3. Mixture of 1 and 2 => IR Sensor (HEAD)
PRODUCER CONSUMER STORY:
Miroslav Kopecky Prague, 23rd October 2014
BUS - Shared DataStructure
ORDERS PRODUCERS
CONSUMERS ~ BRIDGES
SYNCRONIZED (demo 1, 2, 3) - early age
Miroslav Kopecky Prague, 23rd October 2014
public EventStorage(){ maxSize = 4; storage = new LinkedList<>(); motorRight = LegoBrickMoveEnginesProvider.
getInstance().getMotorRight(); motorLeft = LegoBrickMoveEnginesProvider.
getInstance().getMotorLeft(); }
feature:: couldn’t extend the lock beyond boundaries
SYNCHRONIZED 1: THREAD CREATION
Miroslav Kopecky Prague, 23rd October 2014
DEMO
…more threads flying around…
SYNCHRONIZED 2: EXECUTORs
Miroslav Kopecky Prague, 23rd October 2014
DEMO
… creation and execution…
SYNCHRONIZED 3: LegoExecutor
Miroslav Kopecky Prague, 23rd October 2014
DEMO
… statistics…
JAVA CONCURENCY API (demo)
Miroslav Kopecky Prague, 23rd October 2014
couple of synchronisation Utilities: Semaphore, CountDownLatch, CyclicBarrier
Exchanger<List<Integer>> exchanger = new Exchanger<>();
executor.submit( new BrickConsumer( consumerBuffer, exchanger)); executor.shutdown();
EXCHANGER : exchanger.exchange(buffer)
Miroslav Kopecky Prague, 23rd October 2014
DEMO
CONNECT ALL UNITS TOGETHER (demo)
Miroslav Kopecky Prague, 23rd October 2014
concurrency and parallelism in the action
1. sensors + engine (front hand) executor.submit(new MoveSimulationSeparate());
2. movement engine (robot platform) executor.submit(new MovementUnit());
CONNECT ALL UNITS TOGETHER
Miroslav Kopecky Prague, 23rd October 2014
FRONT HAND SYSTEM
PLATFORM
CONNECT ALL UNITS TOGETHER
Miroslav Kopecky Prague, 23rd October 2014
DEMO
… more treads with statistics…
ROBOT GOES ONLINE (demo)
Miroslav Kopecky Prague, 23rd October 2014
not to Hollywood (yet) ~ like Frankie => RELAX
1. Spring 4.1 1. JSP + TILES with AngularJS
2. NETTY -> RaspberryPi 3. LegoROBOT
LegoCommandPriorityQueue<E>
ROBOTS GOES ONLINE
Miroslav Kopecky Prague, 23rd October 2014
DEMO… promising Feature<?>…
QUESTIONS & ANSWERS
I CAN ONLY PLAY THE SOUND!
Miroslav Kopecky Prague, 23rd October 2014
Audio brickAudio = brick.getAudio(); brickAudio.systemSound(?);
THANKs!
Miroslav Kopecky Prague, 23rd October 2014