GoPiGo3 can't access Distance Sensor

distancesensor
gopigo3

#1

Am trying to get the distance sensor operational.

Running a simple program (easy.init_distance_sensor() ) yields:

Distance Sensor NOT found
class DistanceSensor has no attribute '__init__'
Traceback (most recent call last):
  File "./DistSensor.py", line 6, in <module>
    distSensor = botty.init_distance_sensor()
  File "build/bdist.linux-armv7l/egg/easygopigo3.py", line 801, in init_distance_sensor
    return DistanceSensor(port, self)
  File "build/bdist.linux-armv7l/egg/easygopigo3.py", line 2290, in __init__
    raise IOError("Distance Sensor not found")
IOError: Distance Sensor not found

My first thought is the device isn't present on the i2c bus. i2cdetect gives me:
i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- 08 -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- 29 -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --

I’m not 100% sure how to interpret this. There appear to be a couple devices; one at address 0x08, the other at 0x29. An i2cdump of each shows all zeros for 08, and some non-zero data for 29. But I’m not sure what devices I’m really looking at.

Any other things I can try to narrow down what might be the root cause? That is, before I pull out multimeters & scopes to figure it out …


#2

Hello @ottodelupe,
sorry you’re running into trouble, we’ve changed a few things on our side and my guess is that you’re not fully up to date.
Which OS are you using? DexterOS, Raspbian for Robots, or plain vanilla Raspbian? Could you let us know, it will help in figuring out what went wrong.
Thanks,
Cleo


#3

Raspian for Robots. I downloaded this from the Dexter site a few weeks ago (am at work right now, so can’t give you the result of uname -a).

I did a git pull from the gopigo3 repo in github earlier this week; and ran the upgrade script. So, this updated /home/pi/Dexter/GoPiGo3 to latest (as of Wednesday).

From reading the datasheet for the sensor, it appears that the sensor is at i2c address 0x52. Yet that’s not showing up in the i2cdetect output. So, I’m wondering if I have the pins all aligned properly between the dexter board and the pi board. Or it’s something else entirely.


#4

Hi @ottodelupe,

First of all the default address of the Distance Sensor is 0x29 and not 0x52.
Second, it seems like you do have the package containing the drivers for the Distance Sensor installed, so everything should be a go.

Could you show us a picture of your setup?

Thank you!


#5

https://photos.app.goo.gl/46YHIIW5OX5eTl4Y2 has a few pictures of the unit.

I’m glad to hear that 0x29 is the address - so at least linux is seeing it as an i2c device.


#6

Here is another data point. I cloned https://github.com/johnbryanmoore/VL53L0X_rasp_python.git and built it on the pi.

Was able to compile & run this, and it seems to be working fine. See output below. The variation in the range is me moving my hand back&forth in front of the sensor.

So, it appears there’s something wonky with my installation of the GoPiGo3 firmware/libs. What can I do to help narrow this down?

pi@dex:~/workspaces/VL53L0X_rasp_python/python $ ./VL53L0X_example.py 
VL53L0X Start Ranging Object 0 Address 0x29

VL53L0X_GetDeviceInfo:
Device Name : VL53L0X ES1 or later
Device Type : VL53L0X
Device ID : VL53L0CXV0DH/1$1
ProductRevisionMajor : 1
ProductRevisionMinor : 1
VL53L0X_BETTER_ACCURACY_MODE
API Status: 0 : No Error
Timing 66 ms
255 mm, 25 cm, 1
252 mm, 25 cm, 2
255 mm, 25 cm, 3
249 mm, 24 cm, 4
252 mm, 25 cm, 5
258 mm, 25 cm, 6
254 mm, 25 cm, 7
256 mm, 25 cm, 8
252 mm, 25 cm, 9
252 mm, 25 cm, 10
255 mm, 25 cm, 11
253 mm, 25 cm, 12
257 mm, 25 cm, 13
253 mm, 25 cm, 14
252 mm, 25 cm, 15
182 mm, 18 cm, 16
128 mm, 12 cm, 17
124 mm, 12 cm, 18
131 mm, 13 cm, 19
129 mm, 12 cm, 20
127 mm, 12 cm, 21
121 mm, 12 cm, 22
117 mm, 11 cm, 23
118 mm, 11 cm, 24
110 mm, 11 cm, 25
101 mm, 10 cm, 26
79 mm, 7 cm, 27
72 mm, 7 cm, 28
63 mm, 6 cm, 29
55 mm, 5 cm, 30
53 mm, 5 cm, 31
51 mm, 5 cm, 32
49 mm, 4 cm, 33
57 mm, 5 cm, 34
68 mm, 6 cm, 35
77 mm, 7 cm, 36
94 mm, 9 cm, 37
114 mm, 11 cm, 38
133 mm, 13 cm, 39
144 mm, 14 cm, 40
157 mm, 15 cm, 41
194 mm, 19 cm, 42
209 mm, 20 cm, 43
218 mm, 21 cm, 44
223 mm, 22 cm, 45
230 mm, 23 cm, 46
236 mm, 23 cm, 47
241 mm, 24 cm, 48
239 mm, 23 cm, 49
233 mm, 23 cm, 50
224 mm, 22 cm, 51
211 mm, 21 cm, 52
191 mm, 19 cm, 53
176 mm, 17 cm, 54
163 mm, 16 cm, 55
152 mm, 15 cm, 56
130 mm, 13 cm, 57
113 mm, 11 cm, 58
100 mm, 10 cm, 59
86 mm, 8 cm, 60
79 mm, 7 cm, 61
76 mm, 7 cm, 62
76 mm, 7 cm, 63
74 mm, 7 cm, 64
75 mm, 7 cm, 65
74 mm, 7 cm, 66
72 mm, 7 cm, 67
73 mm, 7 cm, 68
75 mm, 7 cm, 69
75 mm, 7 cm, 70
70 mm, 7 cm, 71
76 mm, 7 cm, 72
91 mm, 9 cm, 73
106 mm, 10 cm, 74
120 mm, 12 cm, 75
132 mm, 13 cm, 76
142 mm, 14 cm, 77
155 mm, 15 cm, 78
180 mm, 18 cm, 79
191 mm, 19 cm, 80
202 mm, 20 cm, 81
211 mm, 21 cm, 82
214 mm, 21 cm, 83
219 mm, 21 cm, 84
230 mm, 23 cm, 85
228 mm, 22 cm, 86
225 mm, 22 cm, 87
227 mm, 22 cm, 88
246 mm, 24 cm, 89
257 mm, 25 cm, 90
249 mm, 24 cm, 91
254 mm, 25 cm, 92
256 mm, 25 cm, 93
253 mm, 25 cm, 94
252 mm, 25 cm, 95
254 mm, 25 cm, 96
250 mm, 25 cm, 97
257 mm, 25 cm, 98
^CTraceback (most recent call last):
  File "./VL53L0X_example.py", line 44, in <module>
    time.sleep(timing/1000000.00)

