Add waitfile script to wait for a file before starting a node

This commit is contained in:
Oleg Kalachev
2021-05-14 12:05:23 +03:00
parent dbd9a4a238
commit 261faaec0e
2 changed files with 10 additions and 1 deletions

View File

@@ -8,7 +8,7 @@
<arg name="distance_sensor_remap" default="rangefinder/range"/>
<arg name="usb_device" default="/dev/px4fmu"/>
<arg name="prefix" default="" unless="$(eval fcu_conn == 'usb')"/>
<arg name="prefix" default="bash -c 'while [ ! -e $(arg usb_device) ]; do sleep 1; done; $0 $@'" if="$(eval fcu_conn == 'usb')"/>
<arg name="prefix" default="rosrun clover waitfile $(arg usb_device)"/>
<node pkg="mavros" type="mavros_node" name="mavros" launch-prefix="$(arg prefix)" required="false" clear_params="true" respawn="$(arg respawn)" unless="$(eval fcu_conn == 'none')" respawn_delay="1" output="screen">
<!-- UART connection -->

9
clover/src/waitfile Executable file
View File

@@ -0,0 +1,9 @@
#!/usr/bin/env bash
# $ ./waitfile <file> <command> <args...>
# wait until <file> appears and then invoke <command> with <args>
echo "wait for file $1 to ${@:2}"
while [ ! -e "$1" ]; do sleep 1; done;
echo "file $1 appeared, run ${@:2}"
"${@:2}"