Simple Inclinometer with compass in python

Home Forums Forums Technical Support for BerryGPS and BerryGPS-IMU Simple Inclinometer with compass in python

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #6177
    robertg
    Participant

    Hi,

    To save me working it out as I'm not the best in programming, does anyone have the python code to output compass and inclinometer readings please?

    thanks,

    Rob.

    #6178
    Mark Williams
    Keymaster

    All the code for the IMU is here;
    https://github.com/mwilliams03/BerryIMU

    This python code will print out +/- x and y degrees as well as the compass heading
    https://github.com/mwilliams03/BerryIMU/tree/master/python-BerryIMU-gryo-accel-compass

    Mark --OzzMaker.com --

    #6179
    robertg
    Participant

    THanks Mark,

    Should have looked a bit harder, found it.

    Any suggestions within this code how I would calibrate the reading.
    IE in my testing the X & Y are roughly 180deg out.

    #6180
    Mark Williams
    Keymaster

    it all depends on how you have the IMU orientated. And adjusting the code accordingly.
    There are plenty of comments in the code... an example is below.

    	####################################################################
    	######################Correct rotation value########################
    	####################################################################
    	#Change the rotation value of the accelerometer to -/+ 180 and
        	#move the Y axis '0' point to up.
        	#
        	#Two different pieces of code are used depending on how your IMU is mounted.
    	#If IMU is up the correct way, Skull logo is facing down, Use these lines
    	AccXangle -= 180.0
    	if AccYangle > 90:
    		AccYangle -= 270.0
    	else:
    		AccYangle += 90.0
    	#
    	#
    	#
    	#
    	#If IMU is upside down E.g Skull logo is facing up;
    	#if AccXangle >180:
        	#        AccXangle -= 360.0
    	#AccYangle-=90
    	#if (AccYangle >180):
        	#        AccYangle -= 360.0
    	############################ END ##################################

    Mark --OzzMaker.com --

    #6182
    robertg
    Participant

    Thanks again,

    Too easy!
    Was using the BerryIMU-simple which didn't have this.

    Can you suggest a rugged enclosure to enable mounting of the IMU only?

    Rob.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Blip, blop, bloop...