Because the batteries, motors, and motor current affect the z axis of the magnetometer much more strongly than the x and y axes, this program calculates the Zumo’s orientation using only the x and y readings from the magnetometer, assuming that the robot is always level. In order to prevent external, locally varying magnetic fields (e.g. from rebar in a concrete floor) from affecting the Zumo’s navigation too much, the program measures the magnetic heading before each turn, then turns ninety degrees relative to that heading. | Because the batteries, motors, and motor current affect the z axis of the magnetometer much more strongly than the x and y axes, this program calculates the Zumo’s orientation using only the x and y readings from the magnetometer, assuming that the robot is always level. In order to prevent external, locally varying magnetic fields (e.g. from rebar in a concrete floor) from affecting the Zumo’s navigation too much, the program measures the magnetic heading before each turn, then turns ninety degrees relative to that heading. |