# TF and rqt Frame Editor **Goal:** get an intuitive understanding of coordinate frames and parent-child relationships, by placing frames by hand and watching them in RViz. **Tool:** the [rqt Frame Editor](https://github.com/ROS-Industrial-Session-Common/rqt_frame_editor_plugin/tree/feature/urdf-preview) (package `frame_editor`, branch `feature/urdf-preview`). Slides: [Coordinate transforms (TF2)](https://ros-industrial.github.io/ros2_i_training/slides/Basics/source/TF.html). ## 1. Build the Frame Editor In the `src/` folder of your workspace: ```bash git clone -b feature/urdf-preview https://github.com/ROS-Industrial-Session-Common/rqt_frame_editor_plugin.git cd .. source /opt/ros/jazzy/setup.bash rosdep install --from-paths src/rqt_frame_editor_plugin --ignore-src -y colcon build --symlink-install --packages-select frame_editor source install/setup.bash ``` ## 2. Add frames 1. **Open rqt** in a terminal where the workspace is sourced (`--force-discover` finds the new plugin): ```bash rqt --force-discover ``` ![rqt window](../../../_static/manipulation/tf/rqt_window.png) 2. **Open the Frame Editor:** Plugins → Frame Editor Plugin. 3. **Start a blank edition** with the **New** button. ![Frame Editor: New button](../../../_static/manipulation/tf/frame_editor_new.png) 4. **Add a frame** with **Add New**: name it `object_1`, with `world` as parent. ![Frame Editor: Add New frame](../../../_static/manipulation/tf/frame_editor_add_new_frame.png) 5. **Open RViz** in another terminal, and set the fixed frame to `world`: ```bash rviz2 ``` ![RViz: set fixed frame to world](../../../_static/manipulation/tf/rviz_fixed_frame.png) 6. **Add the TF display:** Add → TF → OK. ![RViz: Add display](../../../_static/manipulation/tf/rviz_add_display.png) ![RViz: TF display](../../../_static/manipulation/tf/rviz_tf.png) 7. **Experiment:** add frames, change the marker size and the visibility, move the frames with the Frame Editor and watch them in RViz. ## 3. Parent and child 1. **Add a child frame:** **Add New**, name it `object_2`, with `object_1` as parent. 2. **Move the parent:** move `object_1` and watch `object_2` follow. The child stores its pose relative to its parent. 3. **Check the transform** in a third terminal: ```bash ros2 run tf2_ros tf2_echo world object_2 ``` Move `object_1` again: the printed transform changes, although you only moved the parent. 4. **Change a parent:** set the parent of `object_2` to `world`, once with **Parent (keep relative)** and once with **Parent (keep absolute)**. What is the difference? Then set it back to `object_1`. Keep `object_1` and `object_2`, the Frame Editor and RViz running: the next exercise, [TF and Python](02_tf_python.md), uses them. ## Questions - Why can `tf2_echo world object_2` print a transform, although nobody publishes `world → object_2` directly? - Which topic do the editor's frames use, `/tf` or `/tf_static`? Check with `ros2 topic info /tf_static --verbose`.