SlideShare ist ein Scribd-Unternehmen logo
1 von 52
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.1
InfoQ.com: News & Community Site
• 750,000 unique visitors/month
• Published in 4 languages (English, Chinese, Japanese and Brazilian
Portuguese)
• Post content from our QCon conferences
• News 15-20 / week
• Articles 3-4 / week
• Presentations (videos) 12-15 / week
• Interviews 2-3 / week
• Books 1 / month
Watch the video with slide
synchronization on InfoQ.com!
http://www.infoq.com/presentations
/raspberry-pi-java-car
Presented at QCon London
www.qconlondon.com
Purpose of QCon
- to empower software development by facilitating the spread of
knowledge and innovation
Strategy
- practitioner-driven conference designed for YOU: influencers of
change and innovation in your teams
- speakers and topics driving the evolution and innovation
- connecting and catalyzing the influencers and innovators
Highlights
- attended by more than 12,000 delegates since 2007
- held in 9 cities worldwide
Is It A Car? Is It A Computer?
No, It’s The Raspberry Pi
Java Carputer
Simon Ritter
Head of Java Evangelism
Oracle Corporation
@speakjava
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.3
The following is intended to outline our general product
direction. It is intended for information purposes only, and
may not be incorporated into any contract. It is not a
commitment to deliver any material, code, or functionality,
and should not be relied upon in making purchasing
decisions. The development, release, and timing of any
features or functionality described for Oracle s products
remains at the sole discretion of Oracle.
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.4
Program Agenda
§  Cars and Computers
§  The Raspberry Pi
§  Embedded Java and JavaFX
§  Building a Java Powered “Carputer”
§  Demos
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.5
Cars And Computers
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.6
My First Car: 1981
§  No electronics
–  Well, it had a radio
§  Purely electromechanical
–  Points/Distributor
–  Carburettor/Manual choke
–  Drum brakes
–  Dynamo
–  Lights, horn, wipers, fan, ignition switch
1971 Mini Clubman 1000
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.7
Car Wiring: 1970s
Image coutesy of Haynes manuals
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.8
My Current Car
§  Lots of electronics
–  Engine Control Unit (ECU)
–  Fuel Injection/Electronic timing
–  “Fly-by-wire” throttle
–  Anti-lock Braking System (ABS)
–  Electronic Stability Program (ESP)
–  Magnetorheological Suspension
–  Satellite navigation
–  Auto-sensing wipers and lights
2011 Audi S3
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.9
Car Wiring: 2011
Bus architecture means substantially less wiring
Convenience Bus Infotainment Bus Powertrain Bus
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.10
Protocols For Car Bus Communication
§  On Board Diagnostics (OBD-II)
–  Connector, SAE J1939 / ISO 15031-3
§  OBD-II Protocols
–  SAE J1850 PWM or VPM
–  ISO 9141-2
–  ISO 14230
–  ISO 15765-4: Controller Area Network (CAN) Bus
§  11 or 29 bit ID, 250 or 500 kbaud
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.11
The Raspberry Pi
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.12
Raspberry Pi
§  Project started in 2006
–  Goal was to devise a computer to inspire children
–  Inspiration from the BBC Micro project from 1981
–  Officially launched 29th Feb, 2012
–  Over 1 million boards shipped so far
History and Goals
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.13
Raspberry Pi
§  CPU: ARM 11 (v6) core running at 700MHz
–  Broadcom SoC package
–  Can now be overclocked to 1GHz (without breaking the warranty!)
§  Memory: 512Mb
§  I/O:
–  HDMI and composite video
–  Audio out (3.5mm plug)
–  2 x USB ports
–  Ethernet
–  Header pins for GPIO, UART, SPI and I2C
Specification
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.14
Raspberry Pi Carputer
§  Plenty of computing power
–  With low electrical power consumption (< 1 Amp at 5V)
§  Persistent storage provided by SD card
–  Disk drives not ideal in hot places with lots of vibration
§  Supported device for embedded Java
–  Hardware floating point acceleration configured
–  Java SE Embedded and Java ME Embedded
–  JavaFX Prism graphics engine ported
Advantages
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.15
Embedded Java and JavaFX
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.16
Java Technology for Embedded Devices
Platform
Footprint
Device
CPU/
GPU/I-OARM 7 Cortex M ARM9/11 MIPS32 ARM Cortex A PPC Intel Atom
50KB-1MB
1MB-10MB
10MB-100MB Java ME
Java SE
Java
Card
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.17
Java ME Embedded 3.3
§  Connected Limited Device Configuration 1.1
–  Reduced footprint JVM and core libraries
§  Device Access API (new)
–  Standard library for access to
§  GPIO
§  UART
§  I2C/SPI
§  Additional profiles used as required
Key Features
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.18
Java SE 8 Embedded (Early Access)
§  Tuned for Raspberry Pi
–  ARM6 architecture does not require hardware FP
–  Raspberry Pi has one, so JVM needs specific compiler options
§  Inlcudes JavaFX
§  Includes compact profiles for reduced footprint
§  Recently added to standard build platforms
–  EA updated as each new build comes out
Key Features
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.19
JavaFX On Embedded Devices
§  JavaFX on embedded does not support the full feature set
–  No WebView component (not a problem for the carputer)
–  No direct media playback support
§  For video there is a work around (but, does the carputer need it?)
§  Sound would be nice, but not essential
§  Remember resource constraints
–  Big scene graphs need memory and CPU cycles
–  Keep number of nodes small (ideally <50)
Things To Consider
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.20
Building a Java Powered
“Carputer”
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.21
Carputer Design Objectives
§  Display realtime data
–  Engine performance (Power, Torque, Load)
–  Driver data (Throttle position, steering angle, braking force, etc)
–  G-Forces on car
§  Record data for later analysis
–  Produce graphs to display changes over time
–  Play at Formula 1
–  Improve driving style (!)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.22
ELM327
§  WiFi or Bluetooth connection to OBD-II
§  Fixed IP address, Ad-hoc networking
§  Need to configure Raspberry Pi
–  /etc/network/interfaces
§  AT style commands for control
§  Non-AT commands are assumed to be OBD-II
–  Simple request-response interaction
–  Easy to write Java code to handle this
Cheap way to hack your car
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.23
Touchscreen
§  2 DIN fitting size
–  Ideal for centre console
§  HDMI input
–  Specifically marketed for Raspberry Pi
§  USB connection for touch screen
Lots of things available on eBay
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.24
JavaFX And Touchscreen
§  Raspian Linux recognises device: eGalax Inc
§  Creates two devices in /dev/input/event0, event1
§  JavaFX sees devices and uses event0
–  No events generated
–  Need to use event1 (No idea why)
§  Special build of JavaFX?
§  Neccesity is the mother of invention
–  Delete event0 and mknod event0 c 13 65 (same as event1)
–  Need script to repeat at boot time
Not completely straightforward
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.25
Carputer Hardware Architecture
USB WiFi Dongle
Touch Screen
Accelerometer
HDMI USB
I2C
12V Car
Converter
ELM327
Car
Service
Port
5V USB
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.26
Touchscreen
Hardware Fitting Challenges
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.27
Accelerometer
§  Sparkfun breakout board MPU 9150
–  9 DoF sensor (accelerometer, gyroscope, compass)
§  Communications via I2C
–  Configure Raspberry Pi /etc/modules
§  i2c-bcm2708, i2c-dev
§  i2c-detect -y 1 to get address
–  Compass communication is a bit more complicated
§  Second I2C bus
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.28
Accelerometer Code
Using Pi4J Library on Java SE Embedded
I2CBus bus = I2CFactory.getInstance(I2CBus.BUS_1);
I2CDevice device = bus.getDevice(0x68);
/* Start sensing */
device.write(0x6B, (byte)0b00000000);
device.write(0x6C, (byte)0b00000000);
/* Set configuration */
device.write(0x1B, (byte)0b00011000); // Gyroscope
device.write(0x1C, (byte)0b00000100); // Accelerometer
device.read(0x3B, accelData, 0, ACCEL_PACKET_SIZE);
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.29
Compensating For Gravity In Acceleration
§  The accelerometer measures acceleration (obviously)
§  Gravity is a constant acceleration
–  Consider it static acceleration
§  What we want is dynamic acceleration
§  Zero out gravitational effect
–  Assume no rotation of the sensor
–  Nearly correct, car will roll in corners and pitch under braking/acceleration
–  Good enough for the demo
–  Could integrate gyro and Kalman filter for higher accuracy
The Earth Sucks
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.30
Calculating Power And Torque
§  Results will not have high accuracy
–  Values in red are not precise
§  Dynamometer is the only way to get accurate figures
§  Interesting to see values v. manufacturers figures
Torque (Nm) = Mass x Wheel Radius x Acceleration (in G)
Torque (lb/ft) = Torque in Nm x 0.73756
Power (BHP) = Torque (lb/ft) x engine RPM / 5252
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.31
Carputer Software Architecture
§  Screens based
–  Splash screen
–  Basic and advanced car data
–  G forces on car
–  Graphed results of different parameters
§  Simple UI
–  Can’t read numbers when driving
§  Touchscreen to switch screens
–  Repurpose existing car controls to change screen?
Realtime Data
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.32
UI Design Ideas
Take Inspiration From Others
Renault Megane Sport
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.33
UI Design Ideas
Take Inspiration From Others
Tesla
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.34
UI Design Ideas
Take Inspiration From Others
Lamborghini Reveton
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.35
Simple Data Display Control
§  Only uses 3 nodes
–  Polygon
–  Rectangle
–  Line
–  Labels are optional
§  Displays
–  Current value
–  Maximum value since start (resetable)
§  Simple to understand from a glance
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.36
User Interaction
§  Complex UIs are bad for driver distraction
–  Programming the SatNav while driving
§  Make Carputer interaction as simple as possible
§  Sequence of screens
–  Main menu? Too complex, too much reading
–  Cycle through screens (Keep number small)
–  Just touch screen to change to next display
§  Use setMouseTransparent(true);
–  Use steering wheel button
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.37
UI Screens
Splash Screen
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.38
UI Screens
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.39
UI Screens
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.40
UI Screens
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.41
Graph Plots Of Throttle Position And Power
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.42
Using Car Control Buttons
§  Not simple
–  Car manufacturers don’t share the CAN bus IDs and message formats
–  Even things like Audi forums can’t supply this
–  Need to reverse engineer
§  ELM327 has AT MA command
–  Monitor all CAN Bus traffic
–  Need to pick the relevant message from a LOT of data
–  Once the ID is know use AT MT xx to monitor transmit messages
Monitoring CAN Bus Data
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.43
Future Ideas, Conclusions
and Resources
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.44
What Next
§  Integrate heart rate monitor to add biometric data
§  Heads Up Display (HUD)
–  Microprojector and half-silvered perspex
§  Further investigation of CAN Bus signals
–  Brake pressure, steering position
–  Use other switches
–  Send commands (this is rather scary)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.45
Adafruit Ultimate GPS Breakout
P1-01
TX
RX
NOTE: RX TX
TX RX
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.46
The Pi Can Interface
§  Can’t read CAN bus and OBDII at the
same time via ELM327
§  Use connector for entertainment
system
§  Need to check that I2C for
accelerometer will still work
§  Reasonable cost, $50
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.47
Resources
§  www.audi.com
§  www.raspberrypi.org
§  javafx.oracle.com
§  blogs.oracle.com/speakjava
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.48
Demos
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.49
Watch the video with slide synchronization on
InfoQ.com!
http://www.infoq.com/presentations/raspberry-
pi-java-car

