Distance sensor and IMU troubles

Help, please! I’m struggling to get readings from my new distance sensors and the IMU. Here’s what I’ve got so far: http://somup.com/cqQTqseGRV

Thanks,
Dan

Hi Dan - distance sensor user here, not DI.

There are two ways to set up to use the TOF distance sensor:

  1. follow the EasyDistanceSensor.py example in your code

add the import:

from di_sensors.easy_distance_sensor import EasyDistanceSensor

then instantiate the object:

my_sensor = EasyDistanceSensor()

then where you need a reading:

dist_in_cm = my_sensor.read()      # Example says mm but trust me it is cm.

if you want mm use:

dist_in_mm = my_sensor.read_mm()
  1. the other way is through an EasyGoPiGo3 object:

First import the bot:

import easygopigo3

then instantiate the bot:

egpg = easygopigo3.EasyGoPiGo3(use_mutex=True)

then instantiate the distance sensor object:

my_sensor = egpg.init_distance_sensor()   

then where you need a reading:

dist_in_cm = my_sensor.read()      # Example says mm but trust me it is cm.

if you want mm use:

dist_in_mm = my_sensor.read_mm()

An Important Note:

my_sensor = egpg.init_distance_sensor() with default port will use “Software I2C” which in the case of my robot would work for a while and then clog the i2c port requiring a reboot.

I use the sensor plugged only into either of the true I2C ports and instantiate with “Hardware I2C”:

my_sensor = egpg.init_distance_sensor('RPI_1')    # use HW I2C only!

Everything else is the same.

RE: IMU

There is sample that uses the IMU: /home/pi/Dexter/GoPiGo3/Projects/CompassRobot/

1 Like

Thanks, that’s a big help! I’ve got to spend some time with the IMU but with that help, I’ll get there.

It’s weird, 3 of 18 of my robots periodically crash when accessing the gyroscope. I get a stream of good readings, then move the motors, then a crash when their algorithm calls up the gyro once again. Our next class lesson will be about exception handling! Meanwhile, any idea what could be going wrong? The error reads “i2c” which throws me off a bit because only the distance sensor is the plugged into i2c and the IMU has been working in digital port two.
I ran updates on the three machines (OS, and dex softaware/firmware) but no effect.
error15

The students all fork from this project

My suspicion from your problem description is that you are hitting the same software I2C instability my bot had - (random non-recoverable I2C failure requiring a reboot).

As I mentioned prior - I suggest using bus = “RPI_1” (instead of GPG_AD1) and plugging the IMU and Distance Sensors into both “real” I2C ports.

self.distance_sensor = EasyDistanceSensor(port="RPI_1",use_mutex=True)
self.imu = inertial_measurement_unit.InertialMeasurementUnit(bus = "RPI_1")

You may find that importing easy_inertial_measurement_unit with port=“RPI_1”, use_mutex=True, is needed to have both the distance sensor and the IMU co-existing.

Here is my post about failures with SW I2C and none with HW I2C:

BTW, I’m not sure how much the DI folks are around here now that they merged with Modular and set up to use a different support structure:

If this doesn’t solve your problem, this is how to open a support request with Dexter Industries now:

Dexter Industries and Modular Robotics are merging

To serve the educational market even better, we’ve merged with Modular Robotics. We’re now moving customer support from this forum to Zendesk. You can open a request for support through this webpage:
https://www.dexterindustries.com/contact/
Or by emailing support@dexterindustries.com

See full post here:

@cyclicalobsessive,

So it looks like since the merger, DI is just going to let this Forum slowly die?

Regards,
TCIII

That seems to have done the trick. My class is banging on all cylinders again. Thanks!

1 Like

It does not look that way to me. A community forum is very valuable to users and to the products.

Yahoo just announced that the forum I started in 2001 for the Rug Warrior Robot will be closed at the end of this year. The forum didn’t die even when the product was no longer sold.

There is still a forum for a digital music mastering console I used to own, even though it went out of production ten years ago.

Every corporate merger causes customer facing media to require rebranding and reorganizing, which can take awhile for decisions to be made and contracts to be let. “…slowly die?” not likely.

Alan

@cyclicalobsessive

It has been my experience that the “open for now” usually indicates a future expiration date.

Regards,
TCIII