Skip to content

Commit d4246d5

Browse files
kaiaaiclaude
andcommitted
oomwoo_sim_support: fix initialpose_pub sim-clock race
self.start was captured in __init__, where get_clock().now() can read 0 under use_sim_time (no /clock yet). Every _elapsed() then returned the absolute sim time, so when the node starts against an already-running sim (elapsed > timeout_sec) it fired the fail-open and exited WITHOUT ever seeding /initialpose -- AMCL never localized, no map->odom. Baseline self.start on the first tick instead, once the clock is running. Verified: elapsed now reads real seconds (localize at ~3s) instead of 44s/270s. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 3638553 commit d4246d5

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/oomwoo_sim_support/oomwoo_sim_support/initialpose_pub_node.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ def __init__(self) -> None:
6060

6161
self.localized = False
6262
self.reseeds = 0
63-
self.start = self.get_clock().now()
63+
# Captured on the first tick, not here: under use_sim_time get_clock()
64+
# can read 0 at construction (no /clock yet), which would make every
65+
# _elapsed() look like the absolute sim time and trip the fail-open
66+
# before we ever seed. Baseline once the clock is actually running.
67+
self.start = None
6468

6569
self.pub = self.create_publisher(
6670
PoseWithCovarianceStamped, 'initialpose', 10)
@@ -93,6 +97,10 @@ def _seed(self) -> None:
9397
self.pub.publish(msg)
9498

9599
def _tick(self) -> None:
100+
if self.start is None:
101+
# clock is running now; baseline elapsed from here
102+
self.start = self.get_clock().now()
103+
return
96104
el = self._elapsed()
97105
if self.localized:
98106
self.get_logger().info(

0 commit comments

Comments
 (0)