-
Notifications
You must be signed in to change notification settings - Fork 412
Add ROS 2 integration tests #1024
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
12 commits
Select commit
Hold shift + click to select a range
2b374f7
Add ROS 2 integration tests
EzraBrooks 883654f
Get Param test passing in both ROS 1 and ROS 2
EzraBrooks 3f9991e
Rewrite pubsub test to accomodate ROS 2 nondeterministic topic order
EzraBrooks 53a7d35
Make Params and Topics tests less fragile
EzraBrooks 6403f6f
Skip getParams test on Humble due to upstream bug
EzraBrooks 310c315
Clarify assertions in Service test
EzraBrooks 0636126
Enable call_services_in_new_thread on rosbridge
EzraBrooks c406ad3
remove annoying log from fibonacci example
EzraBrooks 90902f6
Lengthen timeout on slow test on ROS 1
EzraBrooks 39004c4
Add kilted, rolling to CI
EzraBrooks 76fc87e
I don't have the time in my life to support rolling
EzraBrooks d3d5bfe
add comments about humble EOL
EzraBrooks 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
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 |
|---|---|---|
| @@ -1,72 +1,57 @@ | ||
| import { describe, it, expect } from "vitest"; | ||
| import { describe, it, expect, vi } from "vitest"; | ||
| import * as ROSLIB from "../../src/RosLib.js"; | ||
|
|
||
| const expectedTopics = [ | ||
| /* | ||
| * '/turtle1/cmd_vel', '/turtle1/color_sensor', '/turtle1/pose', | ||
| * '/turtle2/cmd_vel', '/turtle2/color_sensor', '/turtle2/pose', | ||
| */ | ||
| "/tf2_web_republisher/status", | ||
| "/tf2_web_republisher/feedback", | ||
| // '/tf2_web_republisher/goal', '/tf2_web_republisher/result', | ||
| "/fibonacci/feedback", | ||
| "/fibonacci/status", | ||
| "/fibonacci/result", | ||
| ]; | ||
|
Comment on lines
-4
to
-15
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test data is ROS-1-only and wasn't even sensical.. it didn't check for the one thing unique to our test suites, the |
||
| const expectedTopics = ["/listener"]; | ||
|
|
||
| describe("Example topics are live", function () { | ||
| const ros = new ROSLIB.Ros({ | ||
| url: "ws://localhost:9090", | ||
| }); | ||
|
|
||
| it("getTopics", () => | ||
| new Promise((done) => { | ||
| ros.getTopics(function (result) { | ||
| expectedTopics.forEach(function (topic) { | ||
| expect(result.topics).to.contain( | ||
| topic, | ||
| "Couldn't find topic: " + topic, | ||
| ); | ||
| }); | ||
| done(result); | ||
| }); | ||
| })); | ||
| it("getTopics", async () => { | ||
| const callback = vi.fn(); | ||
| ros.getTopics(callback); | ||
| await vi.waitFor(() => { | ||
| expect(callback).toHaveBeenCalledOnce(); | ||
| for (const topic of expectedTopics) { | ||
| expect(callback.mock.calls[0][0].topics).to.contain(topic); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| const example = ros.Topic({ | ||
| name: "/some_test_topic", | ||
| messageType: "std_msgs/String", | ||
| }); | ||
|
|
||
| it("doesn't automatically advertise the topic", () => | ||
| new Promise((done) => { | ||
| ros.getTopics(function (result) { | ||
| expect(result.topics).not.to.contain("/some_test_topic"); | ||
| example.advertise(); | ||
| done(result); | ||
| }); | ||
| })); | ||
| it("doesn't automatically advertise the topic", async () => { | ||
| const callback = vi.fn(); | ||
| ros.getTopics(callback); | ||
| await vi.waitFor(() => { | ||
| expect(callback).toHaveBeenCalledOnce(); | ||
| expect(callback.mock.calls[0][0].topics).not.to.contain( | ||
| "/some_test_topic", | ||
| ); | ||
| }); | ||
| example.advertise(); | ||
| }); | ||
|
|
||
| it("advertise broadcasts the topic", () => | ||
| new Promise((done) => { | ||
| ros.getTopics(function (result) { | ||
| expect(result.topics).to.contain("/some_test_topic"); | ||
| example.unadvertise(); | ||
| done(result); | ||
| }); | ||
| })); | ||
| it("advertise broadcasts the topic", async () => { | ||
| const callback = vi.fn(); | ||
| ros.getTopics(callback); | ||
| await vi.waitFor(() => { | ||
| expect(callback).toHaveBeenCalledOnce(); | ||
| expect(callback.mock.calls[0][0].topics).to.contain("/some_test_topic"); | ||
| }); | ||
| example.unadvertise(); | ||
| }); | ||
|
|
||
| it( | ||
| "unadvertise will end the topic (if it's the last around)", | ||
| () => | ||
| new Promise((done) => { | ||
| console.log("Unadvertisement test. Wait for 15 seconds.."); | ||
| setTimeout(function () { | ||
| ros.getTopics(function (result) { | ||
| expect(result.topics).not.to.contain("/some_test_topic"); | ||
| done(result); | ||
| }); | ||
| }, 15000); | ||
| }), | ||
| 20000, | ||
| ); | ||
| it("unadvertise will end the topic (if it's the last around)", async () => { | ||
| const callback = vi.fn(); | ||
| ros.getTopics(callback); | ||
| vi.waitFor(function () { | ||
| expect(callback).toHaveBeenCalledOnce(); | ||
| expect(callback.mock.calls[0][0]).not.to.contain("/some_test_topic"); | ||
| }, 15000); | ||
| }); | ||
| }); | ||
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 |
|---|---|---|
| @@ -1,62 +1,65 @@ | ||
| import { describe, it, expect } from "vitest"; | ||
| import * as ROSLIB from "../../src/RosLib.js"; | ||
|
|
||
| describe("Fibonacci Example", function () { | ||
| it( | ||
| "Fibonacci", | ||
| () => | ||
| new Promise<void>((done) => { | ||
| const ros = new ROSLIB.Ros({ | ||
| url: "ws://localhost:9090", | ||
| }); | ||
| /* | ||
| * The ActionClient | ||
| * ---------------- | ||
| */ | ||
| // Noetic is the only version of ROS 1 we support, so we skip based on distro name | ||
| // instead of adding extra plumbing for ROS_VERSION. | ||
| describe.skipIf(process.env.ROS_DISTRO !== "noetic")( | ||
| "ROS 1 Fibonacci Example", | ||
| function () { | ||
| it( | ||
| "Fibonacci", | ||
| () => | ||
| new Promise<void>((done) => { | ||
| const ros = new ROSLIB.Ros({ | ||
| url: "ws://localhost:9090", | ||
| }); | ||
| /* | ||
| * The ActionClient | ||
| * ---------------- | ||
| */ | ||
|
|
||
| const fibonacciClient = new ROSLIB.ActionClient({ | ||
| ros: ros, | ||
| serverName: "/fibonacci", | ||
| actionName: "actionlib_tutorials/FibonacciAction", | ||
| }); | ||
| const fibonacciClient = new ROSLIB.ActionClient({ | ||
| ros: ros, | ||
| serverName: "/fibonacci", | ||
| actionName: "actionlib_tutorials/FibonacciAction", | ||
| }); | ||
|
|
||
| // Create a goal. | ||
| const goal = new ROSLIB.Goal({ | ||
| actionClient: fibonacciClient, | ||
| goalMessage: { | ||
| order: 7, | ||
| }, | ||
| }); | ||
| // Create a goal. | ||
| const goal = new ROSLIB.Goal({ | ||
| actionClient: fibonacciClient, | ||
| goalMessage: { | ||
| order: 7, | ||
| }, | ||
| }); | ||
|
|
||
| // Print out their output into the terminal. | ||
| const items = [ | ||
| { sequence: [0, 1, 1] }, | ||
| { sequence: [0, 1, 1, 2] }, | ||
| { sequence: [0, 1, 1, 2, 3] }, | ||
| { sequence: [0, 1, 1, 2, 3, 5] }, | ||
| { sequence: [0, 1, 1, 2, 3, 5, 8] }, | ||
| { sequence: [0, 1, 1, 2, 3, 5, 8, 13] }, | ||
| { sequence: [0, 1, 1, 2, 3, 5, 8, 13, 21] }, | ||
| ]; | ||
| goal.on("feedback", function (feedback) { | ||
| console.log("Feedback:", feedback); | ||
| expect(feedback).to.eql(items.shift()); | ||
| }); | ||
| goal.on("result", function (result) { | ||
| console.log("Result:", result); | ||
| expect(result).to.eql({ sequence: [0, 1, 1, 2, 3, 5, 8, 13, 21] }); | ||
| done(); | ||
| }); | ||
| // Print out their output into the terminal. | ||
| const items = [ | ||
| { sequence: [0, 1, 1] }, | ||
| { sequence: [0, 1, 1, 2] }, | ||
| { sequence: [0, 1, 1, 2, 3] }, | ||
| { sequence: [0, 1, 1, 2, 3, 5] }, | ||
| { sequence: [0, 1, 1, 2, 3, 5, 8] }, | ||
| { sequence: [0, 1, 1, 2, 3, 5, 8, 13] }, | ||
| { sequence: [0, 1, 1, 2, 3, 5, 8, 13, 21] }, | ||
| ]; | ||
| goal.on("feedback", function (feedback) { | ||
| expect(feedback).to.eql(items.shift()); | ||
| }); | ||
| goal.on("result", function (result) { | ||
| expect(result).to.eql({ sequence: [0, 1, 1, 2, 3, 5, 8, 13, 21] }); | ||
| done(); | ||
| }); | ||
|
|
||
| /* | ||
| * Send the goal to the action server. | ||
| * The timeout is to allow rosbridge to properly subscribe all the | ||
| * Action topics - otherwise, the first feedback message might get lost | ||
| */ | ||
| setTimeout(function () { | ||
| goal.send(); | ||
| }, 100); | ||
| }), | ||
| 8000, | ||
| ); | ||
| }); | ||
| /* | ||
| * Send the goal to the action server. | ||
| * The timeout is to allow rosbridge to properly subscribe all the | ||
| * Action topics - otherwise, the first feedback message might get lost | ||
| */ | ||
| setTimeout(function () { | ||
| goal.send(); | ||
| }, 100); | ||
| }), | ||
| 8000, | ||
| ); | ||
| }, | ||
| ); |
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.