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

Demo tf2 broadcaster with Python not work

asked 2018-06-20 09:24:00 -0600

updated 2018-06-20 11:48:36 -0600

Hello there, I'm a newbie in this domain so, I try to understand the tf2 and use demo script to see. Stuck into the "Writing a tf2 broadcaster with Python", each time I launch the script it got issue. Could you please show me where is the problem, because I spent 3 days to try to reinstall UBUNTU and redo all steps of that tutorial and still got issue :

Unable to launch [turtle1_tf2_broadcaster-3]. 
If it is a script, you may be missing a '#!' declaration at the top.

In the tutorial script, the first line had that declaration .

My environment is UBUNTU 14.04.LTE ROS Distro : Indigo PC : an old DELL XPS M1530

bichnm@bnm:~/catkin_ws$ roslaunch learning_tf2 start_demo.launch
... logging to /home/bichnm/.ros/log/7f8aa624-748b-11e8-8932-001de081b445/roslaunch-bnm-32118.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://bnm:39504/


 * /rosdistro: indigo
 * /rosversion: 1.11.21
 * /turtle1_tf2_broadcaster/turtle: turtle1
 * /turtle2_tf2_broadcaster/turtle: turtle2

    sim (turtlesim/turtlesim_node)
    teleop (turtlesim/turtle_teleop_key)
    turtle1_tf2_broadcaster (learning_tf2/
    turtle2_tf2_broadcaster (learning_tf2/


core service [/rosout] found
process[sim-1]: started with pid [32136]
process[teleop-2]: started with pid [32137]
Unable to launch [turtle1_tf2_broadcaster-3]. 
If it is a script, you may be missing a '#!' declaration at the top.
The traceback for the exception was written to the log file
Reading from keyboard
Use arrow keys to move the turtle.
[turtle1_tf2_broadcaster-3] killing on exit
[teleop-2] killing on exit
[sim-1] killing on exit

Please help!!! Thanks a lot! Cheers,


Thanks jarvisschultz for answer me rapidly! I just copy and paste the demo script, sure it is there! I did chmod, catkin_make on the workspace and source the devil setup.bash! Every thing are done, but still got that issue. Sorry to ask you that, what’s mean “shebang”? I just start into Unix domain! :-))

edit retag flag offensive close merge delete


I just tried the demo on Ubuntu 16 with ROS kinetic and I didn't run into a problem. These are things I tried that did not result in the described failure: skipped change to executable step, skipped sourcing step, reordered launch file, removed nodes from launch file, and reordered launch file.

KothariA gravatar image KothariA  ( 2018-06-20 10:03:45 -0600 )edit

Does the first line of your <PATH_TO_WORKSPACE>/src/learning_tf2/nodes/ script actually read #!/usr/bin/env python as it does in the tutorial? Did you properly make the file executable with chmod +x nodes/

jarvisschultz gravatar image jarvisschultz  ( 2018-06-20 10:04:28 -0600 )edit

Removing the shebang ) from the first line will likely produce the error you are seeing.

jarvisschultz gravatar image jarvisschultz  ( 2018-06-20 10:11:23 -0600 )edit

@bichnm please don't answer your questions with answers that are not actually answers. I've moved your answer to be an edit to your original question. Generally, that is how you should add more information to your question.

jarvisschultz gravatar image jarvisschultz  ( 2018-06-20 11:50:10 -0600 )edit

For some reason askbot didn't like the ")" character in the link to Shebang, so I edited my comment and re-added the link. Not having the #! properly formatted right at the beginning of the first line is the only thing I know of that can produce the error you are reporting.

jarvisschultz gravatar image jarvisschultz  ( 2018-06-20 11:54:17 -0600 )edit

The #! must be on the first line. Further, it must be the first two characters in the file.

jarvisschultz gravatar image jarvisschultz  ( 2018-06-20 11:54:39 -0600 )edit

Please edit your post to link to the tutorial you're following as well as putting the contents of your script in a code block or put it into a gist.

Can you run the script manually from the command line without the launch file?

tfoote gravatar image tfoote  ( 2018-06-20 12:40:22 -0600 )edit

Hello jqrvisschultz, sure the #! are the two first characters in the script. I reinstall the Ubuntu 16.04 and stuck to the tutorial, the result is the same as mention above. While trying to run the script --> got a lot of syntax errors! line 1-12 command not found ???

bichnm gravatar image bichnm  ( 2018-06-21 09:33:15 -0600 )edit

1 Answer

Sort by » oldest newest most voted

answered 2018-06-21 09:49:37 -0600

The issue was identified in the comments above. The OP mistakenly pasted the code from the tutorial he was following into his text editor with the line numbers from the tutorial. Thus the shebang (hashbang) was not implemented correctly, and roslaunch properly identified the issue and printed out a useful error message.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower


Asked: 2018-06-20 09:24:00 -0600

Seen: 247 times

Last updated: Jun 21 '18