Raspberry Pi Car with Java

Post on 13-May-2015

3210 Views

Category:

Technology

6 Downloads

Preview:

Click to see full reader

DESCRIPTION

jQuery Mobile, Socket.io, Node.js, Redis, Java, Spring Integration, Arduino, RXTX, Pi4J

Transcript

RASPBERRY PI CAR

BOGDAN CRACIUNSIVECO ROMANIA

Build, Code, Deploy and Run

Agenda

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

About me

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

chapter

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

Prop

Victim

Result

v1 v2

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

Service integration

Java Application Java Service Wrapper

Node Application Nodejitsu Forever

Linux native program Scripting

JeeNode integration

Using serial communication RXTX Java library with native support

Car engine

Java SE Application Spring Framework

IoC container Spring Integration

Redis Channel Adapter Custom Serial Channel

Adapter Using RXTX Serial library

Control component - Client

Client JQuery Mobile

User interface and interactions

Socket.io Client <> Server

communication Virtualjoystick.js

Dual virtual joystick support

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

Image streaming

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

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

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

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

High level Architecture

Detailed Diagram

Detailed Diagram

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 !

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.

Testing Team

Next projects

Raspberry Pi assisted quad-copter

Raspberry Pi controlled Tank

Q&A

Demo car connection data: SID: orange Password: 12345678

top related