GoPiGo IMU Examples

AND… I have implemented an expanded EasyIMUSensor() class in:
my_easy_inertial_measurement_unit.py

that implements mutex protected methods, and NDOF Sys calibration with file persistence.

DI Methods Implemented (Unchanged)

  • EasyIMUSensor(port=“AD1”, use_mutex=False)
  • imu.reconfig_bus()
  • imu.safe_calibrate()
  • imu.safe_calibration_status()
  • imu.convert_heading(in_heading)
  • imu.safe_read_euler()
  • imu.safe_read_magnetometer()
  • imu.safe_north_point()

.

Expanded mutex protected Methods Implemented:

  • imu.resetExceptionCount() resset count of recent I2C exceptions
  • imu.getExceptionCount() get number of recent I2C exceptions
  • imu.printCalStatus() prints sys, gyro, acc, mag status 0=not cal, 3=fully calibrated
  • imu.dumpCalDataJSON() writes out calibration data to ./calData.json
  • imu.loadCalDataJSON() returns calibration data from file ./calData.json
  • imu.loadAndSetCalDataJSON() Resets calibrarion from data in file ./calData.json
  • imu.resetBNO055() reset the IMU and print calibration status
  • imu.my_safe_calibrate() uses the NDOF SYS value instead of just mags value
  • imu.my_safe_sgam_calibration_status() returns all four cal status: sys, gyro, accels, mags
  • imu.safe_read_gyroscope() returns the gyroscope values x, y, z
  • imu.safe_read_accelerometer() returns the accels values x, y, z
  • imu.safe_read_linear_acceleration() returns the linear accel values x, y, z
  • imu_safe_read_temperature() returns the chip temp degC

.

I also created a version of the DI Examples/IMUSensor.py example that uses this expanded EasyIMUSensor() class: my_Examples_IMUSensor.py

And a further example which overwrites column justified readings while recording I2C exceptions or rotation of the bot: slowEzReads.py

1 Like

One word:

WOW!

And here I am, still trying to figure out the markings on the back of the beastie! (Or is that really an Anaconda?) Oh! Sorry. . . We’re talking about a programming language and not snakes? Oops!

Maybe after this you can submit an upstream kernel patch to Raspbian so that it fully implements the i2c spec., including clock stretching? Seems like this would be child’s-play for an old dog like yourself.

Me? I like programming, but I really like messing with the hardware - and then writing software to make it work. I like “blockly” style programming for the same reason - it’s the software equivalent of a breadboard. Not very pretty and it’s not the most elegant construction method, but it does allow you to prototype an idea quickly to discover if it works or not. Then you rip it apart and try something else once you loose interest in the current project. (Maybe I should change my “handle” to “Asperger’sPosterChild”? I get distracted really easily.)

If you make a mistake, zero problemo (unless you get the VCC voltage wrong or backwards!), you just pull out a component or two, move things around, and you’re back in business

To me, “conventional” programming is like soldering - it’s more difficult to change, it’s messier, and it’s a lot easier to misplace something like a curly-brace, parenthesis, or semi-colon and drive yourself all the way insane - and back again! - looking for a pesky short-circuit or miss-wire way behind a dozen other things.

I just updated the my_easy_inertial_measurement.py EasyIMUSensor() class with a working resetBNO055() method - I think that was the last part to get working.

The “simple” calibration example is at calEz.py

The “Full” calibration with file save/restore example is next on my to-do list.

And BTW the BNO055 datasheet (pdf), I am using is v1.4 located here

We take pull requests, if you’re willing to share your code . Hint hint.

1 Like

I feel honored by the comment, but the code is very green at this point. Testing for correctness and for utility are needed before I would be emboldened to suggest a pull request.

In the meantime, all my code is on github for use by the courageous and curious.