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

rosserial too big for Arduino

asked 2015-12-22 07:06:04 -0500

Mehdi. gravatar image

I am trying to add a magnetometer to my robot by plugging it into an Arduino and publishing the data using MagneticField message. I can't compile my code for Arduino Uno or Leonardo while at the same time using the Adafruit Magnetometer driver . I end up with this error message:

Global variables use 2,675 bytes (104%) of dynamic memory, leaving -115 bytes for local variables. Maximum is 2,560 bytes.

I only defined the necessary variables as globel (ros handle, publisher, message to publish and sensorlib instance). Did anybody figure out a way to work with such sensors on an Arduino and publishing their data using ROS?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2017-01-25 18:22:13 -0500

lordricky gravatar image

Late response, but I guess this is a common problem. This solved my problem:

Basically you can change the assigned buffer for serial communication by limiting the number of publishers/subscribers and also their length.

edit flag offensive delete link more

answered 2015-12-22 08:58:04 -0500

fsteinhardt gravatar image

You can write your Arduino software without using rosserial, instead write a minimal serial protocol that is small enough to fit into your arduino memory. Then you need an additional receiver-node on the ROS side, it receives the data over this minimal serial protocol and can construct a big nice standard ROS message out of it.

edit flag offensive delete link more



That is what I just did, parsing strings containing my values that Arduino sends through serial. But what is the point of rosserial-arduino then?

Mehdi. gravatar image Mehdi.  ( 2015-12-22 09:36:28 -0500 )edit

How big is your library?

NEngelhard gravatar image NEngelhard  ( 2015-12-25 12:39:45 -0500 )edit

Declaring a node handle and a subscriber makes my binary just few bytes smaller than the limit of 2500 bytes. Then adding the 300 bytes magnetometer lib makes it slightly larger (104%). This would work with bigger arduino boards though, like the Due

Mehdi. gravatar image Mehdi.  ( 2015-12-26 07:09:46 -0500 )edit

Question Tools

1 follower


Asked: 2015-12-22 07:06:04 -0500

Seen: 2,201 times

Last updated: Jan 25 '17