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

pass arg to ros node in launch file

asked 2019-12-20 11:44:39 -0600

dinesh gravatar image

How do i properly pass argument to ros node in ros launch file? Here is the ros node which i want to launch from a roslaunch file:

> <launch>   <node name="2d_obj_rec"
> pkg="advanced_vision_pkg"
> type="2d_obj_rec" args="image"
>     output="screen"/> </launch>

Here i want to pass image arugment like " rosrun advanced_vision_pkg 2d_obj_rec image:=/camera/image"
when i launch the file using cmd " roslaunch advanced_vision_pkg 2d_obj_rec.launch image:=/camera/image" it is not working.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-12-20 12:06:17 -0600

Abhishekpg gravatar image

updated 2019-12-20 12:07:17 -0600

Add below arg line to launch file

<arg name="image"/>

Then Change the node line to the following

<node name="2d_obj_rec" pkg="advanced_vision_pkg" type="2d_obj_rec" args="$(arg image)" output="screen"/>

edit flag offensive delete link more


is this also possile to pass more than one args to more than one ros nodes? how?

dinesh gravatar image dinesh  ( 2019-12-20 12:16:00 -0600 )edit

Can you please clarify the question. If you want to pass more arguments to your node the. You can do it by adding more arg tags like blow

<arg name="image"/>

<arg name="2nd_arg"/>

<node name="2d_obj_rec" pkg="advanced_vision_pkg" type="2d_obj_rec" args="$(arg image) $(2nd_arg)" output="screen"/>

You can do like this for another nodes also

Abhishekpg gravatar image Abhishekpg  ( 2019-12-20 12:21:38 -0600 )edit

ok. got it.

dinesh gravatar image dinesh  ( 2019-12-20 12:26:53 -0600 )edit

Question Tools


Asked: 2019-12-20 11:44:39 -0600

Seen: 3,945 times

Last updated: Dec 20 '19