I always look forward to IBM Impact. Not for the Vegas lights or casino floors, but the opportunity to create some fun and interesting demos for Liberty and discuss them with a whole range of industry professionals.
After last year’s insightful discussions, and much iteration, I brought new and improved Liberty Cars (Version 2) and the all-new Liberty Arduino feature (Version 1).
The Liberty Cars at IBM Impact 2014
The Liberty Car was first unveiled at Impact 2013. It was a big hit as a showcase for responsive Liberty web applications running on a Raspberry Pi and also for the concept of “Zero Infrastructure” setups.
So what’s new in version 2?
I re-wrote a lot of the underlying code. There was only one Liberty Car before Impact 2014 so a lot of the configuration, tuning, and settings were hard-coded to work with that hardware platform. I also worked on making sure the software is configurable from the web UI to work with any car hardware without needing to dive into the code all the time. This re-write also improved battery life significantly over the previous version by changing the frequencies used in controlling the steering.
Beyond the under-the-cover software improvements, however, I’ve started to make the cars smarter by adding sensors to them. We now have a light sensor and an LED under the front of the car. When the car crosses a light-coloured Finish line, it reflects the light from the LED into the light sensor. This lets the cars know when they are completing laps so they can time their own lap and race times.
We attached the sensors to the car, and connected them to the car’s code, using the Liberty Arduino feature, which I’ll explain a little later in this article.
The hardware for the cars themselves was improved and we now use a common chassis for all the cars so repairing damaged parts is easier. The new cars have better turning circles, better motors (that have a higher top speed and a lower minimum speed), and four-wheel drive so they are easier to control.
The final addition to the cars was a race coordinator. At Impact we had a racetrack where people could race the cars around. It would be complicated to have the cars keeping their own lap times to themselves, as well as to have to coordinate who was driving which car and for how long, so we created a race coordination application to automate the whole track for us.
Running on a quad-core ARM desktop computer we had an additional Liberty server which allowed me to:
- See the status of all the cars on the track (Is the battery flat? Is someone in control? etc)
* Have a centralised leaderboard of lap times for everyone racing
* Have a single web page where users go to the register to race a car. When a car is available they are given control and forwarded to the control page to drive the cars. When their turn is over control is removed from them and they are forwarded onto the leaderboard to see their times.
This automated application worked with the individual Liberty Cars on the track to give a seamless, automated setup for the cars. It demonstrated that you can have groups of Liberty servers working together on low power ARM devices quite easily.
The Liberty Arduino feature
It’s basically a new user feature, which you can add to your Liberty runtime. It allows you to directly interact with Arduino microcontrollers from your Java EE application code. You use Arduinos to connect to any sensors and output devices and it can read and write vales from the IO on those devices.
We had a couple of demos at Impact that included a JSP that could read the temperature from a temperature sensor, send messages to a Bluetooth-powered screen and turn a radio-controlled plug on and off. All of this was achieved with a couple of lines of code per sensor (it takes 2 lines of Java to read the temperature from the temperature sensor) and adds Internet of Things capability to the Liberty runtime.
A single Liberty server running on something as low-powered as a Raspberry Pi computer can be communicating with a whole collection of Arduinos and their sensors to collect sensor data or to control a whole host of different devices or outputs.
We’ll be expanding on the possibilities this enables in a future article (I’ll now go poke Anthony Elder, the creator of this functionality, to finish it off!).
Meanwhile, if you want to build your own Liberty Car, see Build the Liberty Car (Part 1): The hardware, part 1 of a 3-part series on how to build the Liberty Car. Parts 2 and 3 are coming soon.