I’m getting inconsistent distance readings on my GoPiGo3’s distance sensor. At distances greater than 3m it will seemingly randomly report substantially smaller distances. I checked with a tape measure and there’s nothing nearby at those distances, and there seems to be no pattern to it in frequency.
It happens in all the scripts I write, but as an example here’s a script I wrote to test this:
import time
import easygopigo3 as easy
robot = easy.EasyGoPiGo3()
ds = robot.init_distance_sensor()
index = int(input("Enter # of loops: "))
pause = float(input("Enter pause time: "))
for i in range(index):
print(i,".",ds.read())
time.sleep(pause)
Here’s an example of the kinds of results I get (this one isn’t printing index the loop is at):
Is it possible for a dust mote to affect the readings? I’m running out of ideas. Any help would be suuuuuuper appreciated!
So I grabbed a tape measure and looked into accuracy at different distances, and it basically lines up with what you say.
Approx 1500mm
Readings consistently accurate
Approx 2100mm
Readings accurate 98.8% of the time. (just a single 8190mm reading, no big deal)
Approx 2500mm
100% incorrect, as you said. Either 8190mm or 0mm.
Overall
This explains why my script would have it stop seemingly at random with nothing nearby. I had originally had it driving and stopping at distances of 40cm, so those random zeroes when it was >2.3m from the wall caused it stop. This is easy to get around in my script.
Everything seems to be working as you have said. Thank you very much for your time and help, I really appreciate it! Would recommend you guys to my friends.