2

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?

caffeine
  • 123
  • 4

2 Answers2

1

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.

Olin Lathrop
  • 310,974
  • 36
  • 428
  • 915
0

Have seen this kind of direction sensing work, but it isn't easy. Depending on your location, one component of the compass chip is vertical. Near the north or south pole, the vertical component dominates, and the X,Y components are very small. Any tilt must be corrected in a 3-dimensional manner - that is why the accelerometer is included. You are interested in the x-y plane to extract direction information, but part of the z component will likely reflect to x-y plane. In Northern USA, the Z-axis dip angle (from vertical) is about 70 degrees.
Peter Bennett has mentioned one problem indoors (add conduit to rebar and steel structures as magnetic disturbers). Another problem involves DC current in your robot wiring affecting compass direction - current-carrying wires produce magnetic fields too. You may have to mount this module well away from other electronics and motors.

glen_geek
  • 23,591
  • 1
  • 22
  • 50