Hello,

I just bought a book "Inteligence unleashed" and there is a note about "some serious math" in "Just for fun!" section on page 97. I'm actualy curious about used math formulas used in DifferentialPilot class, but it's quite complicated to get it from source code, because, there is refering to variables which are refered to another variables or constants etc. in every method. Does anyone have these math formulas used in this class in "math form"?

I'm writting a work about LeJOS and I need to mention these formulas in there.

Thx for answer.

## DifferentialPilot math formulas

**Moderators:** imaqine, 99jonathan, roger

### Re: DifferentialPilot math formulas

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

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

### Re: DifferentialPilot math formulas

Thx a lot, it's very helpful.

### Who is online

Users browsing this forum: No registered users and 2 guests