Hello @junwan2000,
You have a GoPiGo3 which is fundamentally different from a GoPiGo2 in its hardware architecture. You cannot run any of the examples under the GoPiGo folder. You have to look under the GoPiGo3 folder.
I think you have an older version of the GoPiGo3 installed.
In your terminal, type the following command: sudo curl https://raw.githubusercontent.com/DexterInd/Raspbian_For_Robots/master/upd_script/fetch_gopigo3.sh | bash
This will update your GoPiGo3 repository to the latest version.
By the way, after updating the GoPiGo3 repository, you might also want to update the firmware of the GoPiGo3 through the DI Update app that’s found on the Desktop.
After running the update, please run the example @cleoqc showed you and you should see your script working.
Updated my GoPiGo3 repository to the latest version
Updated the firmware of the GoPiGo3 through the DI Update app
My code is as:
import time
import easygopigo3 as easy
gpg = easy.EasyGoPiGo3()
my_distance_sensor = gpg.init_distance_sensor()
while True:
# Directly print the values of the sensor.
print("Distance Sensor Reading (mm): " + str(my_distance_sensor.read_mm()))
The new error is:
Distance Sensor init: [Errno 121] Remote I/O error
Traceback (most recent call last):
File "/home/pi/Dexter/GoPiGo3/Software/Python/Examples/Distance_sensor_wj/distance_sensor_wj1.py", line 6, in <module>
my_distance_sensor = gpg.init_distance_sensor()
File "build/bdist.linux-armv7l/egg/easygopigo3.py", line 839, in init_distance_sensor
return DistanceSensor(port, self)
File "build/bdist.linux-armv7l/egg/easygopigo3.py", line 2615, in __init__
distance_sensor.DistanceSensor.__init__(self)
File "build/bdist.linux-armv7l/egg/di_sensors/distance_sensor.py", line 24, in __init__
self.VL53L0X = VL53L0X.VL53L0X(bus = bus)
File "build/bdist.linux-armv7l/egg/di_sensors/VL53L0X.py", line 121, in __init__
self.reset(self.ADDRESS)
File "build/bdist.linux-armv7l/egg/di_sensors/VL53L0X.py", line 142, in reset
value = self.i2c_bus.read_reg_8u(IDENTIFICATION_MODEL_ID)
File "build/bdist.linux-armv7l/egg/di_sensors/dexter_i2c.py", line 196, in read_reg_8u
val = self.transfer([reg], 1)
File "build/bdist.linux-armv7l/egg/di_sensors/dexter_i2c.py", line 106, in transfer
return self.i2c_bus.read_i2c_block_data(self.address, outArr[0], inBytes)
IOError: [Errno 121] Remote I/O error