Home › Forums › Forums › Technical Support for BerryIMU › Is there a simple way to change orientation in code?
Tagged: Axes change, imu
- This topic has 4 replies, 2 voices, and was last updated 3 years, 4 months ago by jimb.
- AuthorPosts
- May 2, 2020 at 10:18 am #15783jimbParticipant
Hello, I have a project functioning quite well using the BerryIMU and/or the BerryGPS-IMU with code based heavily on the BerryIMU.py code in your git repository. Circumstances dictate that the orientation of my project needs to change so that the orientation of the IMU will essentially be rotated by 90deg around the Y axis; i.e., Z becomes X and X becomes -Z. Is there an “easy way” to change the code to accommodate this? Is it as easy as making the substitutions as highlighted above (Z -> X, X -> -Z)? or…? Any guidance is greatly appreciated. Keep up the good work; these are nice tools!! -Jim.
May 2, 2020 at 1:04 pm #15784Mark WilliamsKeymasterHi
It is possible. Tell me how you will have the board orientated and i will see if i can do some basic code for you. If you have it rotated 90 degrees on the Y axis, does this mean that the GPS module is at the top of the PCB like in the image below?Mark --OzzMaker.com --
May 2, 2020 at 1:26 pm #15785jimbParticipantThanks for the quick reply. I am attaching a photo of the current configuration showing the top view and the forward direction of movement. I am proposing to rotate the unit so that the right edge in the photo becomes the top (left edge goes down to be bottom) and the direction of movement is still from left to right. By this thinking, I believe the orientation is upside down to your figure and movement would be into the screen… does this make sense? The more I type the more I feel like a 2D creature ๐
Thanks again!
Attachments:
May 2, 2020 at 2:50 pm #15787Mark WilliamsKeymasterI assume you are using the python code?
Replace this;
ACCx = IMU.readACCx() ACCy = IMU.readACCy() ACCz = IMU.readACCz() GYRx = IMU.readGYRx() GYRy = IMU.readGYRy() GYRz = IMU.readGYRz()
with this;ACCz = -(IMU.readACCx()) ACCx = IMU.readACCy() ACCy = IMU.readACCz() GYRz = -(IMU.readGYRx()) GYRx = -(IMU.readGYRy()) GYRy = -(IMU.readGYRz())
Mark --OzzMaker.com --
May 14, 2020 at 12:08 am #15807jimbParticipantThank you!! I will try this out – I am sorry for not responding sooner. I appreciate your help very much… I am hoping that my order for 3 BerryGPS-IMUs will be delivered soon – our mutual postal services (Australian and Canadian) are taking their time!
- AuthorPosts
- You must be logged in to reply to this topic.