Demo tf2 broadcaster with Python not work
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/
SUMMARY
========
PARAMETERS
* /rosdistro: indigo
* /rosversion: 1.11.21
* /turtle1_tf2_broadcaster/turtle: turtle1
* /turtle2_tf2_broadcaster/turtle: turtle2
NODES
/
sim (turtlesim/turtlesim_node)
teleop (turtlesim/turtle_teleop_key)
turtle1_tf2_broadcaster (learning_tf2/turtle_tf2_broadcaster.py)
turtle2_tf2_broadcaster (learning_tf2/turtle_tf2_broadcaster.py)
ROS_MASTER_URI=http://localhost:11311
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,
EDIT
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! :-))
Asked by bichnm on 2018-06-20 09:24:00 UTC
Answers
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.
Asked by jarvisschultz on 2018-06-21 09:49:37 UTC
Comments
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.
Asked by KothariA on 2018-06-20 10:03:45 UTC
Does the first line of your
<PATH_TO_WORKSPACE>/src/learning_tf2/nodes/turtle_tf2_broadcaster.py
script actually read#!/usr/bin/env python
as it does in the tutorial? Did you properly make the file executable withchmod +x nodes/turtle_tf2_broadcaster.py
?Asked by jarvisschultz on 2018-06-20 10:04:28 UTC
Removing the shebang from the first line will likely produce the error you are seeing. https://en.wikipedia.org/wiki/Shebang_(Unix)
Asked by jarvisschultz on 2018-06-20 10:11:23 UTC
@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.
Asked by jarvisschultz on 2018-06-20 11:50:10 UTC
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.Asked by jarvisschultz on 2018-06-20 11:54:17 UTC
The
#!
must be on the first line. Further, it must be the first two characters in the file.Asked by jarvisschultz on 2018-06-20 11:54:39 UTC
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?
Asked by tfoote on 2018-06-20 12:40:22 UTC
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 ???
Asked by bichnm on 2018-06-21 09:33:15 UTC
Hello jarvisschultz, I found my mistake. While copy/paste the script in the tutorial, I forget to toggle line numbers before copying. So while you ask me to launch script without launch file, that gave me an idea while seeing line 1-12 : command not found. So before the #! is the number of line !.
Asked by bichnm on 2018-06-21 09:43:37 UTC
Thank you so much jarvisschultz for spending your time to try to fix my issue. Issue is closed now.
Asked by bichnm on 2018-06-21 09:45:02 UTC
Awesome! Glad that you fixed the issue. You added a blank answer, but I've instead added an answer that summarizes this conversation. This will be more useful for any future users that encounter this question.
Asked by jarvisschultz on 2018-06-21 09:50:49 UTC