Add support check for content filter feature in subscription#1451
Add support check for content filter feature in subscription#1451minggangw wants to merge 15 commits intoRobotWebTools:developfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a Subscription-level API to check whether content-filtering topics are supported by the underlying ROS 2 middleware, exposing it through the JS API, native bindings, and TypeScript typings, with accompanying tests.
Changes:
- Add
Subscription.isContentFilterSupported()to JS and TypeScript types. - Expose a new native binding
isContentFilterSupportedbacked byrcl_subscription_is_cft_supported. - Add type-level and runtime tests for the new API.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
lib/subscription.js |
Adds JS-facing isContentFilterSupported() method on Subscription. |
src/rcl_subscription_bindings.cpp |
Adds N-API binding that calls rcl_subscription_is_cft_supported and exports it. |
types/subscription.d.ts |
Extends the Subscription TypeScript interface with isContentFilterSupported(): boolean. |
test/types/index.test-d.ts |
Adds type assertion coverage for isContentFilterSupported(). |
test/test-subscription-content-filter.js |
Adds runtime test validating the method returns a boolean and matches expected capability heuristics. |
rosidl_parser/parser.py |
Modifies CLI arg-count error output/message (appears unrelated to PR goal). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
rosidl_parser/parser.py
Outdated
| if __name__ == '__main__': | ||
| if len(sys.argv) < 4: | ||
| print('Usage: {} <command> <packageName> <filePath>'.format(sys.argv[0]), file=sys.stderr) | ||
| print('Wrong number of argments') |
There was a problem hiding this comment.
The argument-count check regresses error reporting: it now prints a generic message to stdout and drops the detailed usage message (previously printed to stderr). This makes failures from rosidl_parser/rosidl_parser.js much harder to diagnose because the Node-side error includes stderr was: ... and will now often be empty. Consider restoring the original Usage: <command> <packageName> <filePath> message and printing it to stderr.
| print('Wrong number of argments') | |
| print(f'Usage: {sys.argv[0]} <command> <packageName> <filePath>', file=sys.stderr) |
rosidl_parser/parser.py
Outdated
| if __name__ == '__main__': | ||
| if len(sys.argv) < 4: | ||
| print('Usage: {} <command> <packageName> <filePath>'.format(sys.argv[0]), file=sys.stderr) | ||
| print('Wrong number of argments') |
There was a problem hiding this comment.
Typo in the error message: "argments" should be "arguments".
| print('Wrong number of argments') | |
| print('Wrong number of arguments') |
| if len(sys.argv) < 4: | ||
| print('Usage: {} <command> <packageName> <filePath>'.format(sys.argv[0]), file=sys.stderr) | ||
| print('Wrong number of argments') | ||
| sys.exit(1) |
There was a problem hiding this comment.
This change in rosidl_parser/parser.py (updating the CLI arg-count error message) doesn’t appear related to the PR’s stated goal of adding a subscription content-filter support check. If it’s not required for the feature, consider reverting it or splitting it into a separate PR to keep changes focused.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| rosdep init || true | ||
| rosdep update | ||
| rosdep install --from-paths /opt/ros/rolling/share --ignore-src -y --skip-keys "cyclonedds fastcdr fastdds iceoryx_binding_c rmw_connextdds rti-connext-dds-7.3.0 urdfdom_headers" |
There was a problem hiding this comment.
In the Rolling nightly install step, rosdep install is run before any source /opt/ros/rolling/setup.bash (and without --rosdistro rolling). In a clean container this often means ROS_DISTRO is unset, causing rosdep install to fail or resolve against the wrong distro. Consider sourcing the newly extracted /opt/ros/rolling/setup.bash (or at least export ROS_DISTRO=rolling, or add --rosdistro rolling) before running rosdep update/install so dependency resolution is deterministic.
| rosdep init || true | |
| rosdep update | |
| rosdep install --from-paths /opt/ros/rolling/share --ignore-src -y --skip-keys "cyclonedds fastcdr fastdds iceoryx_binding_c rmw_connextdds rti-connext-dds-7.3.0 urdfdom_headers" | |
| export ROS_DISTRO=rolling | |
| rosdep init || true | |
| rosdep update | |
| rosdep install --rosdistro rolling --from-paths /opt/ros/rolling/share --ignore-src -y --skip-keys "cyclonedds fastcdr fastdds iceoryx_binding_c rmw_connextdds rti-connext-dds-7.3.0 urdfdom_headers" |
| #if ROS_VERSION > 2505 // Rolling only | ||
| Napi::Value IsContentFilterSupported(const Napi::CallbackInfo& info) { | ||
| Napi::Env env = info.Env(); | ||
|
|
||
| RclHandle* subscription_handle = | ||
| RclHandle::Unwrap(info[0].As<Napi::Object>()); | ||
| rcl_subscription_t* subscription = | ||
| reinterpret_cast<rcl_subscription_t*>(subscription_handle->ptr()); | ||
|
|
||
| bool is_supported = rcl_subscription_is_cft_supported(subscription); | ||
| return Napi::Boolean::New(env, is_supported); | ||
| } | ||
| #endif |
There was a problem hiding this comment.
The preprocessor guard #if ROS_VERSION > 2505 is commented as “Rolling only”, but > 2505 will also evaluate true for any future non-Rolling distro IDs (e.g., 2605, 2705, …). This can (a) cause build failures if rcl_subscription_is_cft_supported() remains Rolling-only, and (b) diverge from the JS runtime guard which only enables the method on DistroId.ROLLING. Consider aligning both sides by guarding on the same threshold (e.g., ROS_VERSION >= 5000 if it’s truly Rolling-only, or updating the JS guard/comment if the API is expected to exist on post-Kilted stable distros too).
Corresponding to rclpy d892204 and rcl's
rcl_subscription_is_cft_supported()API, this addsisContentFilterSupported()to theSubscriptionclass. This allows users to query at runtime whether the underlying RMW supports content-filtered topics for a given subscription, rather than relying on hardcoded RMW name checks. Currently gated to ROS 2 Rolling only (ROS_VERSION > 2505); on older distros it returnsfalse.Feature changes
IsContentFilterSupported()N-API function callingrcl_subscription_is_cft_supported(), guarded by#if ROS_VERSION > 2505. Added#include <rcl/subscription.h>. Registered as"isContentFilterSupported"inInitSubscriptionBindings().isContentFilterSupported()method with a distro guard (DistroUtils.getDistroId() < ROLLINGreturnsfalse). AddedDistroUtilsimport.isContentFilterSupported(): booleanto theSubscriptioninterface.describe('subscription isContentFilterSupported')block that runs on all distros. Validates the return value accounts for both the rolling requirement and RMW capability.expectType<boolean>assertion forisContentFilterSupported().CI changes
setup-roswithuse-ros2-testingfor rolling with a nightly binary tarball approach, following the official ROS 2 Rolling binary installation guide:ros2-apt-sourcedeb package.test-msgs,mrpt-msgs,colcon,rosdep) before extracting the nightly tarball, so the nightly's newer libs (e.g.librcutils.sowithrcutils_decode_base64) overwrite apt's older versions.--strip-components=1into/opt/ros/rolling/so everything lives under one prefix — singlesource /opt/ros/rolling/setup.bashlike all other distros.rosdep installfor remaining runtime dependencies.xvfb,libgtk-3-0, etc.) into its own step that runs for all distros.-ytoapt installfor test-msgs.use-ros2-testingparameter fromsetup-ros.Fix: #1450