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

RS232 Queue System in ROS

asked 2018-01-22 21:34:37 -0500

mdturner32 gravatar image

Using ROS Kinetic and primarily python. I have a driver that subscribes to several topics including /cmd_vel and a bunch of other commands which interact with a control board via RS232.

One problem I have is if multiple commands are sent at the same time, it can break the communication stream (two messages sent/received at the same time in the buffer).

I fixed it by adding a “busy” boolean state, but this only works for 2 function (i.e. when one function runs, boolean state busy = TRUE, so the other function does not run and waits for busy = FALSE. however, when there a 3 functions, 2 of them are waiting and can sometimes trigger at the same instead of busy =FALSE)

In ROS is there a way to QUEUE function calls that are initiated by subcribers? for example if I have 5 subscribers each being triggered at a defined rate, how do I queue these commands so the RS232 communication with the control board is done one-at-a-time

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2018-01-24 02:30:13 -0500

billy gravatar image

updated 2018-01-26 11:46:32 -0500

I do this by using a ros-topic that several nodes will publish to asynchronously, and there is a single node that subscribes to the topic and handles all outbound comport messages. Never had any issue with the approach of using this topic as the queue.

EDIT: 1/26/18 I have another node that handles all incoming comport messages and sends data to appropriate topics. I have laser scan data coming in on the comport and I interleave data packets for all other sensors and state feedback into that data stream. Each data packet has a 1 byte header that indicates what type of info is in the packet. The node for incoming data decodes the data the publishes to the topic needed. If your nodes needs to get a response from the comport prior to continuing, it can wait on a topic instead of the comport. In my case I have laser data, IMU, ODOM, bumpers, and robot state all coming in on one comport with state control and motor commands going out, but a 75mS delay waiting for the next scheduled robot state packet doesn't cause me any grief. Of course this only works if you can tolerate the delay.

edit flag offensive delete link more


how do you ensure that the COMPORT response is sent back to the original caller of the function?

mdturner32 gravatar image mdturner32  ( 2018-01-26 01:06:46 -0500 )edit

See the edit in the answer

billy gravatar image billy  ( 2018-01-26 11:46:43 -0500 )edit

answered 2018-01-22 23:48:45 -0500

0xd1ma gravatar image

updated 2018-01-22 23:49:18 -0500

you should enter an intermediate data storage structure (array, dictionary, etc.) between subscribers and RS232. subscribers add information to the storage structure. the other essence of the program periodically reads the storage structure and if the information is updated there, it sequentially withdraws it and sends it to the RS232.

edit flag offensive delete link more


that sounds like what i'm looking for.

If i have a bunch of subcribers, whose callbacks result in population of this array however... how do i ensure that this additional "queue handling software" sends back the corresponding RS232 / SERIAL data to the appropriate caller?

mdturner32 gravatar image mdturner32  ( 2018-01-26 01:08:09 -0500 )edit

Question Tools

1 follower


Asked: 2018-01-22 21:34:37 -0500

Seen: 244 times

Last updated: Jan 26 '18