ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

rosserial stops working when trying to use software serial on arduino?

asked 2020-10-20 05:40:29 -0600

ekptwtos gravatar image

updated 2022-05-15 08:33:23 -0600

lucasw gravatar image

Hello everyone,

I am running ROS melodic on ubuntu 18.04 and I have encountered a problem for which I couldn't find any info , or I didn't know how to look for it (which could be possible! ) and I would like your help!

I have been using rosserial in the past with no issues at all. However, I have never tried using the serial communication on the arduino side, while it is plugged in the computer and the rosserial is running. When I did try yesterday to control a VESC through arduino's software serial library, if I do not send any commands to the vesc through UART all is fine and ros is happily connected to the arduino, but the moment I try to send a vesc command (no matter what command i try to send ) I get the following error on the terminal:

[INFO] [1603186275.781290]: Requesting topics... Requesting topics... The setup is as follows:

Laptop running ros -> arduino -> vesc

Joystick sends commands to the arduino over rosserial || the arduino sends the current value to the vesc (vesc being controlled in current mode )

The rosserial is communicating with the arduino at 56200 BAUD whereas the software serial ( I am using this library because of lack of serial ports ) is set to 19600 BAUD.

I can control the vesc with ppm control and rosserial but then I lose all the info I could get back from it using the UART, which is something I would rather not!

Here is a simple arduino code:

#include <Arduino.h>
#include <VescUart.h>
#include <SoftwareSerial.h>
#include <ros.h>
#include <geometry_msgs/Twist.h>

SoftwareSerial vesc1_serial(6, 7); // RX , TX
VescUart vesc1;
ros::NodeHandle nh; 

/////// PUBLISHERS /////////

geometry_msgs::Twist vel_recieved;
ros::Publisher velocity_pub("/report/vel_received", &vel_recieved);

void setup()
  // Serial.begin(19200);
  // vesc1_serial.begin(19200);


  /** Define which ports to use as vesc1 */

void loop()


  vel_recieved.linear.x = 3;


  vel_recieved.linear.x = 0;

  // drive_vesc();
  // get_vesc_values();


The command that makes rosserial through the error is this one:


This is the library I use for vesc uart control. Important! It has to be the development branch because this allows controlling vescs over software serial.

Any idea as to what might be causing that? Any advice greatly appreciated!

Should you require any additional info, please let me know!

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2020-11-23 05:26:05 -0600

ekptwtos gravatar image

The answer to this question unfortunately was not the one I was looking for.

The software serial library, even though it allows you to use whichever pins you want as software serial, it still uses the hardware serial, therefore microcontrollers that have only 1 hardware serial port can not be used for this application.

My solution was to buy a Feather M0 which has 1 hardware serial, but you can create more hardware serial ports through SERCOMs. Here is the relevant link for those who are interested.

IMPORTANT NOTE it took me some time before I could make the Feather communicate over its USB with rosserial. The reason behind this: to use samd21 native usb port you have to add

#define USE_USBCON

before including any ros libraries in the Feather code.

Hope this helps someone, and /or save some and frustration!



edit flag offensive delete link more


Hi, I am having exactly the same problem. I am trying to publish the GPS data from my mega2560 using rosserial and SIM808 module is using the SoftwareSerial. Can you show me exactly, how did you solve this?

I also noticed this from the documentation of SoftwareSerial: "The library has the following known limitations:

If using multiple software serial ports, only one can receive data at a time. "

but here I am trying to receive GPS data with SoftwareSerial and publish (tx) with rosserial. I am guessing that should be possible.

I also have stumbled upon this gem: which could be the answer.

attaoveisi gravatar image attaoveisi  ( 2021-01-04 11:15:16 -0600 )edit

Question Tools



Asked: 2020-10-20 05:40:29 -0600

Seen: 667 times

Last updated: Jan 04 '21