Electronic – arduino – Cheap indoor compass

arduinocompass

I am trying to build a simple RC rover (car with only two wheels).
On certain commands, I want it to rotate a specific number of degrees into a direction or another (don't want military precision). In other words, to change it's orientation by controlling the two wheels.

I wanted to use a cheap compass like this: https://www.pololu.com/product/2127 (LSM303D)
But I heard that it won't work inside buildings; my rover will be used inside.

But in my case, I don't want to know the current orientation of my car, I just want to rotate an exact number of degrees into a direction relative to current orientation (even if current orientation is wrong).

Will it work in my case?

Do I have any other options to play around?

PS: Another possibility would be to use stepper motors. But this method is not pretty accurate as the contact surface of wheels may be smooth.

What about a gyroscope?

Best Answer

The reason the manufacturer says the compass "doesn't work" indoors is because there can be various magnetic sources indoors. The compass still works fine telling you which direction the magnetic field north lines go, but that direction may have little to do with the earth's magnetic field.

Since these magnetic source are quite localized, the apparent direction can change significantly as the car drives around on the floor of a single room. This makes such a compass useless for navigation.

However, turning in place might still work. The car wouldn't be changing location, so whatever magnetic field is around it should be fairly consistent as the car turns in place. You might get away with stopping the car, looking at the magnetic field direction, turning in place some fixed amount relative to the magnetic field, then moving again after the turn. Doing a broad turn while also moving is less likely to work as expected.