How To Add A Motor Controller To Your ROS Robot

Jason Bowling
Exploring ROS Robotics
12 min readSep 24, 2022

--

Give your robot straight, precise driving and odometry!

Perseverance rover wheels. Image courtesy NASA JPL/Caltech, public domain

If you are building a mobile robot for use with ROS/ROS2, one of the first things you need to do is integrate a motor controller. The purpose of the motor controller is to accept messages from higher level software, such as the navigation stack, and convert it into signals that drive the motors. It will also receive information from the motor’s encoders to compute the robot’s speed and position. As a bonus, you get precise control over your robot’s wheels that are consistent as battery voltage changes and terrain varies. Interested? We’re going to go through everything you need to make a ROS motor controller for a typical differential drive robot, and give you code to a working one that you can use for reference!

The full code for this project is in the github repo.

Background

I’ll assume you’ve read my previous articles on why ROS is useful, what it does, and a high level overview of how it integrates with a physical robot:

--

--