is the total number of steps that both motors need to perform. This
is not difficult to understand.
, on the other hand, is a little more
complicated.
is the total difference of steps between the two motors.
In other words, if forward is positive for both wheels,
is the
difference between the displacement of the right wheel and the displacement
of the left wheel.
To keep track of
, every time either the right or the left wheel has
a step forward, we add one to a counter. If a wheel has a step
backward, we subtract one from the counter. To keep track of
, we
assign positive to forward for one motor (we'll use left-forward), and
assign negative to forward for the other motor. This means for each step
the left wheel goes forward, it adds one to the counter. For each step the
right wheel goes forward, it subtracts one from the counter.