Is there a environmental variable for current namespace in launchfiles?
Hi,
I have created an multirobot launch for Gazebo. Now I found out that there is a solvable problem with the namespace in the robot state publisher. I solved it with adding a tf_prefix. But now here is what I am interested in.
Is it possible to get the current namespace into the
<param name="tf_prefix" value="robotA"/>
instead of writing the namespace name? Is there an environment variable that I could for example write something like this to get the "current namespace" for a parameter?:
<param name="tf_prefix" value="$(optenv ns)"/> <!-- CAUTION: THIS IS NOT A WORKING SOLUTION -->
Unfortunately robot state publisher does not care about the namespace like for example the gazebo plugins do, if you do not add an tf_prefix they add it automatically.
I also know that there is the possibility to include this by a separate launchfile and add an argument for that.
<!--ROBOT A-->
<group ns="robotA" clear_params="true">
<param name="robot_description" command=
"$(find xacro)/xacro.py $(find h4r_rapid_robot_xacros)/defs/test_robots/diff_drive_bot.xacro" />
<node pkg="robot_state_publisher"
type="state_publisher" name="robot_state_publisher">
<param name="tf_prefix" value="robotA"/><!-- Is needed, for adding the namespace to other links -->
<param name="publish_frequency" type="double" value="30.0"/>
</node>
<node name="spawn_test_bot" pkg="gazebo_ros" type="spawn_model"
args="-z 0.2 -x 0 -urdf -param robot_description -model robot_description"
respawn="false" />
</group>
Or can I make this code (robot_state_publisher)
std::string tf_prefix_key;
n_tilde.searchParam("tf_prefix", tf_prefix_key);
n_tilde.param(tf_prefix_key, tf_prefix_, std::string(""));
return the current namespace into tf_prefix_ somehow?
UPDATE: I added a pull request for the robot state publisher to be able to use the current namespace as prefix, as long as there is not another approach: https://github.com/ros/robot_state_pu...
Regards,
Christian
Just a headsup, tf_prefix is deprecated in tf2. And have you looked at this?
Thanks for the hint @130s