Ask Your Question

rosserial_arduino best practice for messages [closed]

asked 2020-03-26 13:16:18 -0500

PaddyCube gravatar image

Hi there,

I plan to bring my Arduino robot to ROS and I'm curious about the best was to send sensor messages, error codes and events. My plan is to use cmd_vel messages to drive around which is straight forward.

But what is the best way to send data back to ROS? How to raise bumper events, sonar, IMU and odometry data? I plan to stream raw data for odometry and so on and do the calculation in a ros node to translate the raw data into default ros nodes.

  • So is it best to send a complex message containing all sensor values (approx 30 different values) every 100ms?
  • or is it better to use smaller messages (one for odometry, one for sonar etc.) and send them every 100ms or if needed?
  • is it good practice to raise events (bumper hit, battery event etc.) by a single message or should I create multiple event messages, one for each event?

As Arduino (Mega) only provides a few kB of storage and is slow I'm curious if it can handle large messages or a lot of small messages reliable.

I've looked to so many tutorials but didn't find a more complex one.

Any hints on how I should set it up?


edit retag flag offensive reopen merge delete

Closed for the following reason too subjective or argumentative by PaddyCube
close date 2021-01-06 13:09:55.245686

1 Answer

Sort by ยป oldest newest most voted

answered 2021-01-06 13:09:21 -0500

PaddyCube gravatar image

I answer myself just as reference for others searching for the same. I found it hard to find reference to a real robot, most people seems to use simulations only or just keep firmware things secret

I came to the conclusion not to use rosserial for Arduino as even on Arduino Mega, it consumes too much of the limited RAM. Instead, I use my own proprietary message format which has mostly no overhead. The Arduino is connected to a Raspberry PI running a ROS node (i call it driver), which reads all incoming messages and translate them to custom ROS messages. This driver also writes data back to Arduino (like motor commands) with my own data format.

This seems to work somewhat reliable. Also, at Arduino side, I send often needed data (like Odometry, IMU) as a continuous stream (every 100ms). Other, rarely needed data (overall system status like battery voltage) will only be send, if ROS node (driver) asks for (every 10 seconds).

Any event (bumper hit, drop sensor, overload of motors) will only gets send by Arduino, if they occur.

The ROS node (driver) itself will publish my custom messages. This way I have raw data of Arduino availabe as topics for further processing. Another ROs node, I call it base_controller, subscribes to my custom messages and translate (publish) them to ROS standard messages (/odom, /tf and so on). Also it has a subscriber to cmd_vel and set desired speed to driver via a ROS service provided by driver.

edit flag offensive delete link more

Question Tools



Asked: 2020-03-26 13:16:18 -0500

Seen: 85 times

Last updated: Jan 06