Ask Your Question
3

roslaunch stop if yaml doesn't exists

asked 2016-06-03 06:26:06 -0600

pmarinplaza gravatar image

updated 2016-06-03 08:37:09 -0600

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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2016-06-03 09:26:56 -0600

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)">
         <rosparam command="load" file="$(find webserver_client)/config/vehicle_id.yaml"/>
     </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.

You can find more info on that here

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

and here

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

Regards,

Mario

edit flag offensive delete link more

Comments

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.

pmarinplaza gravatar imagepmarinplaza ( 2016-06-06 07:00:38 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-06-03 06:26:06 -0600

Seen: 1,009 times

Last updated: Jun 03 '16