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

Arduino Rosserial no/slow communication

asked 2012-01-06 06:38:37 -0500

dallaby gravatar image

updated 2012-07-02 13:40:59 -0500

mjcarroll gravatar image

Hi everyone.. forgive me if this has been asked/answered and also I am pretty new with ROS.. Anyway my robot is using Arduino mega 1280 to drive the motors, read encoders, calculate speed/velocity etc.. I was able to create a teleop application and subscribe to that with the arduino and read joy commands successfully to drive the robot..

Since my end goal is to implement the navigation stack I began to program that next.. I started with the tf tutorial and was able to get that running and delivering data to ROS, although I started to have problems with losing sync but it seemed if I timed starting the arduino and ros package it would work..Next I setup the odom stuff from the navigation tutorial.. Now whenever I run the package all I seem to get is lost sync messages.. I am calling ros::spinOnce() with a delay of 10millis and my rosserial is setup with a bandwidth of 115200..

I try running rostopic echo tf and I will see the tx light on the arduino blink once and I will see half of the echo on screen then in about(5 secs) it will blink again and then the rest of the message will show up, then if I wait again and I will see the information change but it seems like something is making it hang up.. I can post the code if that will help.. ?? Thanks in advance for any help..

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2012-01-06 09:10:43 -0500

ahendrix gravatar image

I have a very similar setup on my robot: an Arduino Mega 2560 running rosserial and doing odometry, motor control and a few other things.

Since the tf and Odometry messages contain mostly redundant data, I publish a simplified message without covariance data, and then reconstruct the tf and full Odometry messages on the computer.

My node for receiving simplified odometry messages and transforming them is here: and my message package is here:

edit flag offensive delete link more


I actually came across your setup before and thought it looked awesome.. I was reluctant to try as I wasn't sure if the serial port would keep up with the encoders but I guess it is MUCH less data.. And I presume that I could still do all my speed/distance calculations on the arduino for the PID con
dallaby gravatar image dallaby  ( 2012-01-06 10:08:50 -0500 )edit
If you wander around the rest of the repository, take the arduino code with a large bucket of salt. While I'm running on an arduino, I'm not using the arduino IDE, and I'm using a modified version of the rosserial client. Also note that all of my current work is happening on the interrupts branch.
ahendrix gravatar image ahendrix  ( 2012-01-06 10:34:55 -0500 )edit

answered 2012-01-06 07:36:54 -0500

adasta gravatar image

It sounds like you are exceeding the bandwidth and the packets are getting jumbled.

As a quick sanity check, figure out how much data you are actually sending per second.

The odometry message has a geometry_msg/PoseWithCovariance and a geometry_msg/TwistWithCovarience field. The covariance is a float64[36]. This means to send just the covariances you 2* 836=576 bytes. It is another 268=208 bytes to send the Twist and Pose. Total= 784 per message. Multiply that by the rate to get the bandwidth used.

TFs are also another source of huge data transfer.

You cant send that much data back and forth between the computer and the arduino. You need to throttle it.

Cheers, Adam

edit flag offensive delete link more


More importantly, you may very well be exceeding the size of the buffer.
fergs gravatar image fergs  ( 2012-01-06 08:01:42 -0500 )edit
@Adam and Fergs... If that were the case would it just stop sending data all together? Cause when this happens I see no activity from the serial lights on the Arduino either tx or rx for 5 secs and then just 1 little blip and then nothing again..
dallaby gravatar image dallaby  ( 2012-01-06 10:08:28 -0500 )edit

Question Tools


Asked: 2012-01-06 06:38:37 -0500

Seen: 4,227 times

Last updated: Jan 06 '12