ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Suyash's profile - activity

2020-04-08 06:32:30 -0500 received badge  Famous Question (source)
2019-11-01 10:18:55 -0500 received badge  Notable Question (source)
2019-10-31 17:40:42 -0500 received badge  Enthusiast
2019-10-24 02:44:00 -0500 marked best answer Unable to run turtle_tf2_broadcaster.py. Tutorial: tf2TutorialsWriting a tf2 broadcaster (Python)

Hello,

I am new to ROS and I am trying to complete the tf2 tutorials. While running this particular tutorial (http://wiki.ros.org/tf2/Tutorials/Wri... a tf2 broadcaster (Python)) I created the turtle_tf2_broadcaster.py file and the start_demo.launch file exactly as described in the tutorial and in the directory as described in the tutorial. After this, I invoked catkin_make and I source devel_isolated/setup.bash in the terminal (I also tried sourcing devel/setup.bash). However, the following error comes up and it closes:

    RLException: Unable to launch [turtle1_tf2_broadcaster-4]. 
    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

The full output of the command I have attached at the end.

I am not able to figure out a way to get through this. Please suggest me what should I do. Please also find below my code for turtle_tf2_broadcaster.py and start_demo.launch. On lines 5 and 22 in turtle_tf2_broadcaster.py, I tried changing tf (as mentioned on the tutorial http://wiki.ros.org/tf2/Tutorials/Wri... a tf2 broadcaster (Python)) to tf2 and it still didn't work.

   #!/usr/bin/env python  
   import rospy

   # Because of transformations
   import tf2_conversions

   import tf2_ros
   import geometry_msgs.msg
   import turtlesim.msg


   def handle_turtle_pose(msg, turtlename):
       br = tf2_ros.TransformBroadcaster()
       t = geometry_msgs.msg.TransformStamped()

       t.header.stamp = rospy.Time.now()
       t.header.frame_id = "world"
       t.child_frame_id = turtlename
       t.transform.translation.x = msg.x
       t.transform.translation.y = msg.y
       t.transform.translation.z = 0.0
       q = tf2_conversions.transformations.quaternion_from_euler(0, 0, msg.theta)
       t.transform.rotation.x = q[0]
       t.transform.rotation.y = q[1]
       t.transform.rotation.z = q[2]
       t.transform.rotation.w = q[3]

       br.sendTransform(t)

   if __name__ == '__main__':
       rospy.init_node('tf2_turtle_broadcaster')
       turtlename = rospy.get_param('~turtle')
       rospy.Subscriber('/%s/pose' % turtlename,
                        turtlesim.msg.Pose,
                        handle_turtle_pose,
                        turtlename)
       rospy.spin()

Code for start_demo.launch

  <launch>
      <node pkg="turtlesim" type="turtlesim_node" name="sim"/>
      <node pkg="turtlesim" type="turtle_teleop_key" name="teleop" output="screen"/>


    <node name="turtle1_tf2_broadcaster" pkg="learning_tf2" type="turtle_tf2_broadcaster.py" respawn="false" output="screen" >
      <param name="turtle" type="string" value="turtle1" />
    </node>
    <node name="turtle2_tf2_broadcaster" pkg="learning_tf2" type="turtle_tf2_broadcaster.py" respawn="false" output="screen" >
      <param name="turtle" type="string" value="turtle2" /> 
    </node>

  </launch>

Full out put when lunching the start_demo.launch.

suyash@ROS:~/tutorial_ws$ roslaunch learning_tf2 start_demo.launch
... logging to /home/suyash/.ros/log/b7a6d97a-f1bb-11e9-a228-08002776bdd9/roslaunch-ROS-2614.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://ROS:36971/

SUMMARY
========

PARAMETERS
 * /rosdistro: melodic
 * /rosversion: 1.14.3
 * /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)

auto-starting new master
process[master]: started with pid [2625]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to b7a6d97a-f1bb-11e9-a228-08002776bdd9
process[rosout-1]: started with pid [2636]
started core service [/rosout]
process[sim-2]: started with pid ...
(more)
2019-10-23 22:29:36 -0500 commented question Unable to run turtle_tf2_broadcaster.py. Tutorial: tf2TutorialsWriting a tf2 broadcaster (Python)

Hi, I have figured out the solution. There was around 3 space characters between the start and #!/usr/bin/env python. Wh

2019-10-21 10:28:10 -0500 commented question Unable to run turtle_tf2_broadcaster.py. Tutorial: tf2TutorialsWriting a tf2 broadcaster (Python)

Hi there. Is there any update for me on this question?

2019-10-19 14:50:12 -0500 received badge  Popular Question (source)
2019-10-18 10:44:37 -0500 commented question Unable to run turtle_tf2_broadcaster.py. Tutorial: tf2TutorialsWriting a tf2 broadcaster (Python)

I ran the command and the output was: suyash@ROS:~/tutorial_ws/src/learning_tf2/nodes$ ls -al turtle_tf2_broadcaster.py

2019-10-18 10:42:26 -0500 edited question Unable to run turtle_tf2_broadcaster.py. Tutorial: tf2TutorialsWriting a tf2 broadcaster (Python)

Unable to run turtle_tf2_broadcaster.py. Tutorial: tf2TutorialsWriting a tf2 broadcaster (Python) Hello, I am new to RO

2019-10-18 10:42:26 -0500 received badge  Editor (source)
2019-10-18 10:24:44 -0500 commented answer Unable to run turtle_tf2_broadcaster.py. Tutorial: tf2TutorialsWriting a tf2 broadcaster (Python)

Hi Alberto.Thank you for your response and pardon me for the delayed response. I am using the same tutorial as mentioned

2019-10-18 10:24:30 -0500 commented answer Unable to run turtle_tf2_broadcaster.py. Tutorial: tf2TutorialsWriting a tf2 broadcaster (Python)

Hi Alberto.Thank you for your response and pardon me for the delayed response. I am using the same tutorial as mentioned

2019-10-18 10:24:17 -0500 commented answer Unable to run turtle_tf2_broadcaster.py. Tutorial: tf2TutorialsWriting a tf2 broadcaster (Python)

Hi Alberto.Thank you for your response and pardon me for the delayed response. I am using the same tutorial as mentioned

2019-10-18 10:21:39 -0500 commented question Unable to run turtle_tf2_broadcaster.py. Tutorial: tf2TutorialsWriting a tf2 broadcaster (Python)

Thank you for your response, sorry I missed those details. I have edited my question and included the details.Also one m

2019-10-18 10:18:26 -0500 edited question Unable to run turtle_tf2_broadcaster.py. Tutorial: tf2TutorialsWriting a tf2 broadcaster (Python)

Unable to run turtle_tf2_broadcaster.py. Tutorial: tf2TutorialsWriting a tf2 broadcaster (Python) Hello, I am new to RO

2019-10-17 22:53:48 -0500 asked a question Unable to run turtle_tf2_broadcaster.py. Tutorial: tf2TutorialsWriting a tf2 broadcaster (Python)

Unable to run turtle_tf2_broadcaster.py. Tutorial: tf2TutorialsWriting a tf2 broadcaster (Python) Hello, I am new to RO