Electronic – How to count the units moved with 2 motor encoders

digital-logic

I have a 2 wheel device that both has motor encoders, counting the units moved on both motors is simple if the both motors speed is the same. My problem arises when the device is turning to the left or to the right. Turning causes one motor to speed up and the other to slow down. The count now on each motor is different.

Is there some logic or arithmetic i can apply that takes into accounts turnings? and can calculate the true distance moved of the device. The point of refence now of measuring the distance is now not on the wheel since it is not very reliable but now on the center of both wheels.

What I came up with is just to AVERAGE the left and right motor counts, but i do not know if this is the best solution to approach this problem

Any thoughts?

enter image description here

Best Answer

im not sure of my answer:

arc length = $$2\pi r\theta$$

enter image description here

distance between wheels = h

arc1 units = $$2\pi r\theta$$ arc2 units = $$2\pi (r+h)\theta$$

arc_center = $$2\pi (r+(h/2))\theta$$

average:

$$(arc1 + arc2) / 2 = (\pi\theta)(r+(r+h))$$ $$(arc1 + arc2) / 2 = (\pi\theta)(2r+h))$$ $$(arc1 + arc2) / 2 = (\pi\theta)(2(r+h/2)))$$ $$(arc1 + arc2) / 2 = 2(\pi\theta)((r+h/2)))$$

you can see your method is actually = center arc length