def test_clear(self): buffer_core = BufferCore() transform = build_transform('bar', 'foo', rclpy.time.Time(seconds=0).to_msg()) buffer_core.set_transform(transform, 'unittest') result, _ = buffer_core.can_transform_core(target_frame='foo', source_frame='bar', time=rclpy.time.Time()) self.assertTrue(result) buffer_core.clear() result, _ = buffer_core.can_transform_core(target_frame='foo', source_frame='bar', time=rclpy.time.Time()) self.assertFalse(result)
def test_set_transform(self): buffer_core = BufferCore() transform = build_transform('bar', 'foo', rclpy.time.Time().to_msg()) result = buffer_core.set_transform(transform, 'unittest') self.assertEqual(result, None) result, _ = buffer_core.can_transform_core( target_frame='bar', source_frame='foo', time=rclpy.time.Time(seconds=0.5)) self.assertEqual(result, 0)
def test_can_transform_core_fail(self): buffer_core = BufferCore() transform = build_transform('bar', 'foo', rclpy.time.Time(seconds=1).to_msg()) buffer_core.set_transform(transform, 'unittest') transform = build_transform('bar', 'foo', rclpy.time.Time(seconds=2).to_msg()) buffer_core.set_transform(transform, 'unittest') result, error_msg = buffer_core.can_transform_core( target_frame='foo', source_frame='bar', time=rclpy.time.Time(seconds=2.5)) self.assertEqual(result, 0) self.assertIn('extrapolation into the future', error_msg) result, error_msg = buffer_core.can_transform_core( target_frame='foo', source_frame='bar', time=rclpy.time.Time(seconds=0.5)) self.assertEqual(result, 0) self.assertIn('extrapolation into the past', error_msg)
def test_can_transform_core_pass(self): buffer_core = BufferCore() transform = build_transform('bar', 'foo', rclpy.time.Time().to_msg()) buffer_core.set_transform(transform, 'unittest') transform = build_transform('bar', 'foo', rclpy.time.Time(seconds=1).to_msg()) buffer_core.set_transform(transform, 'unittest') result, error_msg = buffer_core.can_transform_core( target_frame='foo', source_frame='bar', time=rclpy.time.Time(seconds=0.5)) self.assertEqual(result, 1) self.assertEqual(error_msg, '')