Ask Your Question

ROS2 - tf2_ros::TransformBroadcaster and rclcpp_lifecycle::LifecycleNode

asked 2018-09-05 04:15:14 -0600

Myzhar gravatar image

I need to create a TransformBroadcaster inside my LifecycleNode, but the constructor of tf2_ros::TransformBroadcaster requires a rclcpp::Node::SharedPtr.

This may be a silly question, but I cannot fill the missing part:

    std::shared_ptr<tf2_ros::TransformBroadcaster> mTransformPoseBroadcaster;
    mTransformPoseBroadcaster = std::make_shared<tf2_ros::TransformBroadcaster>(??????????);

Thank you for help


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-09-05 16:06:18 -0600

William gravatar image

The tf2_ros interface, which pre-dates lifecycle nodes and the node interfaces in rclcpp, would need to be updated to take the "node interfaces" that it uses, which are the common element between Node and LifecycleNode. For example, maybe it should instead take a pointer to rclcpp::node_interfaces::NodeTopicsInterface and a pointer to an instance of rclcpp::node_interfaces::NodeParametersInterface instead of a pointer to a node.

A separate question is whether or not tf2_ros should create lifecycle topics or normal topics (should it work only in certain lifecycle states or always)?

I'd recommend opening an issue on the ros2/geometry2 issue tracker ( ) asking about this. I'm not sure if anyone will have time to implement this for you, but if you're interesting in contributing this feature for tf2 that would probably be a quicker way to get a solution for this.

edit flag offensive delete link more


Yes, I think that it should be similar to executors that get a pointer to NodeBaseInterface when you add nodes.

Added issue:

Myzhar gravatar image Myzhar  ( 2018-09-06 03:08:56 -0600 )edit

Actually I'm using a simple trick: I publish the TF2 as normal message and I made a "normal" node that subscribes and broadcasts using tf2_ros::TransformBroadcaster

Myzhar gravatar image Myzhar  ( 2018-09-06 03:10:48 -0600 )edit

An update: using the node that subscribes to tf2 messages and broadcasts them it works, but there is a latency issue as i described here:

Myzhar gravatar image Myzhar  ( 2018-09-15 15:06:15 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2018-09-05 04:15:14 -0600

Seen: 620 times

Last updated: Sep 05 '18