Repository navigation
test(rtps): interop cases for lease liveliness, many participants, and the CycloneDDS addressing fixes #874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
92c820f
test(rtps): interop cases for lease liveliness and a busy domain, on …
finger563 735c9b6
test(rtps): interop liveliness window past the worst-case expiry; lif…
finger563 bf0b16e
test(rtps): interop review follow-ups; note why only the espp-publish…
finger563 20bd968
Merge branch 'main' into test/rtps-interop-dds-cases
finger563 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| #!/usr/bin/env python3 | ||
| """Count std_msgs/String samples from a ROS 2 subscriber for a fixed time. | ||
|
|
||
| Used by the interop harness as the ROS 2 side of the liveliness cases: | ||
| `ros2 topic echo --once` proves one sample arrived, this proves samples KEEP | ||
| arriving - samples received earlier than `count_after_s` seconds after start | ||
| are reported but not counted, so a peer that stops being served once its | ||
| participant lease has expired cannot pass. | ||
|
|
||
| Usage: ros2_count_subscriber.py TOPIC [--seconds S] [--required N] [--count-after S] | ||
| [--reliability reliable|best_effort] | ||
| Exits 0 iff at least REQUIRED samples arrived after COUNT_AFTER seconds, 2 on | ||
| bad arguments. | ||
| """ | ||
|
|
||
| import argparse | ||
| import sys | ||
| import time | ||
|
|
||
| import rclpy | ||
| from rclpy.qos import QoSProfile, ReliabilityPolicy | ||
| from std_msgs.msg import String | ||
|
|
||
|
|
||
| def non_negative(text: str) -> float: | ||
| value = float(text) | ||
| if value < 0: | ||
| raise argparse.ArgumentTypeError(f"must be >= 0, got {text}") | ||
| return value | ||
|
|
||
|
|
||
| def parse_args(argv: list[str]) -> argparse.Namespace: | ||
| parser = argparse.ArgumentParser( | ||
| description="Count std_msgs/String samples on a topic for a fixed time; " | ||
| "samples before --count-after are reported but not counted." | ||
| ) | ||
| parser.add_argument("topic", nargs="?", default="/chatter") | ||
| parser.add_argument("--seconds", type=non_negative, default=25.0, help="how long to listen") | ||
| parser.add_argument("--required", type=int, default=10, help="counted samples needed to pass") | ||
| parser.add_argument( | ||
| "--count-after", type=non_negative, default=0.0, help="seconds before counting starts" | ||
| ) | ||
| parser.add_argument( | ||
| "--reliability", choices=("reliable", "best_effort"), default="reliable" | ||
| ) | ||
| args = parser.parse_args(argv) | ||
| if args.required < 0: | ||
| parser.error(f"--required must be >= 0, got {args.required}") | ||
| return args | ||
|
|
||
|
|
||
| def main() -> int: | ||
| args = parse_args(sys.argv[1:]) | ||
| topic = args.topic | ||
| seconds = args.seconds | ||
| required = args.required | ||
| count_after_s = args.count_after | ||
| reliable = args.reliability == "reliable" | ||
|
|
||
| rclpy.init() | ||
| node = rclpy.create_node("countsub") | ||
| qos = QoSProfile(depth=10) | ||
| qos.reliability = ReliabilityPolicy.RELIABLE if reliable else ReliabilityPolicy.BEST_EFFORT | ||
| start = time.time() | ||
| counts = {"early": 0, "counted": 0} | ||
|
|
||
| def on_sample(_msg: String) -> None: | ||
| if time.time() - start < count_after_s: | ||
| counts["early"] += 1 | ||
| else: | ||
| counts["counted"] += 1 | ||
| if counts["counted"] <= 3 or counts["counted"] % 25 == 0: | ||
| print(f"received {counts['counted']} (t={time.time() - start:.1f}s)", flush=True) | ||
|
|
||
| node.create_subscription(String, topic, on_sample, qos) | ||
| while time.time() - start < seconds: | ||
| rclpy.spin_once(node, timeout_sec=0.1) | ||
|
|
||
| ok = counts["counted"] >= required | ||
| print( | ||
| f"{'PASS' if ok else 'FAIL'} received={counts['counted']} required={required} " | ||
| f"(not counted, before {count_after_s:.0f}s: {counts['early']})", | ||
| flush=True, | ||
| ) | ||
| node.destroy_node() | ||
| rclpy.shutdown() | ||
| return 0 if ok else 1 | ||
|
finger563 marked this conversation as resolved.
Resolved
|
||
|
|
||
|
|
||
|
finger563 marked this conversation as resolved.
Resolved
|
||
| if __name__ == "__main__": | ||
| sys.exit(main()) | ||
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.