Rosanswers logo

Dear sir, I use arduino yun and build rosserial-arduino example helloworld, when I complier and upload the code, it show warning: Sketch uses 11,968 bytes (41%) of program storage space. Maximum is 28,672 bytes. Global variables use 1,948 bytes (76%) of dynamic memory, leaving 612 bytes for local variables. Maximum is 2,560 bytes. Low memory available, stability problems may occur. Could this cause problem? How to reduce size? Helloword is simple: #include <ros.h> #include <std_msgs/String.h>

ros::NodeHandle nh;

std_msgs::String str_msg; ros::Publisher chatter("chatter", &str_msg);

char hello[13] = "hello world!";

void setup() { nh.initNode(); nh.advertise(chatter);

void loop() { str_msg.data = hello; chatter.publish( &str_msg ); nh.spinOnce(); delay(1000); }

The communication errors: john@uDocker:~$ rosrun rosserial_python serial_node.py _port:=/dev/ttyACM1 [INFO] [WallTime: 1461906854.574293] ROS Serial Python Node [INFO] [WallTime: 1461906854.580512] Connecting to /dev/ttyACM1 at 57600 baud [ERROR] [WallTime: 1461906871.685965] Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino

I had follow http://wiki.ros.org/rosserial_arduino/Tutorials/Arduino%20IDE%20Setup and then follow http://answers.ros.org/question/196204/unable-to-sync-with-device-arduino-uno/ to get indigo source code, but the errors are the same.

Could somebody show me how to debug this?

  1. how to low the serial baud from 57600 to a low rate to make the link stable
  2. How to check my rosserial_python version and my Arduino version, such as "link software version mismatch such as hydro rosserial_python with groovy Arduino"

Thanks John

Originally posted by john_gao on ROS Answers with karma: 11 on 2016-04-29

Post score: 1

Original comments

Comment by alee on 2016-05-12:
Are you sure you have the correct permissions to your Arduino? Also, are you running at the same baud rate on the Arduino? There's likely a mismatch in baud rates between the serial node and the Arduino

Comment by john_gao on 2016-05-12:
Thank Alee, I think the baud rate is control by rosserial. I had add code set the serial port board in setting up. but the result is same.

Comment by alee on 2016-05-12:
Both can control baud. There's a baud rate on the arduino side and a baud rate on rosserial's side. Both need to match to communicate

Comment by john_gao on 2016-05-12:
Could you tell me the detail? From the sample code, this is hidden. If I want to reduce it, what should I do? Thanks

Comment by alee on 2016-05-12:
nh.getHardware()->setBaud(//some baud rate);

Make sure this value matches what you set for serial node.

Comment by john_gao on 2016-05-15:
Dear alee, it still does not work, even I drop both to 9600. I follow in http://wiki.ros.org/rosserial_arduino/Tutorials/Arduino%20IDE%20Setup I had done both 3.1.1 and 3.1.2, the only mistake is git clone which somebody see should use indigo, I had redo it but don't know how to clean old one,

Comment by alee on 2016-05-16:
What distro of ROS are you on? If you ran make_libraries with the wrong version of ROS, it might cause issues.

Comment by john_gao on 2016-05-17:
Thank alee, john@uDocker:~$ env | grep ROS ROS_ROOT=/opt/ros/indigo/share/ros ROS_PACKAGE_PATH=/opt/ros/indigo/share:/opt/ros/indigo/stacks ROS_MASTER_URI=http://localhost:11311 ROSLISP_PACKAGE_DIRECTORIES= ROS_DISTRO=indigo ROS_ETC_DIR=/opt/ros/indigo/etc/ros It is right.

Comment by alee on 2016-05-21:
It's hard to tell what's wrong without more information and the rosserial package doesnt have the best error statements...last thing I can think of is permissions to the port you're using

Comment by john_gao on 2016-05-23:
Thank Alee, I had set the port commission,so I can load the code to arduino Yun in no problem. The only things I think could be issue is I had followed the document but which install latest code, then I change to load the indigo part, I don't know any temp file or something is missing there,


2 Answers 2


Rosanswers logo

You can also define the node handle in your code using NodeHandle_, which avoids the need to edit rosserial code:

ros::NodeHandle_<ArduinoHardware, 5, 5, 125, 125> nh;

Be aware, though, that rosserial on a ~2 kbyte Arduino can easily get a corrupted stack/heap if you're not careful, and it can be unstable in mysterious ways. I've had issues with around 600 or fewer bytes free RAM. (In fact, it's been frustrating enough that I've abandoned rosserial in favor of ros_arduino_bridge.)

If possible, switching to a Mega or Teensy would be more stable.

Originally posted by Mark Rose with karma: 1563 on 2016-08-02

This answer was ACCEPTED on the original site

Post score: 2


Rosanswers logo

The standard settings use lots of RAM. If you edit ros_lib/ros.h (or ros_lib/ros/node_handle.h) you can change

  typedef NodeHandle_<ArduinoHardware> NodeHandle;


On the pubsub.ino example, the default of <6,6,512,512> which uses 2.0K of dynamic memory (of the 2.5K available on my Atmega32U4) and isn't stable, as the OP mentioned. I changed it to use <2,2,100,100> which uses 1.1K of dynamic memory. Haven't tested it extensively yet, so may need to tune the buffers, but I don't need more than 2 subscribers or publishers (yet).

Originally posted by KevinNickels with karma: 23 on 2016-07-13

This answer was NOT ACCEPTED on the original site

Post score: 1


Your Answer

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