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

How to kill nodes in launch file after 10 seconds

asked 2021-08-10 08:05:44 -0500

nayan gravatar image

Hello!

I am launching 7 ROS nodes using a single launch file. Can I kill all nodes after 10 seconds (or x seconds) without doing ctrl+c? I am using C++ btw.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2021-08-10 09:35:52 -0500

nayan gravatar image

Thanks @gvdhoorn !

This is my bash script (runtime_benchmark.sh) if anyone is wondering:

#!/bin/bash

sleep 15

echo "Killing all nodes"

rosnode kill -a

And this is the part in the launch file:

    <node name="runtime_benchmark" pkg="kinect_pcl" type="runtime_benchmark.sh" />
edit flag offensive delete link more
1

answered 2021-08-10 08:13:55 -0500

gvdhoorn gravatar image

updated 2021-08-10 08:40:26 -0500

No, not without writing a custom node/script.


Edit:

Hi! Do you mean I have to write a custom node/script that kills all the nodes I launched using a single launch file? Or do you mean I have to kill all the nodes individually in their scripts after x seconds? How do I do this?

I'm saying roslaunch does not have built-in support to "kill all nodes after 10 seconds (or x seconds)".

One way to achieve what you're after would be to write a script which uses rosnode kill on all the nodes you'd like it to kill. Could be a Bash script fi. Or something more complex.

Then start that script as part of your .launch file.

edit flag offensive delete link more

Comments

Hi! Do you mean I have to write a custom node/script that kills all the nodes I launched using a single launch file? Or do you mean I have to kill all the nodes individually in their scripts after x seconds? How do I do this?

nayan gravatar image nayan  ( 2021-08-10 08:18:44 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2021-08-10 08:05:44 -0500

Seen: 806 times

Last updated: Aug 10 '21