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

Problem setting up rosserial_arduino

asked 2011-09-08 21:35:28 -0500

Per Lenander gravatar image

updated 2011-09-08 23:00:44 -0500

Hello!

I am working on a project using ROS, and I want to integrate external hardware using an Arduino. So I thought that using the rosserial_arduino library would work wonders... I ran into trouble however.

The arduino running the basic hello world code does not seem to be sending any serial data. The receiving python node never seems to connect, and if you bring up the internal serial monitor in the arduino IDE no data is sent from the board. Running nh.initNode() seems to kill all serial communication. If I comment that line and use Serial.begin(...) in setup and Serial.print(...) in the loop everything still works. I've been working on this for two days now and is just about ready to give up and use another frontend on the computer and write my own communication using the Serial commands...

I use Ubuntu 11.04 (Natty), ros-electric from the repos, ros-electric-rosserial from the repos and arduino from the repos. I have also tried rosserial from hg, but the result is the same. I have a Duemilanove 168. I have tried on several computers with the same setup, and on two different arduinos.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2011-09-09 08:48:28 -0500

fergs gravatar image

updated 2011-09-09 08:49:54 -0500

So, it would appear that we're just using too much RAM for the 168:

$ avr-size HelloWorld.cpp.elf
text       data     bss     dec     hex filename
5132        144    1345    6621    19dd HelloWorld.cpp.elf

The ATMEGA168 has only 1K of SRAM, but our bss and data is about 1.5k.

You could do the following:

  • checkout from hg, build and copy to your libraries directory as usual.
  • edit line 48 of your <sketchbook>/libraries/ros_lib/ros.h to read:

    typedef NodeHandle_<ArduinoHardware, 5, 5, 100, 100> NodeHandle;

When I did this, I had the following for size:

avr-size HelloWorld.cpp.elf
text       data     bss     dec     hex filename
5120        144     441    5705    1649 HelloWorld.cpp.elf

This will limit you to only 5 publishers, 5 subscribers, and messages must be <100 bytes long. The buffers we maintain use a lot of memory since many messages can get quite large.

Please let me know if this does solve your problem, if it does, I'll get a tutorial up on ros.org so that others can tune the performance of rosserial to their hardware.

edit flag offensive delete link more

Comments

Thanks! I will try this and see if it works. Additionally, we are receiving an Arduino Mega (Atmega 128) pretty soon, so the basic example should work without problems. I will get back to you on this!
Per Lenander gravatar image Per Lenander  ( 2011-09-21 22:55:38 -0500 )edit
It worked without problems!
Per Lenander gravatar image Per Lenander  ( 2011-09-21 23:39:25 -0500 )edit

I'd really appreciate the tutorial you were talking about @Per Lenander

rflmota gravatar image rflmota  ( 2014-09-04 10:52:48 -0500 )edit

@fergs, please see this I tried all solutions, nothing worked. I am running this on a RasPi with Groovy. I only face this issue on my RasPi. When I use Indigo on Ubuntu Trusty, it works without any hassle.

Nightstalker gravatar image Nightstalker  ( 2014-09-23 03:49:09 -0500 )edit

Could you provide the tutorial you were talking about on tuning the performance of rosserial - @fergs ?

I'm having some similar issues... Should I increase or decrease the buffer size on ros.h?

rflmota gravatar image rflmota  ( 2014-10-13 17:55:40 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2011-09-08 21:35:28 -0500

Seen: 2,482 times

Last updated: Sep 09 '11