Ask Your Question

Revision history [back]

An obvious answer would be that you could use the full name of the parameter e.g. /foo/do_something.

I'm guessing you are looking for something a bit fancier. If the ROS_NAMESPACE environment variable is set, then the call to rosparam will automatically happen inside of that namespace. So you could use the <env> tag to set that environment variable to be the same as your node name, then the name should get resolved correctly.

I'm not exactly sure if that answers your question, there may be other solutions as well.

An obvious answer would be that you could use the full name of the parameter e.g. /foo/do_something.

I'm guessing you are looking for something a bit fancier. If the ROS_NAMESPACE environment variable is set, then the call to rosparam will automatically happen inside of that namespace. So you could use the <env> tag to set that environment variable to be the same as your node name, then the name should get resolved correctly.

I'm not exactly sure if that answers your question, there may be other solutions as well.

EDIT

Here's an example... I tested this and it works.

Launch File:

<launch>
  <node name="foo" pkg="bar" type="test.sh" output="screen">
    <env name="ROS_NAMESPACE" value="foo" />
    <param name="do_something" value="true" />
  </node>
</launch>

test.sh:

#!/bin/bash
val=$(rosparam get do_something)
echo "PARAM = ${val}"