Rosanswers logo


Recently i started my own robot project to learn ROS, using Arduino. So far i just have a single Arduino + L289n dual h-bridge motor controller to power 2 DC motors

The initial setup of my project is based on the Husky project, so i have a base node containing a hardware_interface::RobotHW class that communicates with the Arduino. Using the teleop_twist_keyboard i'm able to move my robot. Currently this is done using a custom message, where the RobotHW is the advertiser and the Arduino the subscriber. But just driving the motors is far from enough. I'm using powerfull 24V DC motors salvaged from broken printers and big (heavy) wheels from an old RC car. Currently i'm running the motors are 12v, which seem to be enough to get the robot rolling, but it takes time to get up to speed cause of the big heavy wheels and they keep spinning once the wheel speed is set to 0.

To apply brake force to the wheels i need to reverse the motor power till the wheels stopped, so i got myself some motor encoders to measure the speed of the wheels. According to the hardware interface documentation and code i been checking to learn how it works, i need to read from the hardware, update the controller manager, then write to the hardware. So using ROS message system doesn't seem the correct way.

Been looking into using rosserial for c++ and using the Serial communication in the Arduino firmware instead of message advertisers/subscribers, but this require writing some custom protocol for messages between the hardware and the hardware interface node.

So before continuing writing a custom serial comm protocol, i wanted to know if this is the correct way to go, or if i should just use advertisers/subscribers to send custom messages between the hardware/ros node?

Full code of my project in the current state of using messages can be found here: https://github.com/DeborggraeveR/ampru

the ampru_base package, contains both the firmware and the hardware interface node.

Originally posted by RandyD on ROS Answers with karma: 161 on 2017-06-08

Post score: 0

Original comments

Comment by Soleman on 2022-02-07:
hey @RandyD. I saw your work its very impressive. I am very new to ros. I have same configuration like your as 2 dc motos with encoders, 1 arduino mega, 1 IMU sensor, 1 intel realsense D415. Currently I am facing a problem that how to set odometry using my dc motors and arduino. I am very new the brief guidelines will be highly appreciated. Thank you.


1 Answer 1


Rosanswers logo

As there were no answers to my questions, i went forward with using a custom serial protocol instead of publish/subscribe topics to communicate between the hardware interface node and Arduino.

The protocol is based on HDLC and seems to work fine :) Code pushed to git repository.

Originally posted by RandyD with karma: 161 on 2017-06-16

This answer was ACCEPTED on the original site

Post score: 0

Original comments

Comment by Sai Krishna on 2018-08-26:
Hi Randy, I'm new to roscontrol. Can I know what was the problem if you use public/subscribe to communicate between hardware interface node and Arduino.? Can't we subscribe to the joint values from Arduino and update control manager and then publish the new joint values to Arduino.?

Thank you :)

Comment by pranavb104 on 2018-12-13:
Hi Sai & Randy, I also wanted to know if we can work with publisher/subscriber instead of a custom protocol . Just wanted an opinion before I go forward with my method. Let me know. Thanx!

Comment by RandyD on 2018-12-14:
Hi, i tested with publisher/subscriber on Arduino and it works fine, but my concern was that using it contains more code, while the programming memory on arduino is limited and there is more data going over the serial port.

Comment by pranavb104 on 2018-12-14:
Ah...makes sense....i also got it working anyway....thanx

Comment by Sai Krishna on 2018-12-15:
Hi Pranavb, Can I know your mail id. So that we can share our works. Mine is [email protected].

Comment by pranavb104 on 2018-12-16:
my email is [email protected]

Comment by RandyD on 2018-12-17:
Share your code on github, might be useful to others as well ;)

Comment by pranavb104 on 2019-01-04:
sure ! https://github.com/pranavb104/Robo-moveit/tree/master

Comment by Hunterx on 2019-03-21:
Hey pranavb104 The github link is not valid anymore. Could you send me the code. :)

Comment by fjp on 2020-03-18:
Hi @pranavb104 the link to your Robo-moveit GitHub repository seems to not work anymore. Could you please update it? Thank you.

Comment by pranavb104 on 2020-03-18:
@fjp https://github.com/pranavb104/ROS-Arduino-Robot-Arm Hope this works :D


Your Answer

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