Home › Forums › Forums › Technical Support for BerryGPS and BerryGPS-IMU › BerryGPS-IMU compass “north”
- This topic has 4 replies, 2 voices, and was last updated 7 months, 2 weeks ago by currydem.
- AuthorPosts
- February 10, 2023 at 10:19 am #17937currydemParticipant
I have a simple question. I’ve searched and found two separate answers. Which side of the BerryGPS-IMU is the “north” side. Like which side is facing towards the heading to be read? The short side with the “ublox” chip (Red arrow) or the long side next to the antenna switch (Blue arrow)?
Attachments:
February 10, 2023 at 12:39 pm #17939Mark WilliamsKeymasterIt is the blue arrow
On the next version, we will place an indicator on the PCBMark --OzzMaker.com --
February 10, 2023 at 3:35 pm #17946currydemParticipantThank you so much I have another question about the C files used in the tutorial and the python file. Would it be appropriate to ask it in this same thread or should I make another with that specific topic?
February 10, 2023 at 4:11 pm #17947Mark WilliamsKeymasterno.. go ahead here if you like
Mark --OzzMaker.com --
February 11, 2023 at 5:55 am #17948currydemParticipantIn the tutorial for the compass it is written in C and it has a section to compensate for soft iron distortion as well as magnetic declination. In the Python compass code it does not. I tried to mimic a soft iron distortion section but when I do this it doesn’t give me the correct heading. I also get a different heading (an incorrect one) when I use the original Python compass code even after calibration
code below:
Hard iron distortion
C code
magRaw[0] -= (magXmin + magXmax) /2 ;
magRaw[1] -= (magYmin + magYmax) /2 ;
magRaw[2] -= (magZmin + magZmax) /2
Python code
MAGx -= (magXmin + magXmax) /2
MAGy -= (magYmin + magYmax) /2
MAGz -= (magZmin + magZmax) /2
Soft iron distortion
C code
scaledMag[0] = (float)(magRaw[0] – magXmin) / (magXmax – magXmin) * 2 – 1
scaledMag[1] = (float)(magRaw[1] – magYmin) / (magYmax – magYmin) * 2 – 1
scaledMag[2] = (float)(magRaw[2] – magZmin) / (magZmax – magZmin) * 2 – 1
Python code (what I tried to adapt to the Python code)
scaledMagX = (MAGx – magXmin) / (magXmax – magXmin) * 2 – 1
scaledMagY = (MAGy – magYmin) / (magYmax – magYmin) * 2 – 1
scaledMagZ = (MAGz – magZmin) / (magZmax – magZmin) * 2 – 1
C code
float heading = 180 * atan2(scaledMag[1],scaledMag[0])/M_PI
Python code (what I tried to adapt to the Python code)
float heading = 180 * atan2(scaledMagY,scaledMagX)/M_PI
*****original code*********
heading = 180 * math.atan2(MAGy,MAGx)/M_P
***************************
- AuthorPosts
- You must be logged in to reply to this topic.