[Solved] Issue with checksums when using custom message and rosserial
I'm attempting to create a custom message and transmit it to an Arduino, as per the rosserialclient tutorials. I've generated my message headers by running the "make libraries" command in the rosserialclient, and I am able to compile/upload a sketch in the Arduino IDE using my custom message. However, the serial_node crashes with this error:
rosout: Creation of subscriber failed: Checksum does not match: 583de20b25dc989387bf70bf9589bcbe,583de20b25dc989387bf70bf9589bcbecustommessagepackage_msgs/CustomMessage
It would appear that the message type is getting appended to the checksum. I'm running Ros Noetic, this error occurs when using the rosserial binaries and when building from source. Has anybody seen this issue before, and is there a solution for this?
Asked by Schteve-earl on 2022-07-11 09:19:31 UTC
Answers
I switched from using an Arduino Uno to an Arduino Mega, and the situation resolved itself. I encountered the same error when using std_msgs::Float32MultiArray and the Arduino compiler gave me a warning stating that I was using 85% of the Uno's dynamic memory. So, as of now, the working solution is to get a board with more horsepower if you receive this error.
Asked by Schteve-earl on 2022-07-11 12:59:59 UTC
Comments
In my experience, using any variable-size arrays for arduino messages can lead to problems. It seems that when generated, these headers contain realloc() calls and do not check them for failure. For example, std_msgs::Float32MultiArray has
this->data = (float*)realloc(this->data, data_lengthT * sizeof(float));
which could, theoretically, return a null pointer if there is not enough memory left to realloc successfully. 85% of arduino memory is usually cutting it close to when some dynamic allocation calls can break the limit. When I changed std_msgs::Float32MultiArray to a custom message with fixed-size variables, weird problems went away.
Also, it is probably possible for a bunch of such allocations from different callbacks to eventually fragment the available memory into unusable small chunks, so the memory failures can appear after some time or when a lot of messages were passed via the topic.
Asked by Maxim Rovbo on 2022-11-09 06:11:45 UTC
Comments