We then combine
and
to compute the actual velocity for the
right motor and the left motor. In other words, each motor does not really
have its own acceleration.
Note that for the angular displacement, we also need to take the sign into consideration. The modified code to handle signed quantities is as follows:
The previous code should be replicated so we end up with one for
linear distance and one for angular distance. Then we combine the
two and control the stepper motors. The following is the code for
the left motor. Code for the right motor is almost the same, except
the change
to
.