Sunday, January 15, 2017

Getting Started with robo4j-hw-rpi

This blog will provide a step-by-step instruction for how to quickly get started with the robo4j-hw-rpi module. We will use the Adafruit LCD as an example, but any of the supported hardware would be used in pretty much the same way. Also, if you wish support for certain 1 wire protocol sensors, like the Dallas DS18B20 temperature sensors, or the AM2302/DHT11/DHT22 temperature and humidity sensors, you can find a library for them in my private blog (for now).

Installing the Software

First of all the software required must be installed on the Raspberry Pi:
  1. Install PI4J.
    curl -s | sudo bash
  2. Set up the Raspberry for i2c communication.
  3. Install the Oracle JDK (if not already installed).
    sudo apt-get install oracle-java8-jdk
  4. Ensure that the Oracle JDK is the one in use (use java –version to verify).
    If not change so that it is. There can be a massive performance difference
  5. Clone the robo4j repo.
    git clone
  6. Run gradlew build in the robo4j root directory.
  7. Install Eclipse (optional, but good if you want to play around with the examples a bit).
    apt-get install eclipse

Setting up Eclipse (Optional)

For an easy way to play around with the examples, we can set up Eclipse on our Raspberry Pi.
  1. Install Egit.
    Inside of Eclipse, go to Help | Install New Software…
    Add a new update site with the following URL:
  2. Install the Gradle plug-in.
  3. Go to Robo4J on GitHub and clone the repo using Egit from within Eclipse.
  4. Import the projects into Eclipse.
Note that the Eclipse version currently installed by Raspbian will be a rather old version - Eclipse 3.8.0. This unfortunately means that it will not support JDK 8. This does not matter, as the robo4j-hw-rpi and robo4j-math projects only require Java SE 1.7.
Normally you would probably like to develop in a more modern version of Eclipse (or some other IDE) and just use the command line to build robo4j.

Running the Demos

There are two ways of running the demos. One through building the robo4j.jar file with Gradle, and one through Eclipse.
Here is how you would, for example, run the LCD demo using the robo4j.jar built by gradle:
sudo java –classpath robo4j-hw-rpi/build/libs/robo4j-hw-rpi-alpha-0.2.jar:/opt/pi4j/lib/* com.robo4j.hw.rpi.i2c.adafruitlcd.Demo
If you are playing around with the code in Eclipse, do the following:
  1. With Eclipse started, open a command line and change directory to the robo4j/robo4j-hw-rpi/bin folder.
  2. Search for the demo/example corresponding to the hardware set up you want to test in the examples folder in the eclipse project.
    For example, if you have an Adafruit LCD shield, you would use the com.robo4j.hw.rpi.i2c.adafruitlcd.Demo class.
  3. Run the demo from the command line.
    Do not forget to add the PI4J classes to the classpath, for example:
    sudo java –classpath .:/opt/pi4j/lib/* com.robo4j.hw.rpi.i2c.adafruitlcd.Demo
Running the LCD shield demo would show you something similar to this:

Have fun!

Robo4J Raspberry Pi Support

There are now two new modules in Robo4J:
  • robo4j-math
    Some basic math definitions and functions that may prove useful when building robots. This module will provide common data definitions like points and lines, and also provide feature extraction and other functionality that will prove useful when building robots. We’re currently moving Coff-E to Robo4J, which means this module will grow quite a bit during the upcoming months.
  • robo4j-hw-rpi
    Provides abstractions for commonly used off-the-shelf hardware. Does not have dependencies on any other module but math, and can be used as easy to consume, stand-alone, Java hardware abstractions.
Now, if you are getting started with the Raspberry Pi and hardware, the robo4j-hw-rpi provides a quick way get started. It provides examples that are ready to run for some of the most commonly used chips and protocols out there. Using robo4j-hw-rpi can be used as simple, stand alone, java abstractions for accessing your hardware. It does not require you to buy into the rest of the framework, though we hope that using robo4j fully would be the natural next step once we get further along with our implementation.

If your particular piece of hardware is missing, please let us know. Or why not join our effort and add a nice Java abstraction for your favorite piece of hardware to the library?

Saturday, January 14, 2017

Robo4J on GitHub

The Robo4J team has now created an organisation on GitHub

We will continuously publish all updates to the Robo4J core framework, and all the other related modules, to the repositories in this new location.

Over time we plan on publishing sample code, ranging from little snippets of sample code showing how to use a certain piece of hardware, all the way up to a working autonomous robotic vehicle.


Robo4J is entering the Year 2017!

  Robo4J Team wants to wish you all a beautiful start and happy New Year 2017. 
This year will be very important for the Robo4J framework. A lot of amazing things are already in the queue and waiting for the right time to be published. In such way we keep Java Robotics and IoT community full informed about the continual progress.

 The first Robo4J 2017 announcement is about the core development team. The team currently consists from two brilliant engineers with many years of experiences on the JVM field and pure Java Enthusiasts: 

Miro Wengner

twitter: @miragemiko

Marcus Hirt

twitter: @hirt

Happy New Year 2017! 

updated section ABOUT