GrovePi Line Finder Java 8


We have a project where we use the grovepi module with line_finder sensors to follow a line that will be drawn in black.
(ref:Grove - Line Finder - Seeed Wiki)

However, we had multiple problems with the operation of these sensors. We code the project in JAVA and we have already seen the different examples proposed.
Here is the main :

public class MyMain {
	public static void main(String[] args) throws IOException, UnsupportedBusNumberException, InterruptedException {
		GrovePi grovePi = new GrovePi4J();
		while (true) {

Our problem is that when we run the program in the raspberry console, it always returns the same value: true.
We think this is due to a threshold problem and after extensive research, no result.
We also noticed that there is no line finder class in Java but it exists in Python

Do you know where this problem comes from? Thanks in advance !
(We are french so we can answer in both french and english)

1 Like

Did you calibrate the sensors first? There should be a process where you calibrate both the white-point and black-point prior to using the sensor.

On my GoPiGo robot, prior to calibrating the (new, black), line follower sensor, the readings are (at best) undefined. Once the white-point and black-point are set, it behaves much better.

Also, I didn’t know there were Java libraries for the Grove. Did you “cast” them as being Python libraries when you imported them? I’m curious.

I would run this through Google Translate as a courtesy to you, but Google Translate has a lot of difficulty with proper nouns - at least in Russian!

Instead of preserving things like “Java”, “Grove” and “GoPiGo” as written, as text literals, it attempts to render them as the Russian translation - and the results are often humorous. “I program in [a cup of coffee] programming language on my [group of trees] robot using [big jungle snake] libraries.” :wink: