Skip to content

Commit

Permalink
add examples with using TimerInfo.
Browse files Browse the repository at this point in the history
  ros2/rclpy#1292

Signed-off-by: Tomoya Fujita <[email protected]>
  • Loading branch information
fujitatomoya committed Jul 29, 2024
1 parent e29d00c commit 993d5df
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions prover_rclpy/src/rclpy_1265.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 993d5df

Please sign in to comment.