Ask Your Question
0

merging of launch files

asked 2018-08-31 18:16:01 -0600

debonair gravatar image

updated 2018-09-04 12:13:15 -0600

I have 2 launch files which are launching same node but one launches with namespace and other with no namespace. how do I combine both of them? is it possible to make namespace argument optional ?

launch_file1 :

<node pkg="node_pkg" type="node_type" name="node_name" >

launch_file2:

<node pkg="node_pkg" type="node_type" name="node_name" args="load pkg_name/classname" ns="$(arg namespace)">

so i am launching same node with no_namespace and with namespace.

<node pkg="node_pkg" type="node_type" name="node_name"   if="$(arg use_namespace)" ns="$(arg namespace)">

so i combined both launch files with above line in one single launch file. and i am using use_namespace to specify whether i want to launch node with namespace or not. but now it is launching nodes with onyl namespace my understanding from above line is just use ns if, "if" condition is satisfied and launch it with <node pkg="node_pkg" type="node_type" name="node_name"

edit retag flag offensive close merge delete

Comments

It is not clear what you want to achieve. Do you want your nodes to be in the same namespace/no namespace? Namespace is an optional attribute. If @gvdhoorn 's answer is what you were looking for accept it, otherwise elaborate on "combine".

Reamees gravatar imageReamees ( 2018-09-03 04:05:27 -0600 )edit

1 Answer

Sort by » oldest newest most voted
3

answered 2018-09-01 01:49:46 -0600

gvdhoorn gravatar image

Namespace attributes cannot be empty, so it's not directly possible to make something like that optional I believe.

Something like this might work:

  • first launch file:

    <launch>
      <arg name="use_namespace" default="false" />
      <include file="other.launch"     if="$(arg use_namespace)" ns="my_ns" />
      <include file="other.launch" unless="$(arg use_namespace)" />
    </launch>
    
  • second launch file (just an example):

    <launch>
      <param name="la" value="123" />
    </launch>
    
edit flag offensive delete link more

Comments

what should be my other.launch file contain? just launch node? and we don't specify namespace there?

debonair gravatar imagedebonair ( 2018-09-04 11:49:28 -0600 )edit

what should be my other.launch file contain? just launch node?

whatever you want it to contain. Could launch nodes, include other launch files, everything.

and we don't specify namespace there?

Exactly.

the first launch file essentially "pushes" the other launch file down into a ns.

gvdhoorn gravatar imagegvdhoorn ( 2018-09-04 12:00:46 -0600 )edit

is it possible to combine include code with if condition in your answer.

debonair gravatar imagedebonair ( 2018-09-04 12:18:55 -0600 )edit

I had to write node launch code <node pkg> with params twice. one with if tag and one with unless tag. i was trying to find out way to avoid writing params twice.

debonair gravatar imagedebonair ( 2018-09-04 12:31:23 -0600 )edit
1

Which you can do, if you follow my approach.

The "second launch file" has all the nodes without a ns. If you start that, nothing will be in a namespace.

The "first launch file" starts the second but in a namespace. Don't start the second launch file: no namespace.

No need to duplicate.

gvdhoorn gravatar imagegvdhoorn ( 2018-09-04 12:33:07 -0600 )edit

great. Thanks so much!

debonair gravatar imagedebonair ( 2018-09-04 13:15:55 -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

2 followers

Stats

Asked: 2018-08-31 18:16:01 -0600

Seen: 144 times

Last updated: Sep 04 '18