Skip to content

Commit e2eec14

Browse files
committed
Addressed the comment.
1 parent 8eca2c7 commit e2eec14

File tree

18 files changed

+94
-66
lines changed

18 files changed

+94
-66
lines changed

.github/workflows/humble_docker_test.yaml

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,41 @@
1-
name: Humble_test_with_docker_NativeROS_string
1+
name: Humble_buid_and_test_with_docker_NativeROS_string
22

33
on:
44
push:
55
branches:
66
- "main"
77
pull_request:
8-
types: [opened, synchronize, labeled]
8+
types: [opened, synchronize]
99
jobs:
1010
ci:
11-
runs-on: ${{ matrix.os }}
12-
if: |
13-
((github.event.action == 'labeled') && (github.event.label.name == 'TESTING') && (github.base_ref == 'main' )) ||
14-
((github.event.action == 'synchronize') && (github.base_ref == 'main') && contains(github.event.pull_request.labels.*.name, 'TESTING')) ||
15-
(github.ref_name == 'main')
11+
runs-on: ubuntu-latest
1612
container:
17-
image: osrf/ros:${{ matrix.ros_distribution }}-desktop
13+
image: osrf/ros:humble-desktop
1814
timeout-minutes: 5
1915
strategy:
2016
fail-fast: false
21-
matrix:
22-
os: [ubuntu-22.04]
23-
ros_distribution: [humble]
17+
# matrix:
2418
steps:
2519
- name: Checkout code
26-
uses: actions/checkout@v3
20+
uses: actions/checkout@v4
2721
with:
2822
submodules: recursive
2923
- name: Set up Docker Buildx
3024
uses: docker/setup-buildx-action@v1
3125

3226
- name: Install Docker Compose
3327
run: sudo apt-get update && sudo apt-get install -y docker-compose
34-
# docker-compose.yml を使ってコンテナを起動
28+
# runs containers using docker-compose.yml
3529
- name: Build and run containers
36-
run: docker-compose up -d
30+
run: |
31+
cd workspace/test/mros2
32+
docker-compose up -d
33+
cd -
3734
- name: Wait for containers to start
38-
run: sleep 20 # コンテナが確実に起動するのを待つ時間を長くする
35+
run: sleep 20 # wait time for container startup.
3936
- name: List running containers
40-
run: docker ps -a # 全コンテナが起動しているか確認
41-
- name: Show container logs # コンテナのログを確認する
37+
run: docker ps -a # Check if all containers are running.
38+
- name: Show container logs
4239
run: |
4340
docker logs app1
4441
docker logs app2
@@ -52,28 +49,28 @@ jobs:
5249
docker exec app2 ping -c 4 172.19.0.2 # app2 から app1 へのPing
5350
- name: Test TCP connection between containers (netcat)
5451
run: |
55-
# app2でポート8080をリスン
52+
# Listen port 8080 on app2
5653
docker exec -d app2 bash -c "nc -l -p 8080"
57-
# app1からapp2へのTCP接続を確認
54+
# Check connection to app2 from app1
5855
docker exec app1 bash -c "echo 'Test' | nc -w 3 172.19.0.3 8080"
59-
# app1: ビルドの準備 (chmod +x update_ip.sh ./update_ip.sh の実行)
56+
# app1: prepare build (run chmod +x update_ip.sh and ./update_ip.sh)
6057
- name: Prepare build in mros
6158
run: |
62-
docker cp $GITHUB_WORKSPACE app1:/root/ws_mros # ソースコードをapp1コンテナにコピー
59+
docker cp $GITHUB_WORKSPACE app1:/root/ws_mros # Copy source code to app1
6360
docker exec app1 bash -c "
6461
cd /root/ws_mros &&
65-
chmod +x update_ip.sh && # 権限変更
66-
./update_ip.sh" # IPアドレス更新スクリプトの実行
67-
# app1: クリーンビルド
62+
chmod +x update_ip.sh && # Change grant
63+
./update_ip.sh" # Run script to overwrite IP address.
64+
# app1: clean and build
6865
- name: Clean and build in mros
6966
run: |
7067
docker exec app1 bash -c "
7168
cd /root/ws_mros &&
7269
pwd &&
7370
ls -la &&
74-
bash build.bash clean && # クリーンアップ
75-
bash build.bash all test_echoback_string"
76-
# app2: のコードをコンテナにコピーしてビルド
71+
bash build.bash clean &&
72+
bash build.bash all test/mros2/test_echoback_string"
73+
# app2:
7774
- name: Clone Native test stub source code to app2 and build and run
7875
run: |
7976
docker exec app2 bash -c "
@@ -89,21 +86,22 @@ jobs:
8986
- name: Run mROS and Native ROS
9087
shell: bash
9188
run : |
92-
# テスト対象をバックグラウンドで実行
89+
# Run native ROS respondeer in background
9390
docker exec app2 bash -c "source /opt/ros/humble/setup.bash &&
9491
cd mros2-host-examples &&
9592
source install/setup.bash &&
9693
ros2 run mros2_echoreply_string echoreply_node" &
9794
9895
docker exec app1 bash -c "cd /root/ws_mros && ./cmake_build/mros2-posix" &
99-
mros_pid=$! # テストプログラムのプロセスIDを取得
96+
mros_pid=$! # get mROS process id
10097
10198
docker ps
10299
103-
# mROSが終了するまで待つ
100+
# Wait until mROS finishes
104101
wait $mros_pid
105102
mros_status=$?
106-
# 結果に基づいてCIの成否を判断
103+
104+
# Judge CI success based on results
107105
if [ $mros_status -eq 0 ] ;then
108106
echo "Succeed pub/sub test process between mros2 and Native ROS"
109107
exit 0

