I recently bought a GoPiGo3, and I have been trying to program my GoPiGo so that it can autonomously move without colliding with any obstacles.
I installed the GoPiGo3 libraries on my micro SD card since I did not buy my micro SD card from Dexter Industries - I have the Raspbian Jessie operating system on my Raspberry Pi 3B. I am able to use basic commands to control my GoPiGo3 like forward() and backward() after importing * from easygopigo3 and declaring an EasyGoPiGo3 object, but I have been having trouble with the distance sensor.
When I try to run my collision avoidance program, the line
distance_sensor = robot.init_distance_sensor()
causes
[Errno 2] No such file or directory
Traceback (most recent call last):
File “distance.py”, line 7, in
distance_sensor = robot.init_distance_sensor()
File “build/bdist.linux-armv7l/egg/easygopigo3.py”, line 811, in init_distance_sensor
File “build/bdist.linux-armv7l/egg/easygopigo3.py”, line 2428, in init
IOError: Distance Sensor not found
Also, when I try to run the easy_Distance_Sensor.py example in the /Dexter/GoPiGo3/Software/Python/Examples directory, I get
Traceback (most recent call last):
File “easy_Distance_Sensor.py”, line 36, in
my_distance_sensor = DistanceSensor(easy) # Distance_Sensor will be the Line Follower object.
NameError: name ‘DistanceSensor’ is not defined
I am new to the GoPiGo3, so any help would be much appreciated.
Hello @typhoonrg and welcome to GoPiGo3!
As you installed the libraries on your own Raspbian, you are simply missing these files too:
We just reorganised this part of our software and it’s entirely possible that our instructions don’t reflect the changes yet. I apologize for the lack of relevant instructions regarding the distance sensor.
Thanks for the quick reply! I actually got those files as well earlier today. I went ahead and reinstalled it, and I am still getting the same errors.
In addition, when I try to run the DistanceSensorContinuous.py example from ~/Dexter/DI_Sensors/Python/Examples, I get
Example program for reading a Dexter Industries Distance Sensor on an I2C port.
Traceback (most recent call last):
File “DistanceSensorContinuous.py”, line 19, in
ds = distance_sensor.DistanceSensor()
File “build/bdist.linux-armv7l/egg/di_sensors/distance_sensor.py”, line 24, in init
File “build/bdist.linux-armv7l/egg/di_sensors/VL53L0X.py”, line 116, in init
File “build/bdist.linux-armv7l/egg/di_sensors/dexter_i2c.py”, line 35, in init
IOError: [Errno 2] No such file or directory
Before we go any further, can you confirm that this is the distance sensor that you’re using ? And on which port are you connecting it?
Also, from your last post, it indicates that the distance sensor library is not installed. Did you get the files by using the following command: curl --silent https://raw.githubusercontent.com/DexterInd/Raspbian_For_Robots/master/upd_script/fetch_sensors.sh | bash
Yup, that is the distance sensor I am using. I am connecting the distance sensor to one of the two I2C ports. And yes, I used that command to get the files.
Hmm. It should have worked but obviously there’s a case we’re not catching.
Can you run the install manually? cd ~/Dexter/DI_Sensors/Python sudo rm -r build/ sudo python setup.py install
Oh, it looks like I forgot to enable I2C under interfacing options!
The example under DI_Sensors seems to be working now. I’ll let you know if the distance sensor is not working in my other programs, but I think that fixed it!
Thank you so much for your help! I really appreciate it.
Yeah!
Our scripts should have done it for you so I’ll make a note that I2C is not automatically enabled. Sorry we gave you so much trouble but it looks like you’re on your way to success now
ah, now we’re getting somewhere Also, let me apologize. I missed that you were using your own SD card, even though you said it right away in the first post. That should have been my first clue.
You need to install DI_Sensors (which our scripts should do in theory but I don’t think it does right now - thanks for the reminder)