ROS driver for Zumo32u4

I modified HomeBrew Robotic’s ros_arduino_bridge to support the zumo 32u4 robot. Pretty simple mods. It works, however the reset encoder count does not reset to 0. Not sure why. Drive works fine though.

Download from


From a cursory glance at its GitHub, it seems that ros_arduino_bridge has a resetEncoder function; are you saying that the ros_arduino_bridge function does not seem to work for you or is one of the functions in our Zumo library not functioning as intended?


I implemented the resetEncoder function, but during testing it did not keep the 0 value. Both the Zumo lib and my resetEncoder code are pretty simple; I suspect it’s on the ROS side. Of note, readEncoder() works fine.

Here’s the relevant Arduino code from

#elif defined(ZUMO32U4)
#include <Zumo32U4Encoders.h>

  /* Create the encoders object */
  Zumo32U4Encoders encoders;

  /* Wrap the encoder reading function */
  long readEncoder(int i) {
    if (i == LEFT)
      return encoders.getCountsLeft();
      return encoders.getCountsRight();

  /* Wrap the encoder reset function */
  void resetEncoder(int i) {
    if (i == LEFT)
      return encoders.getCountsAndResetLeft();
      return encoders.getCountsAndResetRight();
  #error A encoder driver must be selected!


I noticed you have return statements in resetEncoder even though it has a void return type, which causes the expression after the “return” keyword to not be evaluated. If you don’t care about the counts before the reset, you should remove the “return” keyword. If you do want to get that value, you should change the return type of resetEncoder to int.


You are the man. That fix worked. I simply removed the return keyword. Good eye.

With that, we now have a working ROS driver for Zumo32u4.

Thanks Tony!!!

1 Like