Robotics StackExchange | Archived questions

Setting delay between nodes in a launch file

Hello everybody.

I am working on a project where i have 2 USB devices connected to my pc. The manufacturer provided the ros nodes to make a connection with the devices.

Now, the problem is: When i start both nodes in a launch file, one of them fails and gives me this message:

serial.serialutil.SerialException: device reports readiness to read but returned no data (device disconnected or multiple access on port?)

I already found a way to fix this: i have to start node 1, wait for it to start up, which takes about 2 or 3 seconds, then start the second node. Now i've looked around and noticed there is not really a standard way to add a 'delay' or a 'sleep' in a launch file. I came across this question: https://answers.ros.org/question/233353/set-delay-between-starting-nodes-within-launch-file/ Here they made a workaround for this issue, but this is from 3 years ago.

I wonder there is a better/cleaner way to do this three years after that solution.

So i'm looking for this:

delay of 3 seconds

Note: node 1 is in c++ and node 2 in python, don't know if this will make a difference.

Kind regards, Jan Tromp

I am working with: ros kinetic Ubuntu 16.04

Asked by Jan Tromp on 2019-05-09 02:21:14 UTC

Comments

Did you see the other 2 answers (not the accepted one) to the question you linked? Especially the one by kushlik. Other than that you could put a waitForService/waitFor in the constructor of node 2 before that exception is triggered.

Asked by aPonza on 2019-05-09 04:36:21 UTC

Time-based control flow is definitely something that is possible, but I'm not sure why two nodes, communicating with different USB devices would have to be started in a staggered manner to avoid serial problems.

If they're not sharing devices, wouldn't the fact that you can't start them simultaneously point to an implementation problem in those nodes (ie: a bug or incorrect design)?

Asked by gvdhoorn on 2019-05-09 04:58:35 UTC

Answers