Add a ROS 2 node example - #10
Merged
Merged
Conversation
Owner
Author
|
Heads-up on merge order: this branch and #9 both add a paragraph to the Build and test section of the README, so whichever one you merge second will conflict there. Nothing else across the five open PRs conflicts — I test-merged every pair. Merge them in whatever order suits you and tell me (or just merge); I'll rebase the loser rather than leave you to resolve it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An ament package under
examples/ros2/: a timer-driven node whose callback runs a three-stage CUDA pipeline, publishes its own latency on~/latency_ms, and holds itself to its timer period. Built with colcon against/opt/ros/humbleand run on real hardware before shipping.Deliberately outside the root
CMakeLists.txtand outside CI — runners have no ROS 2, and a header-only library should not make every consumer care about a dependency they do not have.examples/CMakeLists.txtnames its source explicitly, so the new subdirectory is inert to the existing build. Verified: root build and 4/4 tests unchanged.The demo earns its defaults
The first version ran at 20 ms with the callback taking 449 µs — a deadline bar at 2%, which teaches nothing. Defaults are now 5 ms and 384 taps, so the pipeline uses about 40% of its period: a loop comfortably meeting a rate you can then take away from it.
And the run that came out of that is better than anything I would have staged. Eight seconds at the defaults:
Iteration #269 spent 5.98 ms in
normalize, a stage whose median is 27.6 µs — 220x, on a kernel doing one multiply-add per element. The very next callback took 7.80 ms with every GPU stage at its normal duration, so that one was blocked before it ever reached the GPU. Two consecutive missed frames, one caused by the GPU and one not, and the report separates them. A dashboard averaging the topic would show 1.95 ms and nothing else.The example README also documents
-p period_ms:=2.0, which produces 92% met with p95 sitting exactly on the deadline — the case where a healthy mean hides a real problem.Nothing is synthetic-slowdown theatre. The stages are arithmetic rather than a real detector, but they are real GPU work with real launch costs, and every number above came off the machine.
Two things worth flagging
A real bug this turned up, not fixed here. At
period_ms:=2.5the deadline line printedMISSED 3156/3157 iterations inside budget (100.0%)— the share is%.1fof 99.968%, which rounds up. A verdict reading MISSED beside 100.0% is exactly the confusion that line exists to prevent. The fix belongs inWriteBudget, which #8 already rewrites, so putting it here would conflict; I'll add it to #8 rather than leave it or duplicate it.The maintainer email in
package.xmlisdonald-heddesheimer@users.noreply.github.comrather than the address in your commits, since apackage.xmlgets scraped by ROS index tooling. Change it if you would rather it be the real one.Build note for this machine
colcon buildneeded--cmake-args -DPython3_EXECUTABLE=/usr/bin/python3, because CMake found the miniforge python first and that one has nocatkin_pkg. That is a local environment quirk rather than anything in the package, so it is not in the README.