Weitere ähnliche Inhalte

Mehr von C4Media

Understand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsUnderstand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsC4Media
 
Kafka Needs No Keeper
Kafka Needs No KeeperKafka Needs No Keeper
Kafka Needs No KeeperC4Media
 
High Performing Teams Act Like Owners
High Performing Teams Act Like OwnersHigh Performing Teams Act Like Owners
High Performing Teams Act Like OwnersC4Media
 
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaDoes Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaC4Media
 
Service Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideService Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideC4Media
 
Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDC4Media
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine LearningC4Media
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at SpeedC4Media
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsC4Media
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsC4Media
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerC4Media
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleC4Media
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeC4Media
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereC4Media
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing ForC4Media
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data EngineeringC4Media
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreC4Media
 
Navigating Complexity: High-performance Delivery and Discovery Teams
Navigating Complexity: High-performance Delivery and Discovery TeamsNavigating Complexity: High-performance Delivery and Discovery Teams
Navigating Complexity: High-performance Delivery and Discovery TeamsC4Media
 
High Performance Cooperative Distributed Systems in Adtech
High Performance Cooperative Distributed Systems in AdtechHigh Performance Cooperative Distributed Systems in Adtech
High Performance Cooperative Distributed Systems in AdtechC4Media
 
Rust's Journey to Async/await
Rust's Journey to Async/awaitRust's Journey to Async/await
Rust's Journey to Async/awaitC4Media
 

