Skip to content

TimeSource: apply use_sim_time from a post-set callback, drop /parameter_events subscription - #6

Open
jplapp wants to merge 1 commit into
jazzy-updatedfrom
jazzy-updated-timesource-post-set-callback
Open

jplapp wants to merge 1 commit into
jazzy-updatedfrom
jazzy-updated-timesource-post-set-callback

Conversation

@jplapp

@jplapp jplapp commented Sep 20, 2026

Copy link
Copy Markdown

Why

Every node's TimeSource subscribes to /parameter_events only to notice a change of its own use_sim_time (upstream TODO ros2#609). With N nodes, each declare_parameter of each node is delivered to all N nodes and dropped by N-1 of them. On an AMR (234 nodes) that is about 10k events to about 210 subscribers during startup.

Change

use_sim_time is applied in a local post-set-parameters callback. The subscription and the on_parameter_event handler are removed.

Measured on amr47 (stack restart, container start until nav2 "Managed nodes are active")

time /parameter_events subscribers
before (3 boots) 70.6 / 71.2 / 72.7 s 210
after (2 boots) 59.6 / 62.0 s 24

All 234 nodes came up, with the same died/traceback counts in the launch log as before.

Behaviour notes

  • The value given at startup (launch argument / yaml) is handled exactly as before.
  • When use_sim_time is switched on at runtime, the /clock subscription is created without the QoS override parameters, because parameters cannot be declared from within a parameter callback. (This is the reason upstream went through the topic.) Tested on an isolated domain with static_transform_publisher: ros2 param set ... use_sim_time true/false/true/false/true all succeed and the /clock subscription appears and disappears.
  • Deleting use_sim_time is no longer tracked (parameter_state_ = UNSET); the parameter is declared by the TimeSource itself.
  • Lock order, for review: the new callback takes node_base_lock_ while the parameter mutex is held; attachNode takes them the other way round, but registers the callback as its last step.
  • Nodes that read other nodes' parameter events keep working, since the publishers are unchanged: foxglove_bridge, SmacPlannerHybrid (global costmap resolution), the rosbag recorder.

Not run: the rclcpp unit tests (test_time_source). Built with BUILD_TESTING=OFF on the robot and on the dev machine. The version tested on the robot still contained the unused on_parameter_event; its removal was compile-checked only.

🤖 Generated with Claude Code

https://claude.ai/code/session_011FfCzN8XKNXLTuCXBWJcK5

…ter_events subscription

Every node's TimeSource subscribed to /parameter_events only to see its own
use_sim_time change (upstream TODO ros2#609). With N nodes every declare_parameter of
every node is delivered to, and dropped by, all N nodes. On an AMR (234 nodes) this
is ~10k events x ~210 subscribers during startup.

use_sim_time is now applied in a local post-set-parameters callback. Measured on
amr47: /parameter_events subscribers 210 -> 24, container start to nav2 active
~71 s -> ~61 s.

The /clock subscription is created without QoS override parameters when
use_sim_time is switched on at runtime, because parameters cannot be declared from
within a parameter callback. The value given at startup is handled as before.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011FfCzN8XKNXLTuCXBWJcK5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant