Home › Forums › Forums › Technical Support for BerryGPS and BerryGPS-IMU › Simple Inclinometer with compass in python
- This topic has 4 replies, 2 voices, and was last updated 6 years, 2 months ago by robertg.
- AuthorPosts
- March 20, 2017 at 4:56 pm #6177robertgParticipant
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.
March 20, 2017 at 5:04 pm #6178Mark WilliamsKeymasterAll the code for the IMU is here;
https://github.com/mwilliams03/BerryIMUThis 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-compassMark --OzzMaker.com --
March 20, 2017 at 5:16 pm #6179robertgParticipantTHanks 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.March 20, 2017 at 5:28 pm #6180Mark WilliamsKeymasterit 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 --
March 21, 2017 at 7:54 am #6182robertgParticipantThanks 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.
- AuthorPosts
- You must be logged in to reply to this topic.