From 993d5dfce8d5bd6e9534e646dd0964a340b85493 Mon Sep 17 00:00:00 2001 From: Tomoya Fujita Date: Mon, 29 Jul 2024 10:12:10 -0700 Subject: [PATCH] add examples with using TimerInfo. https://github.com/ros2/rclpy/pull/1292 Signed-off-by: Tomoya Fujita --- prover_rclpy/src/rclpy_1265.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/prover_rclpy/src/rclpy_1265.py b/prover_rclpy/src/rclpy_1265.py index d857dbf..ac90e03 100644 --- a/prover_rclpy/src/rclpy_1265.py +++ b/prover_rclpy/src/rclpy_1265.py @@ -58,6 +58,21 @@ def timer_callback(node, executor, info: TimerInfo): finally: pass + try: + print("----- test 4") + # pass, i think correct behavior, info is appended as extra argument. + def timer_callback(foobar: TimerInfo): + print(foobar) + print(foobar.expected_call_time) + print(foobar.actual_call_time) + + timer = node.create_timer(1, timer_callback) + executor.spin_once(2) + timer.cancel() + node.destroy_timer(timer) + finally: + pass + executor.shutdown() node.destroy_node() rclpy.shutdown()