# roslaunch stop if yaml doesn't exists

Hi,

I am working on autonomous cars and I need a specific performance of roslaunch. I am working with a webserver and I need to know if a vehicle exists in the webserver. In this case I write a yaml file to save the vehicle_ID and continue working. Afterwards, I reset everything and roslaunch again the file. If the vehicle_id.yaml file exists, I load over roslaunch with rosparam command "load"

My problem is that if the vehicle_id.yaml doesn't exists, roslaunch give me an error and stop the whole roslaunch.

This is my roslaunch:

<launch>
<rosparam command="load" file="$(find webserver_client)/config/vehicle_id.yaml"/> <node name="webserver_client" pkg="webserver_client" type="webserver_client" output="screen"/> </launch>  Is there a possibility to ask if the yaml file exists and if not, don't load the parameters? edit retag close merge delete ## 1 Answer Sort by » oldest newest most voted As far as I know, you can not do this directly in the roslaunch. However, you can add an <arg> tag to the ros launch, and then use the <if> and/or <unless> attributes to either read or not the .yaml file Should be something like this: <launch> <!-- ros_args --> <arg name="foo" default="true"/> <group if="$(arg foo)">
</group>
<node name="webserver_client" pkg="webserver_client" type="webserver_client" output="screen"/>
</launch>


Then you can pass the argument to the roslaunch from command line after checking whether or not the file exists.

http://wiki.ros.org/roslaunch/XML/arg

and here

http://wiki.ros.org/roslaunch/Command...

Regards,

Mario

more

Thank you for your answer. I solve it directly with a fake vehicle_id.yaml that always has to be there and then if there is "empty" message, I overwrite it with the correct id. I appreciate your help.

( 2016-06-06 07:00:38 -0500 )edit