Ask Your Question
1

ROS2- passing arguments with launch.py file not working

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

poonam1120 gravatar image

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

gvdhoorn gravatar image

Hi Folks,

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

My Code snippet:

launch_ros.actions.Node(
            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 
OR 
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

Comments

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 -0500 )edit
1

Hi,

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 launc.py file

Thanks, poonam

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

Yes, I am experiencing the same problem.

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

1 Answer

Sort by ยป oldest newest most voted
0

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

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

Comments

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 -0500 )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 -0500 )edit

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

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

@beck, thanks , it is working.

poonam1120 gravatar image poonam1120  ( 2018-12-06 00:19:04 -0500 )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

2 followers

Stats

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

Seen: 976 times

Last updated: Nov 29 '18