Robotics StackExchange | Archived questions

Issue in communicating with multiple robots using rosserial_xbee

Hi,

I have 10 robots - all with an xbee end device and an xbee coordinator to which they all connect. I calculate velocity commands for each of the robots and publish the cmdvel to 10 different topics, 1 for each robot to which they subscribe. This seems to be overloading the communication resulting in delayed command reception/ packet drop. Are there rosmessages that I can use where only one publisher can publish all the velocity commands for all the bots on one topic to which all the robots subscribe and receive the commands?

Asked by robot_probot on 2018-10-01 13:41:24 UTC

Comments

Answers

The twist messages used by cmd_vel contain 6 DOF information, if you're controlling turtle bots for example then you only need two of these six values. A quick and dirty way of doing this would be to use the Float32MultiArray message, with 20 elements.

Consecutive pairs of elements could encode the linear x veloccity and angular z velocity for each robot using a single message which is also a third of the size of the original ten cmd_vel messages.

The longer and more correct way of doing this would be to create a custom message type, possibly using int16 values in mm to save even more space. However I would recommend implementing the quicker version first to see if it solves your problem.

Hope this helps.

Asked by PeteBlackerThe3rd on 2018-10-02 07:16:52 UTC

Comments

@PeteBlackerThe3rd, I agree with FloatMultiArray & it would still take more space than required. So I made a custom message with two float arrays with 10 elements each, the bot receive the whole msg and use the values indexed by bot IDs in both arrays. This overflows my serial buffer though.

Asked by robot_probot on 2018-10-02 10:57:57 UTC

Message from ROS network dropped: message larger than buffer is the error I get.

Asked by robot_probot on 2018-10-02 10:58:36 UTC

I'd recommend doing an experiment changing the size of the float arrays so you can find the limit of the buffer size, then decide what to do based on that

Asked by PeteBlackerThe3rd on 2018-10-02 11:03:21 UTC

Sorry, I edited the comment

Asked by robot_probot on 2018-10-02 11:03:31 UTC

If you want to be as space efficient as possible, try a custom message with 20 individual int16 values. An array has to store its length as well as the content so takes up more space even though it's tidier.

Asked by PeteBlackerThe3rd on 2018-10-02 11:13:25 UTC

Thanks, now, the array with 20 elements is working fine without buffer overflow. However I still see that not all robots get their commands. Since the robots are mobile, I don't have a feedback of what command are they receiving. But, from observation, they dont seem to be getting the right commands

Asked by robot_probot on 2018-10-02 19:48:27 UTC

Can that be because of multiple subscribers subscribing to the same topic with just 1 publisher? If one of the bots reads the message, will that stop the other subscribers from servicing the callback?

Asked by robot_probot on 2018-10-02 19:49:54 UTC

No. ROS topics are one-to-many. However there is no guaranteed delivery in the protocol, in fact it's designed to drop messages when the network capacity is reached. If your network is that constrained it may be worth looking into a more efficient, lower level, non-ROS solution.

Asked by PeteBlackerThe3rd on 2018-10-02 19:56:29 UTC

So you’d suggest looking into serial communication using cpp/python libraries instead of ROS for a reliable network? I am still hoping if there’s a ROS based solution, since integration is easier with multiple robots.

Asked by robot_probot on 2018-10-03 00:20:38 UTC

If using an array of Int16 still results in dropped messages, then the only other option is reducing the frequency that cmd_vel is published at if you can.

Asked by PeteBlackerThe3rd on 2018-10-03 04:11:05 UTC