Is there a simple way to change orientation in code?

Home Forums Forums Technical Support for BerryIMU Is there a simple way to change orientation in code?

Tagged: ,

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #15783
    jimb
    Participant

    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.

    #15784
    Mark Williams
    Keymaster

    Hi
    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 --

    #15785
    jimb
    Participant

    Thanks 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!

    #15787
    Mark Williams
    Keymaster

    I 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 --

    #15807
    jimb
    Participant

    Thank 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!

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

Blip, blop, bloop…