BrickPi + Java in 2019 - is ev3dev my best bet?

I was very excited to get my brickpi running! So I installed Raspbian for Robots based off this chart with the hopes of then installing via the ev3dev-java installer script.

But that didn’t work at all. And now I’m bouncing over to ev3dev-stretch-rpi2-generic-2019-03-03.img. Am I missing out on cool things that Raspbian for Robots gives me? Can I install the RforR features on top of the ev3dev base layer? Are these two alternate and orthogonal systems, or am I misunderstanding the relationship?

1 Like

I’m seeing if I bought the right kit. I have a BrickPi3, and a Raspberry PI 3B+ - “the latest of everything.”

I’d like to code in Java. (Well, Kotlin, but if it runs Java it can run Kotlin)
I’ve been trying to get ev3dev installed, because it provides nice sysfs files for all the sensors and motors, and supports Java. However, I’m not sure this is the correct path - it won’t even boot.

What is the easiest way to for a rpi3b+ to

  1. run Java
  2. have some sort of easy access to standard EV3 Sensors and Motors
  3. enable what the rpi provides (like WiFi and bluetooth)

Is it the BrickPi3? (hopefully yes because I already own it!)
And if yes, which OS? Thanks!

1 Like

Not sure if you’re still wanting to do this a few months on, but for what it’s worth, I recently bought a used BrickPi+ and below is what I did to get it running on a RPi3B. You mention easy access to motors and sensors in Java; I’m a fan of LeJOS which provides that and more. Although I’m not sure if/how that works with Kotlin.

  1. Download ev3-stretch for RPi 2/3 from the downloads section on the ev3dev website (I would have linked to it but am restricted to including max two links per post as a new user here)- I ended up with version 2019-03-03

  2. Unzipped and burned image file to SD Card (i’m on Win10 and use Win32diskimager)

  3. Use a text editor on the PC to edit config.txt. In my case for the BrickPi+. The instructions are commented within to do the same for the BrickPi3

  4. Eject the SD card and insert in the Pi (with the BrickPi hardware already installed of course)

  5. Fire up the Pi with a fixed ethernet connection, SSH to it with Putty to confirm you now have a working Pi.

  6. Optional but recommended, use connmanctl to give it a fixed IP address, I use 192.168.1.222, (don’t forget to set a nameserver) I also turned off IPV6 because of some name resolution problems

  7. On my PC I then installed a fresh version of Eclipse for Java Developers Version: 2019-06 (4.12.0)

  8. Download the ev3dev-lang-java template project gradle - https://github.com/ev3dev-lang-java/template-project-gradle to the PC, unzip it

  9. Import the gradle project into Eclipse

  10. Edit config.gradle with the ip address of the Pi

  11. If you’re on a windows PC also make these changes https://github.com/ev3dev-lang-java/template-project-gradle/pull/34/files (For background, I logged an issue for this, no. 671 on the ev3dev-lang-java/ev3dev-lang-java GitHub page, again constrained to only two links sorry.)

  12. Now run some gradle tasks to test we can talk to the Pi, I did

testConnection
ev3devInfo

here is my output

Image file:         ev3dev-stretch-rpi2-generic-2019-03-03
Kernel version:     4.14.94-ev3dev-2.3.2-rpi2
Brickman:           0.10.0
BogoMIPS:           38.40
Bluetooth:          
Board:              board0
BOARD_INFO_HW_REV=A22082
BOARD_INFO_MODEL=Raspberry Pi 3 Model B Rev 1.2
BOARD_INFO_SERIAL_NUM=000000003f81bb99
BOARD_INFO_TYPE=main
Board:              board1
BOARD_INFO_FW_VER=2
BOARD_INFO_MODEL=Dexter Industries BrickPi
BOARD_INFO_TYPE=aux
  1. Now install Java etc. to the brick using gradle tasks, I ran
	getInstaller
	installJava	
	installJavaLibraries
	updateAPT
	uploadGradleLibraries (if you want to use LeJOS)
  1. Verified the install with gradle task javaVersion, output as follows:
openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment (build 11.0.4+11-post-Debian-1bpo91)
OpenJDK Server VM (build 11.0.4+11-post-Debian-1bpo91, mixed mode, sharing)

BrickPi should now be in a state to be programmed with Java and LeJOS

  1. Attach a large motor to port MA

  2. Overwrite mainclass parameter in config.gradle with

mainClass = "example.robotics.ev3.actuator.motor.BasicMotorOperationExample"

  1. Execute gradletask deployRun
    and that should get your motor running.
    Good luck and have fun.
2 Likes

I got it working with a BrickPi3 and a Rpi3B (not-plus) - and everything worked great! The not-plus was the problem, I had to downgrade my rpi by swapping with a friend.
No idea re: the rpi4.

2 Likes

Hi,
also when this thread is already some months old I hope someone is able to help me. Visual Studio Core is now supporting Java and there is also a VSCode ev3dev-Browser extension out there why I would like to use this as preferred environment. Unfortunately I am not able to get it running /compiling. I open a thread in stack overflow, so maybe someone wants to give it a try: https://stackoverflow.com/questions/63074646/vscode-with-ev3dev-and-java


Edit:
The error seems to be that VSCode tries to run the code locally. So I tried setting up Eclipse as floydieman described but I also did not get any far. Also when I search on the internet all the information I found are regarding lejos and a Eclipse addin for lejos which I assume dont want to use because I am using ed3dev-lang-java. Could anybody be so kind and give me a short tutorial how to get the class BumperCar from the example flying? I am using Windows 10 with openJDK and downloaded the example file as above described.
Thanks

