Rosanswers logo

I just can't get a static transform publisher to launch from a launch.py file... This is the code:

from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():

    ld = LaunchDescription()
    node = Node(package = "tf2_ros", 
                       executable = "static_transform_publisher",
                       arguments = ["0 0 0 0 0 0 odom laser"])

    return ld

This should be pretty straightforward, but the launch fails with:

[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [static_transform_publisher-1]: process started with pid [43278]
[static_transform_publisher-1] [ERROR] [1614263713.282074840] []: static_transform_publisher exited due to not having the right number of arguments
[ERROR] [static_transform_publisher-1]: process has died [pid 43278, exit code 2, cmd '/opt/ros/foxy/lib/tf2_ros/static_transform_publisher 0 0 0 0 0 0 odom laser --ros-args'].

I've tried everything that I could think of, but just can't get it to work.

Things that I've tried:

  • passing arguments as arguments = ["0 0 0 0 0 0 odom laser".split(' ')])
  • passing arguments as arguments = [("0 0 0 0 0 0 odom laser")])
  • passing arguments as parameters= ...
  • running the command from error output ( /opt/ros/foxy/lib/tf2_ros/static_transform_publisher 0 0 0 0 0 0 odom laser --ros-args ) from the terminal -> that works just fine .

update - solved

arguments = ["0", "0", "0", "0", "0", "0", "odom", "laser"]


arguments = "0 0 0 0 0 0 odom laser".split(' ')

works just fine

Originally posted by Jev on ROS Answers with karma: 43 on 2021-02-25

Post score: 4

Original comments

Comment by gvdhoorn on 2021-02-25:
Have you tried with:

arguments = ["0", "0", "0", "0", "0", "0", "odom", "laser"]

there is a difference between a single large arg in ", and a nr of them.

Comment by Jev on 2021-02-25:
Yes, i did, among many, many other things. When the arguments are passed as a list the launch system seems to lump them all together is as a single argument: ...cmd '/opt/ros/foxy/lib/tf2_ros/static_transform_publisher 000000odomlaser --ros-args'].

Comment by gvdhoorn on 2021-02-25:\

Yes, i did, among many, many other things

It doesn't seem like you mentioned that in your question.

Please update your question with what you've tried.

Otherwise we'll just keep suggesting things you've already done ..


1 Answer 1


Rosanswers logo

The value of arguments should be a list of strings. Using

arguments = ["0", "0", "0", "0", "0", "0", "odom", "laser"]

in your launch file works for me. Can you double-check and try it again?

To help with debugging you can also pass the following parameter to Node:


Originally posted by jacobperron with karma: 1870 on 2021-02-28

This answer was ACCEPTED on the original site

Post score: 7

Original comments

Comment by Jev on 2021-03-01:
Thanks, it worked! :D

Comment by gvdhoorn on 2021-03-04:
@Jev: isn't that exactly what I wrote in the first comment? How did this work all of a sudden?

Did you maybe forget to add the commas?

If you don't separate each element by commas, you get this:

>>> a = ["a" "a"]
>>> a

as Python will concatenate the string literals into a single str.

Comment by Jev on 2021-03-04:
@gvdhoorn : I was wandering the same thing: what did I mess up when trying it in the beginning. Unfortunately I don't have exact history of the things that I've changed, however I remember being lazy about typing all the quotes and commas, so at some point probably I went for ["0 0 0 0 0 0 odom laser".split(' ')] ... that did not work. Now retrying this all again, it turnes out that passing arguments = "0 0 0 0 0 0 odom laser".split(' ')) does work. ... or it was a stupid typo. I feel a bit emarassed now :-/ ... but it did cost me half a day before I asked the question. I'll change the things that I've tried to help others ... and thanks for the help! ... also, probably using ExecuteProcess instead of a Node would also do the trick.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.