ros / geometry2

A set of ROS packages for keeping track of coordinate transforms.
191 stars 279 forks source link

Python tf2 buffer does not Detect Jumps in Time #551

Closed erichlf closed 1 year ago

erichlf commented 1 year ago

In humble, after setting use_sim_time and running a bag in a loop via ros2 bag play -l --clock 10 <bag> I get the Warning: TF_OLD_DATA ignoring data from the past for frame tilt at time ... error message. This does not occur when using rclcpp and only rclpy. I have verified that in the source code for buffer.py the logic for detecting clock jumps is missing, but is in the source for buffer.cpp. Minimum code to reproduce is as follows:

#!/usr/bin/env python3

import rclpy
from rclpy.node import Node
from rclpy.qos import qos_profile_sensor_data
from sensor_msgs.msg import PointCloud2
from tf2_ros import TransformException
from tf2_ros.buffer import Buffer
from tf2_ros.transform_listener import TransformListener

class TestNode(Node):
    def __init__(self):
        super().__init__("test_node")
        # Subscribe to /points
        self.get_logger().info("Subscribing to PointCloud2 topic...")
        self.subscription = self.create_subscription(
            PointCloud2,
            "/points",
            self.callback_main,
            qos_profile_sensor_data,
        )
        self.tf_buffer = Buffer()
        self.tf_listener = TransformListener(self.tf_buffer, self)

    def callback_main(self, pc_msg):
        self.get_logger().info(f"time = {self.get_clock().now()}")

def main(args=None):
    # Init client library
    rclpy.init(args=args)
    # Create the pub/sub
    test_node = TestNode()
    # Spinning...
    try:
        rclpy.spin(
            test_node,
        )
    except KeyboardInterrupt:
        pass

    return 0

And I ran this simply by ros2 run test test_node --ros-args -p use_sim_time:=true

erichlf commented 1 year ago

This is related to #43 and #68.

erichlf commented 1 year ago

Wrong repository. See the ros2 geometry2 repo.