by roger » Mon Apr 30, 2012 2:35 am
Hi Orfeus,
I don't think the math is all that serious - it is based on the geometry of the arc of a circle. First, think of a rolling wheel. d = wheel diameter, a = angle of rotation of the wheel ( in radians) so the distance it moves over the ground X = a * d/2.
When the robot moves along the arc of a circle of constant radius and angle A, so does each wheel but the circles have different radii. The difference between the two is the track width W. Let Ro be the radius of the arc traveled by the outer wheel, and Ri , the inner wheel, So
Ri = Ro - W.
Therefore the two wheels travel a different distance over the ground: Xo = A*Ro and Xi = A * Ri .
From these relationships, you can calculate ratio of inside to outside motor speed and the angle of rotation of each motor as the robot traverses the arc.
There are two special cases: Straight line movement -> arc radius is infinite and speed ratio = 1; and rotation in place -> the speed ration is -1, so the robot arc radius = 0 and Ri = -Ro.
The same basic equations can be used to calculate the change in robot position at the end of a move from the tacho counts of the two motors.
The code has many public methods, but only a few private helper methods that contain the commonly used basic calculations.
I hope clears up some of the confusion.
Roger