#7

Hi @ottodelupe,

Can you try running the following command:

  • sudo curl https://raw.githubusercontent.com/DexterInd/Raspbian_For_Robots/master/upd_script/fetch_sensors.sh | bash

And then try calling EasyGoPiGo3.init_distance_sensor method again?
This line command is used for updating all the drivers for our Dexter Industries Sensors, including the Distance Sensor.

Let’s see where this thing takes us.

Thank you!


#8

Correct me if I’m wrong, but the curl command isn’t going to execute the fetch_sensors.sh script, is it?

I have to pull it down (via curl) and save locally; then run it. Right? And if so, where should I put it? /home/pi seems the obvious place, but when I do that:

sudo ./fetch_sensors.sh
./fetch_sensors.sh: 8: ./fetch_sensors.sh: source: not found
./fetch_sensors.sh: 14: ./fetch_sensors.sh: folder_exists: not found
fatal: destination path ‘DI_Sensors’ already exists and is not an empty directory.
python: can’t open file ‘/home/pi/Dexter/DI_Sensors/Python/setup.py’: [Errno 2] No such file or directory
python3: can’t open file ‘/home/pi/Dexter/DI_Sensors/Python/setup.py’: [Errno 2] No such file or directory
python: can’t open file ‘/home/pi/Dexter/DI_Sensors/Python/di_sensors/DHT_Sensor/setup.py’: [Errno 2] No such file or directory
python3: can’t open file ‘/home/pi/Dexter/DI_Sensors/Python/di_sensors/DHT_Sensor/setup.py’: [Errno 2] No such file or directory

Here’s a tree of the Dexter folder on the pi.
DexterTree.txt (191.4 KB)


#9

Hi @ottodelupe,

I’m sorry for this mistake.
The command was incomplete.

I’ve edited the post and now, the fetched file should be executed.

Thank you!


#10

Got a couple of these:
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.4m -c source/_Raspberry_Pi_2_Driver.c -o build/temp.linux-armv7l-3.4/source/_Raspberry_Pi_2_Driver.o -std=gnu99
arm-linux-gnueabihf-gcc: error: source/_Raspberry_Pi_2_Driver.c: No such file or directory
arm-linux-gnueabihf-gcc: fatal error: no input files
compilation terminated.
error: command ‘arm-linux-gnueabihf-gcc’ failed with exit status 4


#11

Hi Folks, just a heads up I have the same error and I am using Raspbian for Robots.

Appreciate any help.

pi@dex:~/Dexter/GoPiGo3/Software/Python/Examples $ python run2.py 
Distance Sensor NOT found
class DistanceSensor has no attribute '__init__'
Traceback (most recent call last):
  File "run2.py", line 28, in <module>
    distance_sensor = gp.init_distance_sensor()
  File "build/bdist.linux-armv7l/egg/easygopigo3.py", line 801, in init_distance_sensor
    """
  File "build/bdist.linux-armv7l/egg/easygopigo3.py", line 2290, in __init__
    print(e)
IOError: Distance Sensor not found

It was working before i upgraded to latest.


#12

@vms,
we’re working on this. Going with ReadTheDocs for the documentation brought in an unexpected challenge that we’re working hard to fix.
When was the last time you updated? I’m asking because we have been changing a few things in these last couple of days. I just want to know which files you have.
Thanks a lot.


#13

@cleoqc, Good to know. I updated last night.


#14

My apologies @vms for not coming back to you.

did you ever get past this issue? It should be working now. (has been for a little while)

Cleo


#15

@cleoqc Sorry got side tracked by other stuff. After updating the software the distance sensor is working.

Appreciate your help.


#16

Thank you for letting us know and happy sensing :heart:


#17

This topic was automatically closed after 28 hours. New replies are no longer allowed.