By Guest Blogger Timothy Beneke
Oracle’s Java Technology Ambassador Stephen Chin presented the “Internet of Things Magic Show” session before a packed crowd on Wednesday morning at JavaOne. The session made it clear—as has much of JavaOne 2014—that with a little ingenuity, persistence, and a Raspberry Pi, Java developers can easily deploy their skills to create IoT magic shows of their own. Chin emphasized the strength of Java for the IoT space, especially now that the divide between Java SE and Java ME has been dramatically narrowed with Java 8. “Java ME as a language is almost the same as Java SE minus lambdas,” observed Chin, “and a prototype of lambdas for Java ME is well on its way. Also, a lot of Java SE APIs are finding their way to Java ME as well.”
Fun with Mr. Grabby
He presented a small smart robot, named Mr. Grabby, that resembles a crab with grippers that can be made to remotely grab and carry a white glowing ball. The robot can then navigate its way around tracks laid down in the form of white tape on the floor.
Mr. Grabby is an autonomous robot using Raspberry Pi and other hardware on top as a controller, plus an Arduino board that uses pin mapping and a motor controller. “Programming the pin assignments right is the biggest issue,” said Chin. “You use software serial on Arduino, where you take any two soft pins and do the serial protocol manually. It uses line follower software, which captures infrared light off the ground through two lights and two sensors; there is an infrared emitting light and another sensor that picks up the infrared. When Mr. Grabby goes off the track, he knows to compensate and follow the lines.”
Chin invited a developer named Mark onstage who successfully took Mr. Grabby around the tracks in a time of 40 seconds. All Mr. Grabby code is available on github.
3-D Printing Magic
Chin then displayed a 3-D printer, which was now busy making a customized bracelet for Mark. The printer has a Raspberry Pi and uses OctoPrint to monitor it remotely. He showed a console that displayed the temperature of the plate and the extruder plus a live video of the bracelet being made.
Software for the printer—known as open constructed geometry software—was designed by Michael Hofer entirely in Java. Hofer leveraged the JavaFX 8 APIs, which now include 3-D support, and built a visual tool for visualizing how 3-D products will look. The code controls space between links, the radius of the sphere, and other pertinent details.
“Printing is done by taking complex shapes and adding and deleting objects from them, so you can delete a bunch of filters from a larger filter to create a space,” explained Chin. Chin illustrated ways that the bracelet could be made bigger and smaller as needed.
He closed by showing a timelapse video of the printer constructing the bracelet.