Using Encoders to move back to starting position - Zumo 32U4

If i was to have a zumo drive in a straight line and use the following to measure the wheels:
int16_t countsLeft = encoders.getCountsLeft();
int16_t countsRight = encoders.getCountsRight();

Is there a way to use this information to return the zumo to the point where the encoders were at 0?

Hello.

You should be able to do that, but you might notice some slight error depending on how much the tracks slip. The simplest method to achieve that would be to program a loop that commands the Zumo to drive the motors backwards, updates the encoder values, and ends when the encoder values are equal to or less than zero.

- Patrick

Thanks for the response.

Any advice on how i would do the same thing but taking into account if the robot has turned left and right multiple times during the original journey?

There are many different ways you could do something like that, so I do not have any specific suggestions for what would work best in your application. For inspiration, you might check out the dead reckoning robots that some people here made for an LVBots competition a few years ago. (Specifically, I suggest looking at the blog posts about Paul’s robot and David’s robot.)

- Patrick