Mehr von C4Media (20)

Understand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsUnderstand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java Applications
 
Kafka Needs No Keeper
Kafka Needs No KeeperKafka Needs No Keeper
Kafka Needs No Keeper
 
High Performing Teams Act Like Owners
High Performing Teams Act Like OwnersHigh Performing Teams Act Like Owners
High Performing Teams Act Like Owners
 
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaDoes Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
 
Service Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideService Meshes- The Ultimate Guide
Service Meshes- The Ultimate Guide
 
Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CD
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine Learning
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at Speed
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep Systems
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.js
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly Compiler
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix Scale
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's Edge
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home Everywhere
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing For
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data Engineering
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
 
Navigating Complexity: High-performance Delivery and Discovery Teams
Navigating Complexity: High-performance Delivery and Discovery TeamsNavigating Complexity: High-performance Delivery and Discovery Teams
Navigating Complexity: High-performance Delivery and Discovery Teams
 
High Performance Cooperative Distributed Systems in Adtech
High Performance Cooperative Distributed Systems in AdtechHigh Performance Cooperative Distributed Systems in Adtech
High Performance Cooperative Distributed Systems in Adtech
 
Rust's Journey to Async/await
Rust's Journey to Async/awaitRust's Journey to Async/await
Rust's Journey to Async/await
 

