ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

ROS2- passing arguments with file not working

asked 2018-11-27 00:13:18 -0600

poonam1120 gravatar image

updated 2018-11-27 01:56:19 -0600

gvdhoorn gravatar image

Hi Folks,

I am trying to launch nodes with in ros2. Nodes are getting launched but I am facing issue with arguments passing.

My Code snippet:

            package='tf2_ros', node_executable='static_transform_publisher',node_name='bl_imu', output='screen',
            #arguments=['-0.07' '0' '0' '3.14159' '0' '0' 'base_link' 'laser' '100']),         
            #arguments=['--x','-0.07', '--y', '0', '--z', '0', '--qx', '3.14159', '--qy', '0', '--qz' ,'0', '--qw','1.570796327','--      #frame_id','base_link','--child_frame_id','imu_link']),

I would like to pass arguments to this node static_transform_publisher.

I tried above two ways but getting error with this specific node.

[ERROR] []: static_transform_publisher exited due to not having the right number of arguments
A command line utility for manually sending a transform.
Usage: static_transform_publisher x y z qx qy qz qw frame_id child_frame_id 
Usage: static_transform_publisher x y z yaw pitch roll frame_id child_frame_id 
[ERROR] [launch]: process[static_transform_publisher-1] process has died [pid 7074, exit code 255, cmd '/opt/ros/bouncy/lib/tf2_ros/static_transform_publisher __node:=bl_imu'].

Please let me know if anybody has tried this or any suggestions.

Thanks, Poonam

edit retag flag offensive close merge delete


I am also running into this issue. I tried passing the arguments as a single string (arguments='0 0 0 0 0 0 1 world cam'), but extra spaces were inserted (cmd '/opt/ros/bouncy/lib/tf2_ros/static_transform_publisher 0 0 0 0 0 0 1 w o r l d c a m').

beck gravatar image beck  ( 2018-11-27 19:12:00 -0600 )edit


I am able to pass this via command line as below and it works.

ros2 run tf2_ros static_transform_publisher 0 -0.3 0.52 -1.570796327 0 1.570796327 base_link imu_link

but i would like to do the same from file

Thanks, poonam

poonam1120 gravatar image poonam1120  ( 2018-11-29 01:48:16 -0600 )edit

Yes, I am experiencing the same problem.

beck gravatar image beck  ( 2018-11-29 11:24:49 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-11-29 14:45:35 -0600

beck gravatar image

I figured it out. The correct way to pass argument is as a list of strings, as in your first attempt. The issue is simply the last argument '100'. Try creating the node as follows.

transform = launch_ros.actions.Node(package='tf2_ros', node_executable='static_transform_publisher',
    arguments=['-0.07', '0', '0', '3.14159', '0', '0', 'base_link', 'laser'])
edit flag offensive delete link more


thanks a lot ..its really working and not throwing error for arguments. By any chance, have you tried to pass arguments like this .

launch.actions.DeclareLaunchArgument( 'output_final_position', default_value='false'),

here , when declaring more that one argument, it throws error.

poonam1120 gravatar image poonam1120  ( 2018-11-30 01:55:36 -0600 )edit

I haven't used this function, but have you tried declaring each argument in a separate call? E.g., DeclareLaunchArgument('arg1', default_value='x', 'arg2', default_value='2') would become DeclareLaunchArgument('arg1', default_value='x') and DeclareLaunchArgument('arg2', default_value='2').

beck gravatar image beck  ( 2018-12-05 14:49:30 -0600 )edit

Also, if this answer worked for you, please mark it as correct.

beck gravatar image beck  ( 2018-12-05 14:49:55 -0600 )edit

@beck, thanks , it is working.

poonam1120 gravatar image poonam1120  ( 2018-12-06 00:19:04 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2018-11-27 00:13:18 -0600

Seen: 3,453 times

Last updated: Nov 29 '18