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

Revision history [back]

click to hide/show revision 1
initial version

As aconkey said giving an empty string from the command line does not seem to work. I'm not sure this is the cleanest solution, but you could hack together the desired behavior to some extent with eval and an intermediate argument. Something like this:

<launch>
    <arg name="helper_arg"      default="some_value"/>
    <arg name="some_arg"        default="$(eval '' if (helper_arg == '!') else helper_arg)"/>

    <include file="$(find pkg)/launch/$(arg some_arg)_node.launch">
    </include>
</launch>

-

roslaunch pkg default.launch helper_arg:="!"

some_arg will evaluate to "" and will try to launch pkg/launch/_node.launch

roslaunch pkg default.launch helper_arg:="default"

some_arg will evaluate to "default" and will try to launch pkg/launch/default_node.launch

As aconkey said giving an empty string from the command line does not seem to work. I'm not sure this is the cleanest solution, but you could hack together the desired behavior to some extent with eval and an intermediate argument. Something like this:

<launch>
    <arg name="helper_arg" name="some_arg"      default="some_value"/>
    <arg name="some_arg"     name="helper_arg"    default="$(eval '' if (helper_arg (some_arg == '!') else helper_arg)"/>
some_arg)"/>

    <include file="$(find pkg)/launch/$(arg some_arg)_node.launch">
helper_arg)_node.launch">
    </include>
</launch>

-

roslaunch pkg default.launch helper_arg:="!"
some_arg:="!"

some_arg will evaluate to "" and will try to launch pkg/launch/_node.launch

roslaunch pkg default.launch helper_arg:="default"
some_arg:="default"

some_arg will evaluate to "default" and will try to launch pkg/launch/default_node.launch

As aconkey said giving an empty string from the command line does not seem to work. I'm not sure this is the cleanest solution, but you could hack together the desired behavior to some extent with eval and an intermediate argument. Something like this:

<launch>
    <arg name="some_arg"      default="some_value"/>
    <arg name="helper_arg"    default="$(eval '' if (some_arg == '!') else some_arg)"/>

    <include file="$(find pkg)/launch/$(arg helper_arg)_node.launch">
    </include>
</launch>

-

roslaunch pkg default.launch some_arg:="!"

some_arg helper_arg will evaluate to "" and will try to launch pkg/launch/_node.launch

roslaunch pkg default.launch some_arg:="default"

some_arg helper_arg will evaluate to "default" and will try to launch pkg/launch/default_node.launch

As aconkey said giving an empty string from the command line does not seem to work. I'm not sure this is the cleanest solution, but you could hack together the desired behavior to some extent with eval and an intermediate argument. Something like this:

<launch>
    <arg name="some_arg" name="arg1"      default="some_value"/>
    <arg name="helper_arg" name="arg1_helper"    default="$(eval '' if (some_arg (arg1 == '!') else some_arg)"/>
arg1)"/>

    <include file="$(find pkg)/launch/$(arg helper_arg)_node.launch">
arg1_helper)_node.launch">
    </include>
</launch>

-

roslaunch pkg default.launch some_arg:="!"

helper_arg arg1:="!"

arg1_helper will evaluate to "" and will try to launch pkg/launch/_node.launch

roslaunch pkg default.launch some_arg:="default"

helper_arg arg1:="some_other_value"

arg1_helper will evaluate to "default" and will try to launch pkg/launch/default_node.launch

pkg/launch/some_other_value_node.launch

roslaunch pkg default.launch

arg1_helper will evaluate to the default value "some_value" and will try to launch pkg/launch/some_value_node.launch

The downsides to this approach would be that you have to have an extra argument in your launch files and instead of arg1:="" you would have to use arg1:="!" (or what ever else you set eval to) to set the argument as an empty string.

As aconkey said giving an empty string from the command line does not seem to work. I'm not sure this is the cleanest solution, but you could hack together the desired behavior to some extent with eval and an intermediate argument. Something like this:

<launch>
    <arg name="arg1"       default="some_value"/>
    <arg name="arg1_helper"    default="$(eval '' if (arg1 == '!') else arg1)"/>

    <include file="$(find pkg)/launch/$(arg arg1_helper)_node.launch">
    </include>
</launch>

-

roslaunch pkg default.launch arg1:="!"

arg1_helper will evaluate to "" and will try to launch pkg/launch/_node.launch

roslaunch pkg default.launch arg1:="some_other_value"

arg1_helper will evaluate to "default" and will try to launch pkg/launch/some_other_value_node.launch

roslaunch pkg default.launch

arg1_helper will evaluate to the default value "some_value" and will try to launch pkg/launch/some_value_node.launch

The downsides to this approach would be that you have to have an extra argument in your launch files and instead of arg1:="" you would have to use arg1:="!" (or what ever else you set eval to) to set the argument as an empty string.

As aconkey said giving an empty string from the command line does not seem to work. I'm not sure this is the cleanest solution, but you could hack together the desired behavior to some extent with eval and an intermediate argument. Something like this:

<launch>
    <arg name="arg1"           default="some_value"/>
    <arg name="arg1_helper"    default="$(eval '' if (arg1 == '!') else arg1)"/>

    <include file="$(find pkg)/launch/$(arg arg1_helper)_node.launch">
    </include>
</launch>

-

roslaunch pkg default.launch arg1:="!"
arg1:=!

arg1_helper will evaluate to "" and will try to launch pkg/launch/_node.launch

roslaunch pkg default.launch arg1:="some_other_value"
arg1:=some_other_value

arg1_helper will evaluate to "default" and will try to launch pkg/launch/some_other_value_node.launch

roslaunch pkg default.launch

arg1_helper will evaluate to the default value "some_value" and will try to launch pkg/launch/some_value_node.launch

The downsides to this approach would be that you have to have an extra argument in your launch files and instead of arg1:="" you would have to use arg1:="!" arg1:=! (or what ever else you set eval to) to set the argument as an empty string.

As aconkey said giving an empty string from the command line does not seem to work. I'm not sure this is the cleanest solution, but you could hack together the desired behavior to some extent with eval and an intermediate argument. Something like this:

<launch>
    <arg name="arg1"           default="some_value"/>
    <arg name="arg1_helper"    default="$(eval '' if (arg1 == '!') else arg1)"/>

    <include file="$(find pkg)/launch/$(arg arg1_helper)_node.launch">
    </include>
</launch>

-

roslaunch pkg default.launch arg1:=!

arg1_helper will evaluate to "" and will try to launch pkg/launch/_node.launch

roslaunch pkg default.launch arg1:=some_other_value

arg1_helper will evaluate to "default" "some_other_value" and will try to launch pkg/launch/some_other_value_node.launch

roslaunch pkg default.launch

arg1_helper will evaluate to the default value "some_value" and will try to launch pkg/launch/some_value_node.launch

The downsides to this approach would be that you have to have an extra argument in your launch files and instead of arg1:="" you would have to use arg1:=! (or what ever else you set eval to) to set the argument as an empty string.