### Can I find the magnetic components from magnetic heading and pitch/roll/yaw?

I'm trying to get a simulated magnetometer (B0x, B0y, B0z) via X-Plane. Can magnetic heading be reverse engineered into its components so I can run an EKF on it. I've got it working with the real thing but it'd be nice if everyone could get the EKF to run without hardware.I've introduced an unrelated bug to my EKF that I've been spending time on so I'm hoping someone can beat me to figuring this out. I realize potentially their could be more than one solution which would make it impossible but if that's the case can someone confirm it?X, Y, Z = magnetic components in x, y and z axisXh = X * cos(roll) + Y * sin(pitch) * sin(roll) - Z * cos(pitch) * sin(roll)Yh = Y * cos(pitch) + Z * sin(pitch)Azimuth = arcTan(Yh/Xh)Summary: The problem is I have Azimuth and I need X, Y, Z. Can it be done?

#### Replies

• What I do to "measure" (simulate) a magnetometer in X-Plane is the next:

1º Take the GPS coordinates.
2º Calculate the XYZ with an Earth's magnetic model with the GPS coordinates.
3º Rotate this coordinates from the Flat Earth's Frame to Body's Frame (roll, pitch, yaw) to simulate the magnetometer measurement.

Do you know if X-Plane 10 will include magnetometer measurements?
• Developer
This might not follow your exact convention but you should be able to follow. Hope you can read the pic if not I have it on hand.
-Beall

### Activity

Chris Anderson liked Zara Mae Pickering's profile
May 21
RT @chr1sa: Donkeycar 4.4 released with tons of new features, including path learning (useful with GPS outdoors), better Web and Lidar supp…
Nov 27, 2022
RT @NXP: We are already biting our nails in anticipation of the #NXPCupEMEA challenge! 😉 Did you know there are great cash prizes to be won…
Nov 24, 2022
RT @gclue_akira: レースまであと3日。今回のコースは激ムズかも。あと一歩 #jetracer https://t.co/GKcEjImQ3t
Nov 24, 2022
UC Berkeley's DIY robocar program https://roar.berkeley.edu/
Nov 24, 2022
RT @chr1sa: The next @DIYRobocars autonomous car race at @circuitlaunch will be on Sat, Dec 10. Thrills, spills and a Brazilian BBQ. Fun…
Nov 24, 2022
RT @arthiak_tc: Donkey car platform ... Still training uses behavioral cloning #TCXpo #diyrobocar @OttawaAVGroup https://t.co/PHBYwlFlnE
Nov 20, 2022
RT @emurmur77: Points for style. @donkeycar racing in @diyrobocars at @UCSDJacobs thanks @chr1sa for taking the video. https://t.co/Y2hMyj1…
Nov 20, 2022
RT @SmallpixelCar: Going to @diyrobocars race at @UCSDJacobs https://t.co/Rrf9vDJ8TJ
Nov 8, 2022