I’m trying to find an example of the dIMU Sensor sensor on a GoPiGo to track its rotation as it drives around. I can’t see any in the Software/Python/Examples. I’m not even sure if it should be plugged in to Serial, I2C or AD. Thanks!
Hello adilettad! It’s been a while since we’ve worked with the dIMU, we’ve replaced it with a new sensor that detects overall motion.
However, to answer your question: it should be plugged into the I2C port. I don’t think we’ve ever linked the dIMU to the GoPiGo3 though.
Please let us know how it goes!
Hi @adilettad,
In that video of yours, you are using the DI IMU (the new one), not the dIMU which is an old sensor. Its documentation in Python can be found here:
https://di-sensors.readthedocs.io/en/master/
In response to your video, you generally do the whole signal processing stuff in a separate thread. That thread includes the acquisition of data from the sensor, the process of preprocessing the data, the fusion of multiple types of data (such as the accelerometer + gyro + magnetometer) with different kind of filters and then the process of queueing the data to a consumer. And also that thread has to run at a specific loop frequency determined by the programmer; generally the higher the loop frequency, the better the response of the system.
What’s really cool about this sensor is that it already runs in fusion mode on all of its 9 degrees of freedom on its chip so you can just poll the absolute position of the sensor (as measured in Euler angles or quaternion data) by using one single method:
Also, remember the output rate of the IMU is limited at 100Hz.
You can read section 3.3.3.5 from the following datasheet of the BNO055 chip, which is the chip we’re using in our DI IMU:
For all of this to work on your GoPiGo3, you need to install the GoPiGo3 and DI-Sensors packages. If you are already on R4R (Raspbian For Robots), you can just skip this if it’s the latest image:
curl -kL dexterindustries.com/update_gopigo3 | bash
curl -kL dexterindustries.com/update_sensors | bash
And then as an example you have this:
from di_sensors.inertial_measurement_unit import InertialMeasurementUnit as IMU
from time import sleep
imu = IMU() # with the IMU connected to the I2C port
while True:
vals = imu.read_euler()
print("Heading: {:06.2f} | Roll: {:06.2f} | Pitch: {:06.2f}".format(*vals))
sleep(0.01) # run it at 100Hz
This little example will output something nice like this:
Heading: 058.75 | Roll: -26.44 | Pitch: 071.12
Heading: 058.81 | Roll: -26.50 | Pitch: 071.12
Heading: 058.81 | Roll: -26.56 | Pitch: 071.12
Heading: 058.88 | Roll: -26.69 | Pitch: 071.12
Heading: 059.25 | Roll: -26.75 | Pitch: 071.12
Heading: 059.31 | Roll: -26.88 | Pitch: 071.12
Heading: 059.31 | Roll: -27.00 | Pitch: 071.12
Heading: 059.38 | Roll: -27.06 | Pitch: 071.12
Heading: 059.75 | Roll: -27.19 | Pitch: 071.12
Heading: 059.75 | Roll: -27.25 | Pitch: 071.12
Heading: 059.81 | Roll: -27.31 | Pitch: 071.12
Heading: 060.00 | Roll: -27.44 | Pitch: 071.12
Heading: 060.06 | Roll: -27.50 | Pitch: 071.12
Heading: 060.06 | Roll: -27.56 | Pitch: 071.12
Heading: 060.12 | Roll: -27.69 | Pitch: 071.12
Heading: 060.38 | Roll: -27.75 | Pitch: 071.12
Heading: 060.38 | Roll: -27.81 | Pitch: 071.12
Heading: 060.44 | Roll: -27.88 | Pitch: 071.12
Heading: 060.44 | Roll: -27.94 | Pitch: 071.12
Heading: 060.56 | Roll: -28.00 | Pitch: 071.12
Heading: 060.62 | Roll: -28.06 | Pitch: 071.12
Heading: 060.62 | Roll: -28.12 | Pitch: 071.12
Heading: 060.62 | Roll: -28.12 | Pitch: 071.12
Heading: 061.00 | Roll: -28.19 | Pitch: 071.12
Heading: 061.06 | Roll: -28.25 | Pitch: 071.06
Let me know if this answers your question.
Thank you!
Very helpful, thank you. imu.read_euler()[0]
was exactly what I was looking for! Now I’ve got a summer to build lesson plans around this.