How to include the ROS_NAMESPACE in the default attribute in a launch file?

asked 2020-03-07 16:23:55 -0500

abhanjac gravatar image

updated 2020-03-07 16:24:37 -0500

Hi,

I am really new to ROS. I have a launch file which has the following written in it: (When there is no ROS_NAMESPACE defined)

<arg name="max_track_error" default="0.2" />
<arg name="cam_image_topic" default="/head_camera/depth_registered/points" />

Now if I define a in the .bashrc: export ROS_NAMESPCE=fetch

I want the launch file to be "equivalent to" the following:

<arg name="max_track_error" default="0.2" />
<arg name="cam_image_topic" default="/fetch/head_camera/depth_registered/points" />

How do I do that, without physically editing the launch file. Can I include some kind of variable or something in the launch file that take the value of the ROS_NAMESPCE (when defined) that will change that default attribute?

edit retag flag offensive close merge delete

Comments

How do I do that, without physically editing the launch file.

and:

Can I include some kind of variable or something in the launch file

would seem to be in conflict with each other.

gvdhoorn gravatar image gvdhoorn  ( 2020-03-08 06:29:50 -0500 )edit

I don't intend to use both of these methods, either one of the solutions (if there is one) will work. Can you tell me how to do this in the launch file?

abhanjac gravatar image abhanjac  ( 2020-03-08 08:19:34 -0500 )edit

I would suggest you look at the answer to this question, where the proper syntax for running a node in a namespace.

sniegs gravatar image sniegs  ( 2022-08-10 07:57:59 -0500 )edit