I notice some strange behaviour on my compass sensor (CMPS10) which also has pitch and roll data and should be able to compensate based upon pitch and roll.
When my robot is stationairy and I read the sensor everything is working fine. As soon as a start moving the robot forward (not turning), the heading readings are jumping around. They can deviate as much as 20 or 30 degrees or more while I am quite sure my robot is moving in a straight line so the heading shouldn't change.
I immediatly thought it was caused due to interference of my servo's so I tested by holding the robot in my hand and letting it move forward in the air. My readings on the sensor are suddenlty very stable and not changing so the servo's aren't the cause. I also held the robot on the floor so the servo's used the maximum current just so I could rule that out and once again, readings on the compass are stable.
I also have to admit that the sensor itself is mounted on top of the robot on a not so stable platfom so when the robot moves, the vibrations from the movement make the sensor vibrate a little but the 20 degrees deviation seems a bit to much. I tried by jiggling the platform and replicate the vibration and I get 2 to 4 degrees but not more.
It seems really odd and I don't know what is causing it.
Sometimes during moving forward the reading even jumps 50 degrees, it's crazy. It's even so that when I let the robot rotate one direction by 50 degress and than back, the heading is so far you wouldn't believe it.
When I rotate the robot by hand he's almost dead on. Even when I let the robot move in the air and my hand is doing the turning but the servo's are running, the reading is the same.
Could this really be because of the vibrations caused by starting, stopping and moving?
Compass modules are susceptible to magnetic interference. That can include your motors and probably explains why you are getting such huge discrepancies when moving only. Other causes can be proximity to hifi speakers your fridge or microwave or anything else that has a decent magnetic field. A lot of people stick their compass on a tower high above the robot to get it away from the magnetic influence of it’s drive motors. Or you could try shielding your motors.
The module is about 20cm above my motors and even when I put the motors at full speed and let it drive but still holding it, so there is definitly load, the headings are dead on.
I think I found some issues… I did the test on my sofa which is soft material so any load will bounce the robot even more. I did the same tests on the floor and the deviations are far less so I guess it must be vibration.
A motor is drawing most current when starting, right? So if I hold the robot so it is still touching the ground and the wheels can move but I hold it in position. That puts a load on the motors but I can keep the robot stationairy. This is a good test, right? During that test the headings don’t change, only when I rotate the robot and the messurements seem correct.
It does sound like you have put some thought into the problem and done tests to establish the cause. And it does sound like it is caused by vibration from your tests.
If it is vibration perhaps you could look at solving it by dampening the vibration. Mounting on a spring or foam perhaps?
So I did a few more tests and I believe there is some interference playing with the compass.
In this test I let the robot wander around and noted down the heading at certain points. I found that the compassis always jumping about at the same location and the reading at those locations are also always almost the same. So if it jumps 20 or 30 degrees at a certain point, it is jumping always that amount when the robot is passing that point.
Strange thing is that at those points, there is no real electronics or something so I don’t understand why it is jumping at those points.
This means that I cannot use the compass for an accurate reading however I use the compass to give the robot a sense of direction/location and in combination with other sensors the robot will have a feel of its location as the readings are concistent which is good.
I only cannot rely on the value. 30 degress on spot A is not the same as 30 degrees on spot B but if the robot is always facing in the same direction, it will also messure 30 degrees at those points. So in a way I can rely on the deviation which sounds a bit contradictary…