Top Banner
RASPBERRY PI CAR BOGDAN CRACIUN SIVECO ROMANIA Build, Code, Deploy and Run
29

Raspberry Pi Car with Java

May 13, 2015

Download

Technology

Bogdan Craciun

jQuery Mobile, Socket.io, Node.js, Redis, Java, Spring Integration, Arduino, RXTX, Pi4J
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Raspberry Pi Car with Java

RASPBERRY PI CAR

BOGDAN CRACIUNSIVECO ROMANIA

Build, Code, Deploy and Run

Page 2: Raspberry Pi Car with Java

Agenda

Introduction Requirements Hardware platform Software platform & Application code Q&A Running Mode Demo

Page 3: Raspberry Pi Car with Java

About me

Software Architect @ SIVECO Romania from 2003 Oracle Certified Master, Java EE Enterprise Architect Founding member of Oracle Architects Club – Romania

chapter

Page 4: Raspberry Pi Car with Java

Requirements

Wireless control - no wires Wi-Fi based

Smartphone and Car only setup No external Wi-Fi access point needed No additional administration system Automatic startup of services on power on

Queue base control Automatic impact detection and reaction Front lights control Status lights for Impact Mode and Commands

Page 7: Raspberry Pi Car with Java

Prop

Page 8: Raspberry Pi Car with Java

Victim

Page 9: Raspberry Pi Car with Java

Result

v1 v2

Page 12: Raspberry Pi Car with Java

Operating system setup

Operating system Rasbian “Wheezy” – Debian based Raspberry Pi

distribution Access point

Hostapd EW-7811Un with custom drivers to support AP mode

DNS & DHCP Dnsmasq

Remove serial console support from standard Raspbian distribution

Page 13: Raspberry Pi Car with Java

Service integration

Java Application Java Service Wrapper

Node Application Nodejitsu Forever

Linux native program Scripting

Page 14: Raspberry Pi Car with Java

JeeNode integration

Using serial communication RXTX Java library with native support

Page 15: Raspberry Pi Car with Java

Car engine

Java SE Application Spring Framework

IoC container Spring Integration

Redis Channel Adapter Custom Serial Channel

Adapter Using RXTX Serial library

Page 16: Raspberry Pi Car with Java

Control component - Client

Client JQuery Mobile

User interface and interactions

Socket.io Client <> Server

communication Virtualjoystick.js

Dual virtual joystick support

Page 17: Raspberry Pi Car with Java

Control component - Server

Server Node.js Server

Server components (request handlers and queue management)

Redis Server Node <> Java

integration using Redis Pub/Sub

Queue persistence using Redis sorted sets

Page 18: Raspberry Pi Car with Java

Image streaming

mjpg-streamer With Raspberry Pi Camera support – 11 fps @ 640x480

Page 19: Raspberry Pi Car with Java

Software challenges

No AP mode support in EW-7811Un

Action: Custom hostapd compatible RTL8188CUS was installed

Reading HC-SR04 sensor data using Java

Works fine if it is the only process on Raspberry Pi

Bad choice to use the sensor with a non real-time SO

Action: Added a Jeenode (Arduino Uno clone) to run the reading loop and push data to a serial Raspberry Pi port

Page 20: Raspberry Pi Car with Java

Software challenges – cont.

Compiling the following on Raspberry Pi:

redis server

node.js

RXTX native library

mjpg-streamer – custom module to support image streaming

Image streaming speed optimization

Page 21: Raspberry Pi Car with Java

Hardware challenges

Differences between Raspberry Pi and HC-SR04 Ultrasonic Sensor - 3.3v vs 5v Action: Used a basic voltage divider between

the Echo port and the GPIO pin of the Raspberry Pi

Reuse the dual H-bridge from the toy car PCB (Printed Circuit Board) or integrate the L298N board v1 reuse car PCB v2 is connected to motors using L298N board

Page 22: Raspberry Pi Car with Java

High level Architecture

Page 23: Raspberry Pi Car with Java

Detailed Diagram

Page 24: Raspberry Pi Car with Java

Detailed Diagram

Page 25: Raspberry Pi Car with Java

Lessons learned

Automate as much as possible Build automation Test automation

Use mocks for development and testing Development without the real car

Design a component based system for easy refactoring Switch between implementations easy

Prototype before develop It is harder to change something already developed and fully

integrated Switch log levels to error/fatal/off Use versioning and release management for code and hardware

designs Don’t use / break children toys !

Page 26: Raspberry Pi Car with Java

Final thoughts

Be a problem solver, not just a programmer.

Use the best tool for the job Does the language really matter? Keep your mind open.

Page 27: Raspberry Pi Car with Java

Testing Team

Page 28: Raspberry Pi Car with Java

Next projects

Raspberry Pi assisted quad-copter

Raspberry Pi controlled Tank

Page 29: Raspberry Pi Car with Java

Q&A

Demo car connection data: SID: orange Password: 12345678