I am using ROS 2 Humble on Raspberry Pi 4(Ubuntu 22.04 OS).

I am trying to build 2-wheeled diff-drive mobile robot and using ros2_control for controlling, but I'm not getting where should I write GPIO port connections part.

I am trying to control movement through Raspberry Pi GPIO pins using ros2_control. I have found many examples but with Raspberry Pi and Arduino serial connection not with only Raspberry Pi GPIO pins and L298N motor driver.

I'm not asking for code but where should it be written and whether it can be velocity controlled or not.

  • 1
    $\begingroup$ Welcome to Robotics Shah, but I'm afraid that questions asking for code are off-topic because there are many ways to solve any given coding problem. We prefer practical, answerable questions based on actual problems that you face, so please try to include what you want to achieve, what you tried, what you saw & what you expected to see. Please take a look at How to Ask, tour and the Robotics question checklist for advice on writing a good question. $\endgroup$
    – Tully
    Commented Mar 15, 2023 at 18:42
  • $\begingroup$ @Tully I have edited the question now. New to the forum so sorry for my mistakes. I just need to know where it should be written and if anyone can guide me little bit I would be grateful. $\endgroup$
    – Shah
    Commented Mar 16, 2023 at 17:10

2 Answers 2


It appears that a GPIO interface can be specified in the <myrobot>.ros2_control.xacro file, as seen here: https://github.com/ros-controls/roscon2022_workshop/blob/1-robot-description/solution/controlko_description/urdf/rrbot/rrbot_macro.ros2_control.xacro. Since this is just an xacro file, this is only providing the description of the interface to ros2_control, but keep following the example found in this repository to see how the hardware interface extends to the GPIO.



This code has the help you need. The Raspi can directly drive the Grove motor controller. It works very well.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.