.github/workflows/humble_test.yaml

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,25 @@
1-
name: ci_humble
1+
name: Humble_build_and_test
22

33
on:
44
push:
55
branches:
66
- "main"
7-
- "feat/add_ci_config"
87
pull_request:
9-
types: [opened, synchronize, labeled]
8+
types: [opened, synchronize ]
109
jobs:
11-
ci:
12-
runs-on: ${{ matrix.os }}
13-
if: |
14-
((github.event.action == 'labeled') && (github.event.label.name == 'TESTING') && (github.base_ref == 'main' )) ||
15-
((github.event.action == 'synchronize') && (github.base_ref == 'main') && contains(github.event.pull_request.labels.*.name, 'TESTING')) ||
16-
(github.ref_name == 'main')
10+
build_and_test:
11+
runs-on: ubuntu-latest
1712
container:
18-
image: osrf/ros:${{ matrix.ros_distribution }}-desktop
13+
image: osrf/ros:humble-desktop
1914
timeout-minutes: 3
2015
strategy:
2116
fail-fast: false
2217
matrix:
23-
os: [ubuntu-22.04]
2418
ros_distribution: [humble]
2519
comm-target: [native , mros]
2620
comm-data-type: [string, twist]
2721
steps:
28-
- uses: actions/checkout@v3
22+
- uses: actions/checkout@v4
2923
with:
3024
submodules: recursive
3125
- name: update
@@ -35,7 +29,7 @@ jobs:
3529
sudo apt-get install -y iproute2 git wget build-essential gcc g++ libssl-dev libreadline-dev
3630
zlib1g-dev make autoconf automake cmake pkg-config curl net-tools netcat python3-jinja2
3731
- name: Clone Test Stub
38-
uses: actions/checkout@v3
32+
uses: actions/checkout@v4
3933
with:
4034
repository: mROS-base/mros2-host-examples
4135
path: ws_host/src/mros2-host-examples
@@ -54,7 +48,7 @@ jobs:
5448
shell: bash
5549
run: |
5650
bash build.bash clean
57-
bash build.bash all test_echoback_${{ matrix.comm-data-type }}
51+
bash build.bash all test/mros2/test_echoback_${{ matrix.comm-data-type }}
5852
mv cmake_build/ test_echoback_${{ matrix.comm-data-type }}/
5953
- name: Build Native ROS responder
6054
if: matrix.comm-target == 'native'
@@ -68,25 +62,25 @@ jobs:
6862
shell: bash
6963
run: |
7064
bash build.bash clean
71-
bash build.bash all test_echoback_${{ matrix.comm-data-type }}_responder
65+
bash build.bash all test/mros2/test_echoback_${{ matrix.comm-data-type }}_responder
7266
- name: Run Testing mROS and Native ROS
7367
if: matrix.comm-target == 'native'
7468
shell: bash
7569
run : |
7670
./test_echoback_${{ matrix.comm-data-type }}/mros2-posix &
77-
mros_pid=$! # mROSのプロセスIDを取得
71+
mros_pid=$! # get mROS process id
7872
79-
# Native ROSをバックグラウンドで実行
73+
# Run Native ROS in background
8074
cd ws_host/
8175
source /opt/ros/humble/setup.bash
8276
source install/setup.bash
8377
ros2 run mros2_echoreply_${{ matrix.comm-data-type }} echoreply_node &
8478
85-
# mROSが終了するまで待つ
79+
# Wait until mROS finishes
8680
wait $mros_pid
8781
mros_status=$?
8882
89-
# 結果に基づいてCIの成否を判断
83+
# Judge CI success based on results
9084
if [ $mros_status -eq 0 ] ;then
9185
echo "Succeed pub/sub test process between mros2 and Native ROS"
9286
exit 0
@@ -99,20 +93,20 @@ jobs:
9993
shell: bash
10094
run : |
10195
./test_echoback_${{ matrix.comm-data-type }}/mros2-posix &
102-
mros_pid=$! # テストプログラムのプロセスIDを取得
96+
mros_pid=$! # get mROS process id
10397
104-
# テスト対象をバックグラウンドで実行
98+
# Run mROS responder in background
10599
./cmake_build/mros2-posix &
106100
107-
# mROSが終了するまで待つ
101+
# Wait until mROS finishes
108102
wait $mros_pid
109103
mros_status=$?
110104
111-
# 結果に基づいてCIの成否を判断
105+
# Judge CI success based on results
112106
if [ $mros_status -eq 0 ] ;then
113-
echo "Succeed pub/sub test process between mros2 and Native ROS"
107+
echo "Succeed pub/sub test process between mros2 and mros2"
114108
exit 0
115109
else
116-
echo "Fail pub/sub test process between mros2 and Native ROS"
110+
echo "Fail pub/sub test process between mros2 and mros2"
117111
exit 1
118112
fi

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ sudo apt-get update && sudo apt-get install -y \
3737
libssl-dev libreadline-dev zlib1g-dev \
3838
make autoconf automake cmake \
3939
pkg-config curl \
40-
net-tools netcat jinja2
40+
net-tools netcat python3-jinja2
4141
```
4242

4343
Please check the IP address and netmask of the execution environment.
@@ -64,6 +64,22 @@ You need to edit the below files to set IP address and netmask.
6464
* IP address and netmask to `include/netif.h`
6565
* IP address to `include/rtps/config.h`
6666

67+
Alternatively, you can use the provided `update_ip.sh` script to automatically update these files according to your building environment.
68+
The `update_ip.sh` script is designed to overwrite the IP address and netmask in `include/rtps/config.h` and `include/netif.h` files based on the current network configuration.
69+
70+
Below is an example of using this script.
71+
72+
```bash
73+
bash update_ip.sh
74+
```
75+
76+
This script retrieves the current IP address and netmask of the system's active network interface and updates the specified files accordingly.
77+
Make sure to check the output to ensure the updates are correct before proceeding with the build.
78+
If multiple network interfaces are available, ensure the correct one is being used.
79+
80+
For troubleshooting, verify that the script runs without errors.
81+
If you encounter issues, check that the necessary network tools are installed and that your system has an active network connection.
82+
6783
## Getting Started
6884

6985
This section explains how to build and execute mros2-posix application as a Linux/POSIX process, using `echoback_string` as an example (please see workspace/README.md for another examples).

update_ip.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
#!/bin/bash
22

3-
# IPアドレスを取得
3+
# Retrieve IP address
44
IP_ADDRESS=$(hostname -I | awk '{print $1}')
55
if [ -z "$IP_ADDRESS" ]; then
66
echo "Error: Failed to retrieve IP address."
77
exit 1
88
fi
99

10-
# ネットマスクを取得(IPアドレスに対応するネットマスクを抽出)
10+
# Retrieve netmask (extract the netmask corresponding to the IP address)
1111
INTERFACE=$(ip -o addr show | grep "$IP_ADDRESS" | awk '{print $2}')
1212
NETMASK=$(ip -o -f inet addr show $INTERFACE | awk '/inet/ {print $4}' | cut -d'/' -f2)
1313
if [ -z "$NETMASK" ]; then
1414
echo "Error: Failed to retrieve netmask."
1515
exit 1
1616
fi
1717

18-
# CIDRからネットマスクを計算
18+
# Calculate netmask from CIDR
1919
function cidr_to_netmask() {
2020
local cidr=$1
2121
local mask=""
@@ -41,14 +41,14 @@ function cidr_to_netmask() {
4141
NETMASK=$(cidr_to_netmask $NETMASK)
4242
echo "Retrieved Netmask for IP $IP_ADDRESS: $NETMASK"
4343

44-
# IPアドレスをドットで分割
44+
# Split the IP address by dots
4545
IFS='.' read -r -a IP_PARTS <<< "$IP_ADDRESS"
4646

47-
# ネットマスクをドットで分割
47+
# Split the netmask by dots
4848
IFS='.' read -r -a NETMASK_PARTS <<< "$NETMASK"
4949
echo "Netmask parts: ${NETMASK_PARTS[0]}, ${NETMASK_PARTS[1]}, ${NETMASK_PARTS[2]}, ${NETMASK_PARTS[3]}"
5050

51-
# include/rtps/config.h のIPアドレス置換
51+
# Replace the IP address in include/rtps/config.h
5252

5353
echo "Running sed on include/rtps/config.h"
5454
sed -i "s/[[:space:]]*[0-9]\{1,3\},[[:space:]]*[0-9]\{1,3\},[[:space:]]*[0-9]\{1,3\},[[:space:]]*[0-9]\{1,3\}[[:space:]]*}; \
@@ -58,15 +58,15 @@ ${IP_PARTS[0]}, ${IP_PARTS[1]}, ${IP_PARTS[2]}, ${IP_PARTS[3]}};\
5858
include/rtps/config.h
5959

6060

61-
# include/netif.h のIPアドレスとネットマスク置換
61+
# Replace the IP address and netmask in include/netif.h
6262
sed -i 's/#define NETIF_IPADDR ".*"/#define NETIF_IPADDR "'$IP_ADDRESS'"/' include/netif.h
6363
sed -i 's/#define NETIF_NETMASK ".*"/#define NETIF_NETMASK "'$NETMASK'"/' include/netif.h
6464

6565

6666

67-
# 結果を表示して確認
67+
# Display the result for confirmation
6868
echo "Updated IP Address: $IP_ADDRESS"
6969
echo "Updated include/rtps/config.h:"
7070
grep -E 'Needs to be set in lwipcfg.h too.' include/rtps/config.h
7171
echo "Updated include/netif.h:"
72-
grep -E 'NETIF_IPADDR' include/netif.h
72+
grep -E 'NETIF_IPADDR' include/netif.h

workspace/test/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,23 @@ We plan to maintain them in the near future, as they remain useful (see #1).
88
(embeddedRTPS and lwip-posix)
99
* embeddedRTPS layer: [fastdds-comp](https://github.com/mROS-base/mros2-posix/tree/main/workspace/test/fastdds-comp)
1010

11+
12+
13+
## mros2 Directory Overview
14+
15+
The `mros2` directory contains several test programs and configuration files, which are actively used in the CI testing process. Below is the structure and overview of the this directory:
16+
17+
```
18+
mros2/
19+
├── docker-compose.yml
20+
├── test_echoback_string
21+
├── test_echoback_string_responder
22+
├── test_echoback_twist
23+
└── test_echoback_twist_responder
24+
```
25+
26+
- **docker-compose.yml**: This is an experimental file that was prepared for setting up the environment, but it is currently not used in the CI process. See `.github/workflows/humble_docker_test.yaml`
27+
- **test_echoback_string**: A test program that sends a string message and expects an echo response, validating communication for string messages in a ROS 2 environment. It is designed to communicate with the `mros2-host-example`'s `mros2_echoreply_string` (a test for Native ROS) and `test_echoback_string_responder` (a test for mROS). The responder listens for incoming messages and sends back the received message.
28+
- **test_echoback_string_responder**: This program subscribes to incoming string messages and echoes them back, facilitating the echo test for string messages.
29+
- **test_echoback_twist**: A test program that sends a `geometry_msgs::msg::Twist` message and expects an echo response, validating communication for Twist messages in a ROS 2 environment. It communicates with the `mros2-host-example`'s `mros2_echoreply_twist` (a test for Native ROS) and `test_echoback_twist_responder` (a test for mROS).
30+
- **test_echoback_twist_responder**: This program subscribes to incoming Twist messages and echoes them back, facilitating the echo test for Twist messages.
File renamed without changes.

0 commit comments

Comments
 (0)