0
$\begingroup$

Rosanswers logo

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


Originally posted by mdturner32 on ROS Answers with karma: 3 on 2018-01-22

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by billy with karma: 1850 on 2018-01-24

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by mdturner32 on 2018-01-26:
how do you ensure that the COMPORT response is sent back to the original caller of the function?

Comment by billy on 2018-01-26:
See the edit in the answer

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.