Control a differential drive robot

I have some questions about implementing a mobile robot. I have an old construction mobile robot wherein this robot the main controller has been removed, and I put in its place a Raspberry Pi 4. I have put Linux and ROS on Raspberry.

I found this library pigpio library I managed by sending pulses through the GPIO to have movement on the wheels.

These pulses can be converted to RPM with the appropriate code, so I can also have the wheel speeds in meters per second. Through forward kinematics, I can convert them to angular and linear velocities of the body entirely theoretically. Is there a way to do this with ROS?

I made a Python script for ROS, which converts linear and angular velocities to wheel velocities, in other words, inverse kinematics.

Can these two coexist so that I can control the robot?

I appreciate any help you can provide.

1 Like

Hi, just a high-level pointer: you probably want to write a ros_control hardware interface for your robot using velocity interface (because you can control velocity of the motors directly). If you create this ros_control interface, you can apply any of the available controllers you find, including diff-drive controller.

If you want to keep things pythony, simple and non-compatible, you can keep your custom code. The usual way mobile robots are controlled in ROS is by accepting a geometry_msgs/TwistStamped message, where linear.x tells forward velocity and angular.z tells rotation speed about the vertical axis. You can definitely have one topic that controls the motors directly (via wheel velocities), and at the same time the cmd_vel topic accepting twist messages and running the command through this super-simple inverse kinematics.

1 Like

I forgot to mark something about robot.
Because it is old-made, the robot does not have wheel encoders. Can I implement forward kinematics without having the encoders?

Yes you can. You can set diff drive controller to work in „open-loop“ mode.

1 Like