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

Run ros2 node using launch file with delay

asked 2021-09-24 06:46:21 -0500

definitive gravatar image

Let's suppose we want to have a single launch file for our project. Some of our nodes are just sensor handlers. Moreover, sensor need some time to return proper data. The idea is to put some delay before running main node to use only correct data. Does launch files design provides some way to put delay on node? Of course we can put delay directly in Node constructor or process data to wait for proper values but this functionality may be useful as a parameter in launch file.

edit retag flag offensive close merge delete

Comments

Shouldn't deterministic system initialisation and startup be achieved by using managed nodes with a lifecycle? Time-based coordination doesn't really work very well. State-based will be much more reliable.

gvdhoorn gravatar image gvdhoorn  ( 2021-09-24 07:24:55 -0500 )edit
2

To re-enforce what @gvdhoorn is saying: you don't want to design a ros system with startup order dependencies. That is unreliable, and makes restarting individual nodes difficult. Almost always a node should wait to see a particular message published (e.g Sensor data or Transform Frame or some state message), so it knows it is OK to proceed.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-09-25 10:03:27 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-10-12 08:38:56 -0500

ChuiV gravatar image

As others have mentioned above, starting nodes in this way isn't really recommended....

However, to answer your question, you're looking for the TimerAction. It's a one-shot timer, that you can use for something like this:

from launch.actions import TimerAction
...
TimerAction(period=60.0,
            actions=[Node(...), Node(...)]),

If you're really wanting to handle this in launch, again not recommended, you could make a custom action that subscribes to you sensor data, and when it receives valid data to start a list of Actions.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2021-09-24 06:46:21 -0500

Seen: 4,112 times

Last updated: Oct 12 '21