As I was experimenting with a HMC5883L sensor, I was curious about using it to detect ones orientation in 3D space.
After writing some code to compute the heading
and how much tilt is in the magnetic field, I made a contraption using four small servos with some Polymorph.
I previously posted a photo of this contraption in the thread about servo attachments
I kept hoping I could get the thing to work well enough to make a video of it in action but I finally gave up on trying to get it to work well and just decided to make a video of it attempting to work.
The two bottom servos use the same signal line. Using the servos stacked like this, allows the two 180 degree servos to provide a full 360 degree range of motion. I was really pleased with how easy it was to get 360 degree motion from these servos.
The Earth's magnetic field is almost vertical here in Idaho. It's off from vertical by only 19 degrees. The vertically aligned field plays havoc on the sensor's ability to find a heading.
Here's a video with the z-axis aligned with the field (this was part of my calibration process).
You can see when the field is perpendicular to the board, the measured heading jumps around.
I'll save a couple of extra posts in case I want to add to this project.