Skip to content

Commit

Permalink
Store time source clocks in a set (#1146)
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Della Vedova <[email protected]>
  • Loading branch information
luca-della-vedova authored Aug 3, 2023
1 parent 5367703 commit 540b809
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rclpy/rclpy/time_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class TimeSource:
def __init__(self, *, node=None):
self._clock_sub = None
self._node_weak_ref = None
self._associated_clocks = []
self._associated_clocks = set()
# Zero time is a special value that means time is uninitialzied
self._last_time_set = Time(clock_type=ClockType.ROS_TIME)
self._ros_time_is_active = False
Expand Down Expand Up @@ -113,7 +113,7 @@ def attach_clock(self, clock):

clock.set_ros_time_override(self._last_time_set)
clock._set_ros_time_is_active(self.ros_time_is_active)
self._associated_clocks.append(clock)
self._associated_clocks.add(clock)

def clock_callback(self, msg):
# Cache the last message in case a new clock is attached.
Expand Down

0 comments on commit 540b809

Please sign in to comment.