Presentation is loading. Please wait.

Presentation is loading. Please wait.

Running Our Robot Overlords with Jakarta EE

Similar presentations


Presentation on theme: "Running Our Robot Overlords with Jakarta EE"— Presentation transcript:

1 Running Our Robot Overlords with Jakarta EE
Experiments in Java Controlling the GoPiGo3 Robot Car With Ken Fogel

2 The Test Platform Dexter Industries GoPiGo3 Robot Car
Development PC (Win 10) Wireless Router TP-Link WR810N 8 AA batteries (NIMH) Ultrasonic Sensor for GrovePi Optional servo motor for sensor sweep Raspberry Pi Computer

3 The Workbench

4 Writing the Java Drivers
The only Java code available from Dexter turned on or off the motors I had to chose from interpreting the Python code or the C code. Found some code that would be at home in my talk about Java Villainy. Kudos to the Pi4J project for providing the necessary code in its core library to communicate with the GoPiGo3 daughterboard Writing the Java Drivers

5 The Java Developer’s Secret Weapon

6 Starting Point in Java public void runMotor(int motor, int power) throws IOException { //TODO Create a Builder byte command[] = new byte[] { (byte) 8, // first byte, start bit (byte) 10, // SET_MOTOR_PWM (byte) motor, // 1 | 2 (byte) power, // }; this.spi.write(command); }

7 Creating a CDI Injectible GoPiGo3 Driver
GoPiGo3DriverProducer

8 Experiment #1: The Basic JSF Controller

9 Experiment #2: The Basic REST Service

10 Experiment #3: JSF 2.3 Websocket Push
JSF 2.3 supports websockets with a tag and a dash of JS Annotations define the push method As the Ultrasonic Sensor must continuously send a stream of data we need a Thread Prior it Java EE 7 creating threads in server side objects was frowned upon Java EE 7 introduced extensions to the SE ThreadFactory called the ManagedThreadFactory Now threads can be created in EE objects Experiment #3: JSF 2.3 Websocket Push

11 JSF 2.3 Websocket Endpoint
A new JSF tag <f:websocket channel="distance" onmessage="socketListener" /> A little JavaScript <script> var reload = true; function socketListener(message, channel, event) { document.getElementById("distanceId").innerHTML = message; } </script> We now have an endpoint

12 Websocket Endpoint Web Page

13 Experiment #5: Websockets- SE to EE
Lots of confusion over the programmatic versus the annotation approach The Oracle documentation is clear but minimal The blogs less so As I write this slide I can send messages to the car but can’t receive a reply It could be working by the time of the presentation

14 Source Code https://gitlab.com/omniprof/gopigo33driver.git

15 Who am I? Co-Chair & Co-Program Coordinator of the Computer Science Technology Program at Dawson College, Montreal Instructor in the Computer Institute of Concordia University Blogger at and on DZone Frequent Twitterer on Speaker at JavaOne from Speaker at Code One in 2018 Speaker at ApacheCon in 2018 Organizer of DawsCon, free one day conference in Montreal on January 11, 2019


Download ppt "Running Our Robot Overlords with Jakarta EE"

Similar presentations


Ads by Google