1 Like

Hi again,
it seems I cannot edit my old post anymore so I just want to give a small update. At first I had to modify the gradlew.bat with the line:

set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

so that I could at least run commands like testConnection. Anyways, I am still not able to pass the example to the brickpi. The farthest I came so far is this output:

C:\Users\stephan\Desktop\template-project-gradle-master(1)\template-project-gradle-master>gradlew testConnection
ev3dev#1|ev3dev
ev3dev#1|ev3dev_java
ev3dev#1|installer
ev3dev#1|jri-ev3.tar.gz
ev3dev#1|test.py

> Task :testConnection
Host key checking is off. It may be vulnerable to man-in-the-middle attacks.
ls

BUILD SUCCESSFUL in 2s
1 actionable task: 1 executed
C:\Users\stephan\Desktop\template-project-gradle-master(1)\template-project-gradle-master>gradlew deployAndBrickRun

> Task :deploy
Host key checking is off. It may be vulnerable to man-in-the-middle attacks.
ev3dev#3|Error: Unable to access jarfile /home/robot/template_project_gradle-2.6.0-all.jar
ev3dev#3|
ev3dev#3|real   0m0.285s
ev3dev#3|user   0m0.045s
ev3dev#3|sys    0m0.001s

> Task :remoteBrickRun FAILED
Host key checking is off. It may be vulnerable to man-in-the-middle attacks.
time brickrun -- java -jar /home/robot/template_project_gradle-2.6.0-all.jar
Failed command ev3dev#3 with status 1: time brickrun -- java -jar /home/robot/template_project_gradle-2.6.0-all.jar

FAILURE: Build failed with an exception.

* Where:
Script 'C:\Users\stephan\Desktop\template-project-gradle-master(1)\template-project-gradle-master\gradle\deploy.gradle' line: 121

* What went wrong:
Execution failed for task ':remoteBrickRun'.
> Command returned exit status 1: time brickrun -- java -jar /home/robot/template_project_gradle-2.6.0-all.jar

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

I still missing some parts which I cannot get from the github site :frowning:

1 Like

@stephanh did you ever get your remote jar to run? I just started this process of running the java template project and working through my errors. I now have a similar issue to yours. I’m looking in the git history of the project to see what happened to the java installer scripts. Pretty sure for me this is the next issue for me. How did you get java installed on your pi?
@floydieman 's steps are the most complete I’ve found so far, but the template is not missing those gradle tasks:
getInstaller
installJava
installJavaLibraries

1 Like

I did end up finding exactly how to get java installed and how to remote deploy and run a project built on the java template. I’m in the process of forking the correct repos and updating the project just for BrickPi, so if anyone needs direction ping me.

2 Likes

You, all of you, have done a bang-up job of figuring out a gnarly problem!

You have my curiosity riz, so to speak, as I am doing something similar on a GoPiGo3 and Visual Studio Code, writing in Python.

My particular workflow is:

  • Visual Studio Code on Windoze-10 to handle writing and source control management using GitHub.
    • Note that the “master copy” of everything is kept in a project folder on my laptop and the repository I created for it on GitHub.
    • The copy on the 'bot itself is a “satellite” copy just in case the SD card goes to Hell in a Hand-basket, or cracks in half, or something else drastic.
  • Then using FileZilla to transfer the prospective files to my GoPiGo3. . .
  • Then using VNC to “remote” into the 'bot’s desktop. . .
  • And after all THAT, I use Thonny on the 'bot itself to actually run the code and see any results/errors generated.
     

Though it works, it’s a pain. Especially since it’s tempting to write “quick fixes” directly on the 'bot itself, and then I have to migrate them back to the master file store on my laptop; creating the possibility of un-synchronized files between the two platforms and the resulting confusion.

Noting that I do want the “master” copy of everything to exist somewhere else than on the 'bot itself, and that running Visual Studio Code on the 'bot itself is painful, (I’ve tried it and molasses running uphill, in the winter, in Siberia, is faster), I would like to smooth out the workflow as much as possible.

Any suggestions or ideas would be most gratefully appreciated.

Hi,
sorry for the late respond. Actually I got it working, and if I remember correctly I had to change the bat file for 64bit jdk. Anyways, I wanted to write a small docu for my self, but forgot it and had some other trouble. Anyways, I still can share my project with you if it helps. Just send me a PM.

1 Like

Thanks @stephanh. I did fork the ev3dev java lang project and added the necessary steps to run a Kotlin example using coroutines that drives two motors. I realized quickly after that the project doesn’t support NXT sensors though which I had initially taken for granted. A project maintainer asked me to post issues for getting the NXT sensors added which i have yet to do. The link to the git hub project is in my other post here: kotlin git hub

1 Like

Btw, I use Visual Studio Code + JavaCodingPack + Ev3Dev Extension, but I used the gradle from the project to build and compile the project.
Tonight I had some free time, and I was wondering if there is something like an event handler, or action listener which I can use for the EV3TouchSensor. So that every time it is used, it will call a function. I use this in come c# projects, but the class EV3TouchSensor itself does not contain any method for this. Do you just build while loops around it?

1 Like

@stephanh yes, you’ll have to poll it frequently to test the value. If you want event-like behavior you’ll need to roll your own. I don’t know the best way to do this in Java, in Kotlin you can easily do it in a coroutine and have your code subscribe to the event.

1 Like