Unable to initialize distance sensor, even thought I2C is enabled and sensor connected

Also … while I have you here :slight_smile:

When attempting to initialise the distance sensor (which is plugged in already in my I2C port:

this.distanceSensor = this.gpg.initDistanceSensor();

I am getting the below:

Dexter Industries GoPiGo3 0.3.4
Sensor init
Pin mode OUTPUT
Port Id -2
TypeError: Cannot read property 'setGroveType' of undefined
    at DistanceSensor.Sensor (/home/pi/roveros/node_modules/node-gopigo3/lib/components/sensor.js:56:29)
    at new DistanceSensor (/home/pi/roveros/node_modules/node-gopigo3/lib/components/distanceSensor.js:41:122)
    at EasyGoPiGo3.initDistanceSensor (/home/pi/roveros/node_modules/node-gopigo3/lib/easyGopigo3.js:415:20)
    at new Rover (/home/pi/roveros/libs/rover.js:16:44)
    at Object.<anonymous> (/home/pi/roveros/index.js:7:13)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
TypeError: Cannot read property 'device' of undefined
    at new DexterI2C (/home/pi/roveros/node_modules/di-sensors/lib/sensors/dexterI2c.js:23:27)
    at VL53L0X.Sensor (/home/pi/roveros/node_modules/di-sensors/lib/sensors/base/sensor.js:33:22)
    at new VL53L0X (/home/pi/roveros/node_modules/di-sensors/lib/sensors/VL53L0X.js:30:108)
    at new DistanceSensor (/home/pi/roveros/node_modules/di-sensors/lib/sensors/distanceSensor.js:22:23)
    at new DistanceSensor (/home/pi/roveros/node_modules/node-gopigo3/lib/components/distanceSensor.js:47:36)
    at EasyGoPiGo3.initDistanceSensor (/home/pi/roveros/node_modules/node-gopigo3/lib/easyGopigo3.js:415:20)
    at new Rover (/home/pi/roveros/libs/rover.js:16:44)
    at Object.<anonymous> (/home/pi/roveros/index.js:7:13)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)

First, I’d upgrade the GoPiGo3’s firmware. You can do that by going to the Firmware directory inside the GoPiGo3 repo. Once you do that, check if the script works.

Also, it might be worth checking if you have the latest commit of the GoPiGo3’s repository. A curl -kL dexterindustries.com/update_gopigo3 | bash should be good enough.

Since @marcello-barile is the one who has contributed the most to this NodeJS project, he might have ideas that are out of reach for me.

Thank you!

hi @sasa.savic, would be possible to have more information about your code? How do you instantiate the “gpg” variable for example? The more you give, the better.

Thanks

Hey gents,

Thanks for your quick response.

Regarding firmware, I’ve downgraded it from 1.0.0 to 3.6.0 (from memory), as NodeJS isn’t seem to be supported (or at least having some issues).

The above firmware, is it post 1.0.0 and would i have same issues (of not being able to instantiate gpg via NodeJS) as before?

As for how I initialise the distance sensor:

this.distanceSensor = this.gpg.initDistance(); … I’m using the EasyGopigo3 class.

My pan/tilt servos work fine, I just specify ‘SERVO02’ for the second servo.

Sash.

Hello @sasa.savic, I fear the upgrade won’t fix the issue you are facing so please do not proceed with it yet. Instead, there is a way to contact you in private? I would like to test something.

Thanks

Yep, pinged you on LinkedIn :slight_smile: