Line following - Gopigo behave weird

Hello

I’m trying a follow the line untill all is black with a basic black line and a “T” to be able to reach a point.
Calibration are done successfully, the line follower seems to work correctly (value are consistent).
But the GOPIGO doesn’t follow the line and spin randomly.

What is wrong in this case. Is there any troubleshooting guideline i can use ?

Hi @gopigoben,

Can you show us a video of your GoPiGo going out of control?

Thank you!

Also,
are you using Bloxter, Python?
Can you share your code?

Thank you
Cleo

Sure, please find the video. And i’m using a bloxter function, but please find the python code associated. I changed nothing, just calibrate white and black and then run a follow the line until all is black.

import easygopigo3 as easy
import time

sensor_readings = None

gpg = easy.EasyGoPiGo3()

try:
my_linefollower = gpg.init_line_follower()
time.sleep(0.1)
except:
print(‘Line Follower not responding’)
time.sleep(0.2)
exit()
my_linefollower.read_position()
my_linefollower.read_position()

start

gpg.forward()
while not my_linefollower.read_position() == “black”:
if my_linefollower.read_position() == ‘center’:
gpg.forward()
if my_linefollower.read_position() == ‘left’:
gpg.left()
if my_linefollower.read_position() == ‘right’:
gpg.right()
gpg.stop()

Sorry for the copy paste that didn’t respect the indentation python requirement.
Thanks to the fix 2.2.3 ( thanks again cleoqc ). I was able to run step by step the python code generated. And i have some weird output. Please find some example :

import easygopigo3 as easy
import time
sensor_readings = None
gpg = easy.EasyGoPiGo3()

my_linefollower = gpg.init_line_follower()

my_linefollower.read_position()
‘center’ # this one is correct, i was on the black line

my_linefollower.read_position()
‘center’ # this one is uncorrect i think, i spined a bit the gopigo to the left ( all the right captor was on black , left captor on white

my_linefollower.read_position()
‘left’ # this one is uncorrect i was totally on the white

my_linefollower.read_position()
‘white’ # incorrect, totally on the black

I did different try and all the results are odd.

Thanks for your insight

Update : I found the issue, the output of read_position is not aligned with the python code ( extract from the bloxter )
When position is ‘left’ it should go to right and vice versa. I swapped it on the code and it works well.

1 Like

Good debugging!

It’s kinda confusing what “left” and “right” mean. “left” could mean 1) the line is being read on the left, 2) the robot needs to go left.

Also internally, sensor 0 is on the right, so if you print the sensor values, you get them in reverse order.

So yeah, confusing…

Cleo