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

How to debug rosserial-arduino?

asked 2016-04-29 00:34:48 -0600

john_gao gravatar image

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... and then follow http://answers.ros.org/question/19620... 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

edit retag flag offensive close merge delete

Comments

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

alee gravatar image alee  ( 2016-05-12 11:09:35 -0600 )edit

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.

john_gao gravatar image john_gao  ( 2016-05-12 16:21:55 -0600 )edit

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

alee gravatar image alee  ( 2016-05-12 16:59:38 -0600 )edit

Could you tell me the detail? From the sample code, this is hidden. If I want to reduce it, what should I do? Thanks

john_gao gravatar image john_gao  ( 2016-05-12 17:46:43 -0600 )edit

nh.getHardware()->setBaud(//some baud rate);

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

alee gravatar image alee  ( 2016-05-12 23:58:55 -0600 )edit

Dear alee, it still does not work, even I drop both to 9600. I follow in http://wiki.ros.org/rosserial_arduino... 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,

john_gao gravatar image john_gao  ( 2016-05-15 19:54:59 -0600 )edit

What distro of ROS are you on? If you ran make_libraries with the wrong version of ROS, it might cause issues.

alee gravatar image alee  ( 2016-05-16 12:02:20 -0600 )edit

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.

john_gao gravatar image john_gao  ( 2016-05-17 22:40:16 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
2

answered 2016-08-02 20:08:55 -0600

Mark Rose gravatar image

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.

edit flag offensive delete link more
1

answered 2016-07-13 17:55:30 -0600

KevinNickels gravatar image

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;

to what you want the MAX_SUBSCRIBERS, MAX_PUBLISHERS, INPUT_SIZE, and OUTPUT_SIZE to be.

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).

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-04-29 00:26:59 -0600

Seen: 1,521 times

Last updated: Aug 02 '16