-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ROS2 to CI and add a small test for it
- Loading branch information
1 parent
22af997
commit d53271d
Showing
13 changed files
with
217 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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,59 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build-cpython: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
name: [ | ||
"ubuntu-py39", | ||
"ubuntu-py310", | ||
"ubuntu-py311", | ||
] | ||
include: | ||
- name: "ubuntu-py39" | ||
os: ubuntu-latest | ||
python-version: "3.9" | ||
- name: "ubuntu-py310" | ||
os: ubuntu-latest | ||
python-version: "3.10" | ||
- name: "ubuntu-py311" | ||
os: ubuntu-latest | ||
python-version: "3.11" | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install wheel | ||
- name: Install | ||
run: | | ||
python -m pip install --no-cache-dir -r requirements-dev.txt | ||
- name: Set up docker containers | ||
run: | | ||
docker build -t gramaziokohler/rosbridge:integration_tests_ros1 ./docker/ros1 | ||
docker run -d -p 9090:9090 --name rosbridge gramaziokohler/rosbridge:integration_tests_ros1 /bin/bash -c "roslaunch /integration-tests.launch" | ||
docker ps -a | ||
- name: Run linter | ||
run: | | ||
invoke check | ||
- name: Run tests | ||
run: | | ||
pytest tests/ros1 | ||
- name: Tear down docker containers | ||
run: | | ||
docker rm -f rosbridge |
This file contains 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,59 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build-cpython: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
name: [ | ||
"ubuntu-py39", | ||
"ubuntu-py310", | ||
"ubuntu-py311", | ||
] | ||
include: | ||
- name: "ubuntu-py39" | ||
os: ubuntu-latest | ||
python-version: "3.9" | ||
- name: "ubuntu-py310" | ||
os: ubuntu-latest | ||
python-version: "3.10" | ||
- name: "ubuntu-py311" | ||
os: ubuntu-latest | ||
python-version: "3.11" | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install wheel | ||
- name: Install | ||
run: | | ||
python -m pip install --no-cache-dir -r requirements-dev.txt | ||
- name: Set up docker containers | ||
run: | | ||
docker build -t gramaziokohler/rosbridge:integration_tests_ros2 ./docker/ros2 | ||
docker run -d -p 9090:9090 --name rosbridge gramaziokohler/rosbridge:integration_tests_ros2 /bin/bash -c "ros2 launch /integration-tests.launch" | ||
docker ps -a | ||
- name: Run linter | ||
run: | | ||
invoke check | ||
- name: Run tests | ||
run: | | ||
pytest tests/ros2 | ||
- name: Tear down docker containers | ||
run: | | ||
docker rm -f rosbridge |
This file contains 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 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,6 +1,4 @@ | ||
<launch> | ||
<include file="$(find-pkg-share rosbridge_server)/launch/rosbridge_websocket_launch.xml"> | ||
<arg name="port" value="9092"/> | ||
</include> | ||
<include file="$(find-pkg-share rosbridge_server)/launch/rosbridge_websocket_launch.xml" /> | ||
<!-- <node pkg="tf2_web_republisher" type="tf2_web_republisher" name="tf2_web_republisher"></node> --> | ||
</launch> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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 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,94 @@ | ||
from __future__ import print_function | ||
|
||
import threading | ||
import time | ||
|
||
from roslibpy import Message, Ros, Time, Topic | ||
from roslibpy.ros2 import Header | ||
|
||
|
||
def test_topic_pubsub(): | ||
context = dict(wait=threading.Event(), counter=0) | ||
|
||
ros = Ros("127.0.0.1", 9090) | ||
ros.run() | ||
|
||
listener = Topic(ros, "/chatter", "std_msgs/String") | ||
publisher = Topic(ros, "/chatter", "std_msgs/String") | ||
|
||
def receive_message(message): | ||
context["counter"] += 1 | ||
assert message["data"] == "hello world", "Unexpected message content" | ||
|
||
if context["counter"] == 3: | ||
listener.unsubscribe() | ||
context["wait"].set() | ||
|
||
def start_sending(): | ||
while True: | ||
if context["counter"] >= 3: | ||
break | ||
publisher.publish(Message({"data": "hello world"})) | ||
time.sleep(0.1) | ||
publisher.unadvertise() | ||
|
||
def start_receiving(): | ||
listener.subscribe(receive_message) | ||
|
||
t1 = threading.Thread(target=start_receiving) | ||
t2 = threading.Thread(target=start_sending) | ||
|
||
t1.start() | ||
t2.start() | ||
|
||
if not context["wait"].wait(10): | ||
raise Exception | ||
|
||
t1.join() | ||
t2.join() | ||
|
||
assert context["counter"] >= 3, "Expected at least 3 messages but got " + str(context["counter"]) | ||
ros.close() | ||
|
||
|
||
def test_topic_with_header(): | ||
context = dict(wait=threading.Event()) | ||
|
||
ros = Ros("127.0.0.1", 9090) | ||
ros.run() | ||
|
||
listener = Topic(ros, "/points", "geometry_msgs/PointStamped") | ||
publisher = Topic(ros, "/points", "geometry_msgs/PointStamped") | ||
|
||
def receive_message(message): | ||
assert message["header"]["frame_id"] == "base" | ||
assert message["point"]["x"] == 0.0 | ||
assert message["point"]["y"] == 1.0 | ||
assert message["point"]["z"] == 2.0 | ||
listener.unsubscribe() | ||
context["wait"].set() | ||
|
||
def start_sending(): | ||
for _ in range(3): | ||
msg = dict(header=Header(stamp=Time.now(), frame_id="base"), point=dict(x=0.0, y=1.0, z=2.0)) | ||
publisher.publish(Message(msg)) | ||
time.sleep(0.1) | ||
|
||
publisher.unadvertise() | ||
|
||
def start_receiving(): | ||
listener.subscribe(receive_message) | ||
|
||
t1 = threading.Thread(target=start_receiving) | ||
t2 = threading.Thread(target=start_sending) | ||
|
||
t1.start() | ||
t2.start() | ||
|
||
if not context["wait"].wait(10): | ||
raise Exception | ||
|
||
t1.join() | ||
t2.join() | ||
|
||
ros.close() |