# rosserial - arduino - custom message - message larger than buffer

Hey guys,

I wrote a custom message which looks like:

geometry_msgs/Vector3[] data


so i got an array of Vector3()'s. I can use this message, echo it, etc... So I am assuming that everything worked fine here.

Now I am using an Arduino Mega to subscribe this message. Which seems to work to. But I got the following problem:

I am publishing a message which contains out of 14 Vector3()'s and I am getting this error:

[ERROR] [WallTime: 1430219046.856917] Message from ROS network dropped: message larger than buffer.


If I publish a message which contains out of 4 Vector3()'s everything works fine. Is this message really too big? Shoudnt it be something like 14 (entries in the array) * 8 (Float64) * 3 (three points for each vector) = 336 Bytes? Is this really too much for the Arduino?...

I found out that I have to change the buffer as descriped here http://wiki.ros.org/rosserial/Overvie... .

typedef NodeHandle_<ArduinoHardware, 25, 25, 1024, 256> NodeHandle;


I dont get the error anymore, but if I echo the topic /Test (see in the code below) I dont see any value (at least for 14 entries in the message. For 4 Values it works perfectly fine!). The Publisher for /Test is made, so that I can see if the message gets transferred correctly.

So though I set the buffer up to 1024 Bytes

[INFO] [WallTime: 1430223859.870142] Note: subscribe buffer size is 1024 bytes


the message is not transferred correctly.

Any ideas how to solve this problem? Thanks alot in advance!

P.S.: My general goal is to send speed information for two stepper motors and a information about the time to the arduino. So each vector looks smth like: (v1 , v2 , t). And i got - at the moment - 14 of them. There might be more in the future!

In case that there is a more handy solution for this, feel free to suggest.

[EDIT]

Actually I tried many Vector3()'s can be in the array, so that the message will be transferred correctly. As chance would have it I only can transfer 4 Vector3()'s in the array... That would only be 4 * 8 * 3 = 96 Bytes right? :0

// einbinden der Bibliotheken
#include <AccelStepper.h>
#include <ros.h>
#include <vector_3_array/Vector3DArray.h>
#include <geometry_msgs/Vector3.h>
#include <std_msgs/Float32.h>
#include <std_msgs/Bool.h>

ros::NodeHandle nh;
std_msgs::Float32 test;
ros::Publisher testpub("Test", &test);

// Interface, PIN1, PIN2
AccelStepper stepper_rot(1, 9, 8);
AccelStepper stepper_lin(1, 3, 2);

void stelldaten_transformation( const vector_3_array::Vector3DArray& vectordaten_tabelle)
{
test.data = vectordaten_tabelle.data[3].x;
testpub.publish( &test);

test.data = vectordaten_tabelle.data[3].y;
testpub.publish( &test);

test.data = vectordaten_tabelle.data[3].z;
testpub.publish( &test);

}

void subscribetest( const std_msgs::Bool& boolee)
{
test.data = 10.1;
testpub.publish( &test);
}

//Initialisieren der ROS Messages
ros::Subscriber<vector_3_array::Vector3DArray> vectordaten("Stelldaten", &stelldaten_transformation);
ros::Subscriber<std_msgs::Bool> booleantest("Boolean", &subscribetest);

void setup()
{
//stepper.setSpeed(4000);
nh.initNode();
nh.subscribe(vectordaten);
nh.subscribe(booleantest);
}

void loop ...
edit retag close merge delete

Sort by » oldest newest most voted

Not sure but try to change:

typedef NodeHandle_<ArduinoHardware, 25, 25, 1024, 256> NodeHandle;


to:

typedef NodeHandle_<ArduinoHardware, 25, 25, 1024, 1024> NodeHandle;


The first two arguments are the max subscribers and publisher, the last two the input and output buffer.

Furthermore I suggest you to write simpler test for debug: on your code you publish a topic based on received message: if something is not working is quite hard to understand if problem is on publishing or subscribing. Try to test a simple subscriber and test it; after a publisher test and, if all is fine, try to put them together.

## UPDATE

Do you declare the array size in your message definition? To be more clear: are you using

float[] x


or

float[3] x


?

If you are using the first one you must specify the length in the message (look at generated message class: you will find a length field in the code).

If this not help please follow my suggestion and test subscriber and publisher separately.

more

Thanks for your help, I tryed both of your suggestions! especially the typedef NodeHandle_<ArduinoHardware, 25, 25, 1024, 1024> NodeHandle; did not change anything. I'm trying to get the stuff done with Float32[] - Arrays, to avoid the vector() data types.

( 2015-04-29 03:12:40 -0600 )edit

I made it work with 3 Float32Array() instead of 1 Vector3() Array. Ill accept your answer, though the original question might not be answered. Btw i tryed subscriber and publisher seperately and the subscriber did not work. Thanks anyways, i really appreciate your effort :)!

( 2015-04-29 07:14:25 -0600 )edit