Kürzlich hochgeladen

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 

Kürzlich hochgeladen (20)

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 

Is It A Car? Is It A Computer? No, It's a Raspberry Pi

  • 1. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.1
  • 2. InfoQ.com: News & Community Site • 750,000 unique visitors/month • Published in 4 languages (English, Chinese, Japanese and Brazilian Portuguese) • Post content from our QCon conferences • News 15-20 / week • Articles 3-4 / week • Presentations (videos) 12-15 / week • Interviews 2-3 / week • Books 1 / month Watch the video with slide synchronization on InfoQ.com! http://www.infoq.com/presentations /raspberry-pi-java-car
  • 3. Presented at QCon London www.qconlondon.com Purpose of QCon - to empower software development by facilitating the spread of knowledge and innovation Strategy - practitioner-driven conference designed for YOU: influencers of change and innovation in your teams - speakers and topics driving the evolution and innovation - connecting and catalyzing the influencers and innovators Highlights - attended by more than 12,000 delegates since 2007 - held in 9 cities worldwide
  • 4. Is It A Car? Is It A Computer? No, It’s The Raspberry Pi Java Carputer Simon Ritter Head of Java Evangelism Oracle Corporation @speakjava
  • 5. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.3 The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle s products remains at the sole discretion of Oracle.
  • 6. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.4 Program Agenda §  Cars and Computers §  The Raspberry Pi §  Embedded Java and JavaFX §  Building a Java Powered “Carputer” §  Demos
  • 7. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.5 Cars And Computers
  • 8. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.6 My First Car: 1981 §  No electronics –  Well, it had a radio §  Purely electromechanical –  Points/Distributor –  Carburettor/Manual choke –  Drum brakes –  Dynamo –  Lights, horn, wipers, fan, ignition switch 1971 Mini Clubman 1000
  • 9. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.7 Car Wiring: 1970s Image coutesy of Haynes manuals
  • 10. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.8 My Current Car §  Lots of electronics –  Engine Control Unit (ECU) –  Fuel Injection/Electronic timing –  “Fly-by-wire” throttle –  Anti-lock Braking System (ABS) –  Electronic Stability Program (ESP) –  Magnetorheological Suspension –  Satellite navigation –  Auto-sensing wipers and lights 2011 Audi S3
  • 11. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.9 Car Wiring: 2011 Bus architecture means substantially less wiring Convenience Bus Infotainment Bus Powertrain Bus
  • 12. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.10 Protocols For Car Bus Communication §  On Board Diagnostics (OBD-II) –  Connector, SAE J1939 / ISO 15031-3 §  OBD-II Protocols –  SAE J1850 PWM or VPM –  ISO 9141-2 –  ISO 14230 –  ISO 15765-4: Controller Area Network (CAN) Bus §  11 or 29 bit ID, 250 or 500 kbaud
  • 13. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.11 The Raspberry Pi
  • 14. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.12 Raspberry Pi §  Project started in 2006 –  Goal was to devise a computer to inspire children –  Inspiration from the BBC Micro project from 1981 –  Officially launched 29th Feb, 2012 –  Over 1 million boards shipped so far History and Goals
  • 15. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.13 Raspberry Pi §  CPU: ARM 11 (v6) core running at 700MHz –  Broadcom SoC package –  Can now be overclocked to 1GHz (without breaking the warranty!) §  Memory: 512Mb §  I/O: –  HDMI and composite video –  Audio out (3.5mm plug) –  2 x USB ports –  Ethernet –  Header pins for GPIO, UART, SPI and I2C Specification
  • 16. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.14 Raspberry Pi Carputer §  Plenty of computing power –  With low electrical power consumption (< 1 Amp at 5V) §  Persistent storage provided by SD card –  Disk drives not ideal in hot places with lots of vibration §  Supported device for embedded Java –  Hardware floating point acceleration configured –  Java SE Embedded and Java ME Embedded –  JavaFX Prism graphics engine ported Advantages
  • 17. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.15 Embedded Java and JavaFX
  • 18. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.16 Java Technology for Embedded Devices Platform Footprint Device CPU/ GPU/I-OARM 7 Cortex M ARM9/11 MIPS32 ARM Cortex A PPC Intel Atom 50KB-1MB 1MB-10MB 10MB-100MB Java ME Java SE Java Card
  • 19. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.17 Java ME Embedded 3.3 §  Connected Limited Device Configuration 1.1 –  Reduced footprint JVM and core libraries §  Device Access API (new) –  Standard library for access to §  GPIO §  UART §  I2C/SPI §  Additional profiles used as required Key Features
  • 20. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.18 Java SE 8 Embedded (Early Access) §  Tuned for Raspberry Pi –  ARM6 architecture does not require hardware FP –  Raspberry Pi has one, so JVM needs specific compiler options §  Inlcudes JavaFX §  Includes compact profiles for reduced footprint §  Recently added to standard build platforms –  EA updated as each new build comes out Key Features
  • 21. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.19 JavaFX On Embedded Devices §  JavaFX on embedded does not support the full feature set –  No WebView component (not a problem for the carputer) –  No direct media playback support §  For video there is a work around (but, does the carputer need it?) §  Sound would be nice, but not essential §  Remember resource constraints –  Big scene graphs need memory and CPU cycles –  Keep number of nodes small (ideally <50) Things To Consider
  • 22. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.20 Building a Java Powered “Carputer”
  • 23. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.21 Carputer Design Objectives §  Display realtime data –  Engine performance (Power, Torque, Load) –  Driver data (Throttle position, steering angle, braking force, etc) –  G-Forces on car §  Record data for later analysis –  Produce graphs to display changes over time –  Play at Formula 1 –  Improve driving style (!)
  • 24. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.22 ELM327 §  WiFi or Bluetooth connection to OBD-II §  Fixed IP address, Ad-hoc networking §  Need to configure Raspberry Pi –  /etc/network/interfaces §  AT style commands for control §  Non-AT commands are assumed to be OBD-II –  Simple request-response interaction –  Easy to write Java code to handle this Cheap way to hack your car
  • 25. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.23 Touchscreen §  2 DIN fitting size –  Ideal for centre console §  HDMI input –  Specifically marketed for Raspberry Pi §  USB connection for touch screen Lots of things available on eBay
  • 26. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.24 JavaFX And Touchscreen §  Raspian Linux recognises device: eGalax Inc §  Creates two devices in /dev/input/event0, event1 §  JavaFX sees devices and uses event0 –  No events generated –  Need to use event1 (No idea why) §  Special build of JavaFX? §  Neccesity is the mother of invention –  Delete event0 and mknod event0 c 13 65 (same as event1) –  Need script to repeat at boot time Not completely straightforward
  • 27. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.25 Carputer Hardware Architecture USB WiFi Dongle Touch Screen Accelerometer HDMI USB I2C 12V Car Converter ELM327 Car Service Port 5V USB
  • 28. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.26 Touchscreen Hardware Fitting Challenges
  • 29. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.27 Accelerometer §  Sparkfun breakout board MPU 9150 –  9 DoF sensor (accelerometer, gyroscope, compass) §  Communications via I2C –  Configure Raspberry Pi /etc/modules §  i2c-bcm2708, i2c-dev §  i2c-detect -y 1 to get address –  Compass communication is a bit more complicated §  Second I2C bus
  • 30. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.28 Accelerometer Code Using Pi4J Library on Java SE Embedded I2CBus bus = I2CFactory.getInstance(I2CBus.BUS_1); I2CDevice device = bus.getDevice(0x68); /* Start sensing */ device.write(0x6B, (byte)0b00000000); device.write(0x6C, (byte)0b00000000); /* Set configuration */ device.write(0x1B, (byte)0b00011000); // Gyroscope device.write(0x1C, (byte)0b00000100); // Accelerometer device.read(0x3B, accelData, 0, ACCEL_PACKET_SIZE);
  • 31. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.29 Compensating For Gravity In Acceleration §  The accelerometer measures acceleration (obviously) §  Gravity is a constant acceleration –  Consider it static acceleration §  What we want is dynamic acceleration §  Zero out gravitational effect –  Assume no rotation of the sensor –  Nearly correct, car will roll in corners and pitch under braking/acceleration –  Good enough for the demo –  Could integrate gyro and Kalman filter for higher accuracy The Earth Sucks
  • 32. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.30 Calculating Power And Torque §  Results will not have high accuracy –  Values in red are not precise §  Dynamometer is the only way to get accurate figures §  Interesting to see values v. manufacturers figures Torque (Nm) = Mass x Wheel Radius x Acceleration (in G) Torque (lb/ft) = Torque in Nm x 0.73756 Power (BHP) = Torque (lb/ft) x engine RPM / 5252
  • 33. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.31 Carputer Software Architecture §  Screens based –  Splash screen –  Basic and advanced car data –  G forces on car –  Graphed results of different parameters §  Simple UI –  Can’t read numbers when driving §  Touchscreen to switch screens –  Repurpose existing car controls to change screen? Realtime Data
  • 34. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.32 UI Design Ideas Take Inspiration From Others Renault Megane Sport
  • 35. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.33 UI Design Ideas Take Inspiration From Others Tesla
  • 36. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.34 UI Design Ideas Take Inspiration From Others Lamborghini Reveton
  • 37. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.35 Simple Data Display Control §  Only uses 3 nodes –  Polygon –  Rectangle –  Line –  Labels are optional §  Displays –  Current value –  Maximum value since start (resetable) §  Simple to understand from a glance
  • 38. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.36 User Interaction §  Complex UIs are bad for driver distraction –  Programming the SatNav while driving §  Make Carputer interaction as simple as possible §  Sequence of screens –  Main menu? Too complex, too much reading –  Cycle through screens (Keep number small) –  Just touch screen to change to next display §  Use setMouseTransparent(true); –  Use steering wheel button
  • 39. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.37 UI Screens Splash Screen
  • 40. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.38 UI Screens
  • 41. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.39 UI Screens
  • 42. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.40 UI Screens
  • 43. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.41 Graph Plots Of Throttle Position And Power
  • 44. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.42 Using Car Control Buttons §  Not simple –  Car manufacturers don’t share the CAN bus IDs and message formats –  Even things like Audi forums can’t supply this –  Need to reverse engineer §  ELM327 has AT MA command –  Monitor all CAN Bus traffic –  Need to pick the relevant message from a LOT of data –  Once the ID is know use AT MT xx to monitor transmit messages Monitoring CAN Bus Data
  • 45. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.43 Future Ideas, Conclusions and Resources
  • 46. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.44 What Next §  Integrate heart rate monitor to add biometric data §  Heads Up Display (HUD) –  Microprojector and half-silvered perspex §  Further investigation of CAN Bus signals –  Brake pressure, steering position –  Use other switches –  Send commands (this is rather scary)
  • 47. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.45 Adafruit Ultimate GPS Breakout P1-01 TX RX NOTE: RX TX TX RX
  • 48. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.46 The Pi Can Interface §  Can’t read CAN bus and OBDII at the same time via ELM327 §  Use connector for entertainment system §  Need to check that I2C for accelerometer will still work §  Reasonable cost, $50
  • 49. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.47 Resources §  www.audi.com §  www.raspberrypi.org §  javafx.oracle.com §  blogs.oracle.com/speakjava
  • 50. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.48 Demos
  • 51. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.49
  • 52. Watch the video with slide synchronization on InfoQ.com! http://www.infoq.com/presentations/raspberry- pi-java-car