Rosanswers logo

I am trying to use rosserial with an Arduino Uno (ROS Indigo & ubuntu 14.04) to control a Kangaroo motor controller from Dimension Engineering. I am publishing a twist message which the Arduino subscribes to. Things are working at 57600 baud except that over half of the commands are not making it through, and after roughly 10 seconds it looses sync.

Now I'm trying to lower the baud rate to 9600. In my arduino code I have:

#define TX_Pin 10
#define RX_Pin 9

SoftwareSerial SerialPort(RX_PIN, TX_PIN);
KangarooSerial K(SerialPort);
KangarooChannel Drive(K, 'D');
KangarooChannel Turn(K, 'T');

ros::NodeHandle nh;

ros::Subscriber<geometry_msgs::Twist> sub("move", &move_cb);

void setup()
nh. initNode();


And in my launch file I put:

<node pkg="rosserial_python" type="serial_node.py" name="serial_node" output="screnn">
    <param name="port" value="/dev/ttyACM0" />
    <param name ="baud" value="9600" />

The Arduino then fails to sync, but if I change the launch file to

<node pkg="rosserial_python" type="serial_node.py" name="serial_node" output="screnn">
    <param name="port" value="/dev/ttyACM0" />
    <param name ="baud" value="57600" />

Then i connect, which tells me that the baud rate of the Arduino is not being set properly. Does anyone know how to properly set the baud rate?


I have since abandoned using ROSSERIAL and instead am using an FTDI cable which I highly recommend. A lot of sensors have packages already made for them to communicate over serial, and those that don't you can use pyserial which is very easy to setup :) This eliminates the need for a unnecessary Arduino, saving money and debugging time.

Originally posted by shoemakerlevy9 on ROS Answers with karma: 545 on 2016-09-07

Post score: 1


1 Answer 1


Rosanswers logo

The baud rate is used in ArduinoHardware::init(), which is called by NodeHandle_::initNode(), so I think you should set the baud rate before calling nh.initNode().

Originally posted by Mark Rose with karma: 1563 on 2016-09-07

This answer was ACCEPTED on the original site

Post score: 3

Original comments

Comment by Mark Rose on 2016-09-07:
I haven't had any problems with the default 57600 baud rate, though. How are you communicating, through a USB cable?

Comment by shoemakerlevy9 on 2016-09-07:
Yes I am communicating through a USB cable. Moving nh.getHardware()->setBaud(9600); above nh. initNode(); solved my issue. Although I am considering abandoning using an arduino altogether and instead using an FTDI cable because even with the baud rate issue fixed I am having issue sending motor cmds


Your Answer

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