Finding Azimuth using the DI IMU Sensor

I have connected the Dexter Industries IMU Sensor to the GoPiGo on I2C and am getting inconsistent results in some cases and what seems to be incorrect results in others.

For example, I am trying to calculate azimuth using the magnetometer data obtained by calls to inertial_measurement_unit.py

Here is the statement I am using for the calculation:
Azimuth = (90 - (math.atan2(mag[0], mag[1])*180) / math.pi)

With the GoPiGo engaged in turning in a full circle, I would anticipate having continuous values in the range 0 to 360, Instead the values go to 264 then drop negative then turn positive again before rising to 264 before dropping negative again.

I also can see no information anywhere on your site on how to calibrate the sensor. I did found information from Bosch on calibrating the BNO055, which seems interesting. Unfortunately, I cannot find how to do with your unit the sort of operations they are illustrate in this video: https://youtu.be/Bw0WuAyGsnY

I could also use some guidance as to the proper orientation for placing the sensor on the GoPiGo. Photos on the Web site show the sensor mounted on the unit with devices that I learned (after placing my order!) must be ordered separately.

Are you using the GoPiGo3? If so, try using the IMU on one of the AD ports of the GPG3.

Thanks for your response.

No, it’s one of the earlier models. I guess I was not clear in my post. As I mentioned, it sort of works on the I2C. Unfortunately, I am thinking there is a problem in my math, given the bizarre readings I am getting with the calculations for azimuth.

In addition, I could see that there are additional functions in Easy_Inertial_Measurement_Unit.py, and I finally figured out how to import those into my program.

It would have saved me a lot of time had I been able to see some sample code for the Easy library that is akin to: IMUSensor.py, which I found here:

Hi @michael_bush,

You might be interested in taking a look at how I did it here (check getNorthPoint function):

As for the documentation, we have this one here. There are 2 classes defined for the IMU sensor: one more complex and another one, simpler.
https://di-sensors.readthedocs.io

Thank you!

Thanks! I will try this! I was editing my previous reply when I noticed this. Basically, I was finally able to get the “Easy” version running. It would have been helpful to have some more examples. I can see from this that I need to change how the sensor is mounted.

As to the issue of mounts, it would have been helpful to know that one did not come with the sensor at the time I ordered it! I guess the marketing folks are doing all they can to eke out revenue where they can, but I could have ordered one with the sensor and avoided an additional shipment had I known.

Thanks again for your help!

Hi @michael_bush,

That’s great. Please, let us know if you get yourself into any problems down the line. And as for the mounts, are you referring to the blue injection-molded mounts?

Thanks!

Yes, the mounts I mentioned are the blue, injection-molded mounts.

Oh I see. I’m really sorry for the inconvenience. I’ll check with the other team and see if we can change that the next time.

Thanks Michael! :slight_smile:

Regarding the sensor mounts, I’m sorry for the confusion! We will come back to it and give it a look, maybe we’ll start packing a sensor mount along with the sensor to make it easier.