Skip to content

Misleading fixed frame broadcaster code in tf2 Adding a Frame (C++) tutorial #6792

@YingKang-an

Description

@YingKang-an

Issue Type

  • 🐛 Bug / Problem
  • ✏️ Typo / Grammar
  • 📖 Outdated Content
  • 🚀 Enhancement

Generated by Generative AI

No

Distribution

Jazzy

Description

In the official ROS2 intermediate tutorial tf2 Adding a frame (C++), the fixed frame demonstration uses tf2_ros::TransformBroadcaster (dynamic TF broadcaster) plus a 100ms wall timer to repeatedly publish unchanged static coordinate transformation.
This implementation is non-standard and confusing for beginners:

1.Fixed frames with constant relative pose do not require periodic repeated publishing.
2.Using dynamic TF broadcaster to send static transform wastes CPU resources and violates ROS2 TF design rules.
3.Beginners cannot correctly distinguish the usage difference between static TF and dynamic TF after learning this example.

Affected Pages/Sections

https://docs.ros.org/en/jazzy/Tutorials/Intermediate/Tf2/Adding-A-Frame-Cpp.html

Screenshots or Examples (if applicable)

No response

Suggested Fix

Rewrite fixed frame broadcaster code to use standard tf2_ros::StaticTransformBroadcaster.
Delete redundant timer and callback function, send static transform only once in node constructor.
Add clear text distinction in tutorial:

Static fixed frame: use StaticTransformBroadcaster, publish once
Dynamic moving frame: use TransformBroadcaster, publish periodically (100ms is reasonable)

Keep the original dynamic frame broadcaster code, it is fully correct.

Additional Context

The original tutorial uses dynamic TF code for fixed frame only for unified code style, which leads to wrong usage cognition.
StaticTransformBroadcaster can automatically maintain static transformation in TF tree without manual loop sending.
Periodic publishing (100ms) is only applicable to dynamically changing coordinate frames.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions