Skip to content

tf_visual_tools: pass Node by reference to TransformBroadcaster - #302

Merged
nbbrooks merged 1 commit into
ros2from
nbbrooks/fix-transform-broadcaster-nodeinterfaces
Aug 2, 2026
Merged

nbbrooks merged 1 commit into
ros2from
nbbrooks/fix-transform-broadcaster-nodeinterfaces

Conversation

@nbbrooks

@nbbrooks nbbrooks commented Aug 2, 2026 •

Copy link
Copy Markdown
Member

Why

rolling-testing fails to compile on Resolute:

/opt/ros/rolling/include/rclcpp/rclcpp/node_interfaces/node_topics_interface.hpp:99:1:
error: 'const class std::shared_ptr<rclcpp::Node>' has no member named 'get_node_topics_interface'
   99 | RCLCPP_NODE_INTERFACE_HELPERS_SUPPORT(rclcpp::node_interfaces::NodeTopicsInterface, topics)

Upstream cause

ros2/geometry2#940 — "Removed deprecated code" (ahcorde, merged 2026-07-01, +0/-978 across 13 files).

tf2_ros::TransformBroadcaster used to accept a node pointer via constructor overloads marked:

template<class NodeT, class AllocatorT = std::allocator<void>,
  std::enable_if_t<rcpputils::is_pointer<NodeT>::value, bool> = true>
[[deprecated("Use rclcpp::node_interfaces::NodeInterfaces instead of NodeT")]]
explicit TransformBroadcaster(NodeT && node)

#940 deleted them. What remains takes rclcpp::node_interfaces::NodeInterfaces<NodeParametersInterface, NodeTopicsInterface>, and that template calls get_node_*_interface() directly on whatever it's handed — so a std::shared_ptr<rclcpp::Node> no longer satisfies it. The error surfaces inside the rclcpp headers, but the change is in geometry2.

src/tf_visual_tools.cpp:62 passes the SharedPtr.

First shipped in tf2_ros 0.46.2:

tf2_ros pointer ctor old form
0.46.1 present ✅ compiles
0.46.2 removed by #940 ❌ fails
0.46.3 removed ❌ fails

How

Dereference it — which is exactly the migration the deprecation notice asked for.

-  tf_broadcaster_ = std::make_shared<tf2_ros::TransformBroadcaster>(node);
+  tf_broadcaster_ = std::make_shared<tf2_ros::TransformBroadcaster>(*node);

The remaining constructor is templated on node type and accepts a node reference on every supported distro, so no version guard is needed.

Verification

Compiled both forms against each distro's real headers:

distro packages from tf2_ros (node) (*node)
humble osrf/ros:humble-desktop — ✅ ✅
jazzy osrf/ros:jazzy-desktop — ✅ ✅
rolling osrf/ros:rolling-desktop 0.46.1 ✅ ✅
rolling ros-testing on ubuntu:resolute 0.46.3 ❌ reproduces ✅

⚠️ Worth noting for anyone reproducing: the prebuilt osrf/ros:rolling-desktop image still ships tf2_ros 0.46.1 and therefore still accepts the old form. Only the current ros-testing packages on Resolute reject it — which is what CI and the buildfarm use. Testing against the desktop image alone gives a false pass.

How it surfaced

The ros2 matrix used to cancel this job: no fail-fast: false, and the rolling + ROS_REPO: main job died in setup within ~60s, taking its siblings with it. #301 fixed that; #300 fixed the Qt5/Qt6 collision that was masking this behind an earlier CMake generate failure. With both cleared, the build gets 44s into compiling and hits this.

Independent of #300 — this touches only src/tf_visual_tools.cpp, that one touches CMakeLists.txt + package.xml. Either merge order works.

🤖 Generated with Claude Code

tf2_ros::TransformBroadcaster used to accept a node pointer through a set of
constructor overloads marked

  [[deprecated("Use rclcpp::node_interfaces::NodeInterfaces instead of NodeT")]]

guarded by std::enable_if_t<rcpputils::is_pointer<NodeT>::value, bool>.
ros2/geometry2#940 "Removed deprecated code" (ahcorde, merged 2026-07-01,
+0/-978 across 13 files) deleted them. What remains takes
rclcpp::node_interfaces::NodeInterfaces<NodeParametersInterface,
NodeTopicsInterface>, which calls get_node_*_interface() directly on whatever
it is handed -- so a std::shared_ptr<rclcpp::Node> no longer satisfies it:

  /opt/ros/rolling/include/rclcpp/rclcpp/node_interfaces/node_topics_interface.hpp:99:1:
  error: 'const class std::shared_ptr<rclcpp::Node>' has no member named
         'get_node_topics_interface'
     99 | RCLCPP_NODE_INTERFACE_HELPERS_SUPPORT(
          rclcpp::node_interfaces::NodeTopicsInterface, topics)

Dereference instead. The remaining constructor is templated on node type and
accepts a node reference on every supported distro, so no version guard is
needed -- and this is the migration the deprecation notice asked for.

First shipped in tf2_ros 0.46.2:

  0.46.1  pointer ctor present  -> old form compiles
  0.46.2  removed by #940       -> old form fails
  0.46.3  removed               -> old form fails

Verified by compiling both forms against each distro's real headers:

  distro                              (node)      (*node)
  humble                              ok          ok
  jazzy                               ok          ok
  rolling  osrf/ros:rolling-desktop   ok          ok    (tf2_ros 0.46.1)
  rolling  ros-testing on resolute    FAILS       ok    (tf2_ros 0.46.3)

Note the prebuilt rolling desktop image still ships 0.46.1 and therefore
still accepts the old form; only the current ros-testing packages on
Resolute reject it, which is what CI builds against.

Surfaced by the rolling-testing job on #300 once #301 stopped fail-fast
from cancelling it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@nbbrooks
nbbrooks force-pushed the nbbrooks/fix-transform-broadcaster-nodeinterfaces branch from 2b25a60 to 632fd3d Compare August 2, 2026 23:09
@nbbrooks
nbbrooks merged commit be83004 into ros2 Aug 2, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant