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

Understaning tf2 demo launch file

asked 2018-06-19 22:24:14 -0600

viveksudani gravatar image

I have one more question regarding the same on this page Writing a tf2 broadcaster (Python)(section 3 Running the broadcaster).

Why we need to initiate two different node named turtle1_tf2_broadcaster & turtle2_tf2_broadcaster. Can anyone explain whole code inside start_demo.launch which is here:

 <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>
edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
2

answered 2018-06-20 04:47:48 -0600

In ROS launch files are used to start multiple nodes with one command. In the above example one starts the same node multiple times but using different parameters. So basically following will happens:

  1. one starts turtle sim node with a name sim
  2. teleoperation node for turtlesim node is started
  3. node with a name turtle1_tf2_broadcaster is started and listens on a topic /turtle1/pose
  4. node with a name turtle2_tf2_broadcaster is started and listens on a topic /turtle2/pose

So basically the two broadcasters will broadcast different stuff depending on subscribed topic.

edit flag offensive delete link more

Comments

@destogl, Thanks for reply. your explanation is well understood. But why we need two broadcasters. since we are running only one turtlesim node. I mean can't we run only one broadcaster instead of two?

viveksudani gravatar image viveksudani  ( 2018-06-24 01:00:33 -0600 )edit

If you read carefully the explanation on the end of the page you will see that second broadcaster is needed in the next tutorial. And here is just added for teaching purposes. See: Checking the results part

destogl gravatar image destogl  ( 2018-06-24 15:51:26 -0600 )edit

Yay! I missed that lines😅. By the way thank you so much.😇 Now i m clear that second broadcaster has no role to play yet.

viveksudani gravatar image viveksudani  ( 2018-06-24 20:52:10 -0600 )edit

You are welcome! If you are happy with answer please mark it as answered.

destogl gravatar image destogl  ( 2018-06-24 23:12:29 -0600 )edit
0

answered 2018-06-20 04:16:19 -0600

sorry , maybe your answer is too big , in a word , launch file is a tool to launch some node (executable file) random

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-06-19 22:24:14 -0600

Seen: 323 times

Last updated: Jun 20 '18