Compiling and running the TF

In the preceding subsection, we had to learn to develop the code for the TF demo application. To compile this, we will have to make an entry in CMakeLists.txt about source files and compilation rules:

add_executable(turtle_tf_broadcaster src/turtle_tf_broadcaster.cpp) 
target_link_libraries(turtle_tf_broadcaster ${catkin_LIBRARIES}) 
 
add_executable(turtle_tf_listener src/turtle_tf_listener.cpp) 
target_link_libraries(turtle_tf_listener ${catkin_LIBRARIES}) 

Now, we can build the package from the top folder of the workspace using catkin_make. If everything goes well, we will have binary files called turtle_tf_broadcaster and turtle_tf_listner in our devel/lib/ folder. To start the application, we will create a launch file called launch/start_demo.launch and add the startup, configuration, and information there:

<launch> 
    <!-- Turtlesim Node--> 
    <node pkg="turtlesim" type="turtlesim_node" name="sim"/> 
 
    <node pkg="turtlesim" type="turtle_teleop_key" name="teleop" output="screen"/> 
    <!-- Axes --> 
    <param name="scale_linear" value="2" type="double"/> 
    <param name="scale_angular" value="2" type="double"/> 
 
    <node pkg="tf_tutorials" type="turtle_tf_broadcaster" 
          args="/turtle1" name="turtle1_tf_broadcaster" /> 
    <node pkg="tf_tutorials" type="turtle_tf_broadcaster" 
          args="/turtle2" name="turtle2_tf_broadcaster" /> 
    <node pkg="tf_tutorials" type="turtle_tf_listener" 
          name="listener" /> 
</launch> 

Finally, we can launch the application and verify the result using the TF visualization and debugging tools which we discussed in the previous subsection:

$ roslaunch tf_tutorials start_demo.launch
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.112.220