Skip to content

Commit a1fc7a5

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

File tree

18 files changed

+97
-61
lines changed

18 files changed

+97
-61
lines changed

.github/workflows/humble_docker_test.yaml

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,42 @@
1-
name: Humble_test_with_docker_NativeROS_string
1+
name: 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:
1713
image: osrf/ros:${{ matrix.ros_distribution }}-desktop
1814
timeout-minutes: 5
1915
strategy:
2016
fail-fast: false
2117
matrix:
22-
os: [ubuntu-22.04]
2318
ros_distribution: [humble]
2419
steps:
2520
- name: Checkout code
26-
uses: actions/checkout@v3
21+
uses: actions/checkout@v4
2722
with:
2823
submodules: recursive
2924
- name: Set up Docker Buildx
3025
uses: docker/setup-buildx-action@v1
3126

3227
- name: Install Docker Compose
3328
run: sudo apt-get update && sudo apt-get install -y docker-compose
34-
# docker-compose.yml を使ってコンテナを起動
29+
# runs containers using docker-compose.yml
3530
- name: Build and run containers
36-
run: docker-compose up -d
31+
run: |
32+
cd workspace/test/mros2
33+
docker-compose up -d
34+
cd -
3735
- name: Wait for containers to start
38-
run: sleep 20 # コンテナが確実に起動するのを待つ時間を長くする
36+
run: sleep 20 # wait time for container startup.
3937
- name: List running containers
40-
run: docker ps -a # 全コンテナが起動しているか確認
41-
- name: Show container logs # コンテナのログを確認する
38+
run: docker ps -a # Check if all containers are running.
39+
- name: Show container logs
4240
run: |
4341
docker logs app1
4442
docker logs app2
@@ -52,28 +50,28 @@ jobs:
5250
docker exec app2 ping -c 4 172.19.0.2 # app2 から app1 へのPing
5351
- name: Test TCP connection between containers (netcat)
5452
run: |
55-
# app2でポート8080をリスン
53+
# Listen port 8080 on app2
5654
docker exec -d app2 bash -c "nc -l -p 8080"
57-
# app1からapp2へのTCP接続を確認
55+
# Check connection to app2 from app1
5856
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 の実行)
57+
# app1: prepare build (run chmod +x update_ip.sh and ./update_ip.sh)
6058
- name: Prepare build in mros
6159
run: |
62-
docker cp $GITHUB_WORKSPACE app1:/root/ws_mros # ソースコードをapp1コンテナにコピー
60+
docker cp $GITHUB_WORKSPACE app1:/root/ws_mros # Copy source code to app1
6361
docker exec app1 bash -c "
6462
cd /root/ws_mros &&
65-
chmod +x update_ip.sh && # 権限変更
66-
./update_ip.sh" # IPアドレス更新スクリプトの実行
67-
# app1: クリーンビルド
63+
chmod +x update_ip.sh && # Change grant
64+
./update_ip.sh" # Run script to overwrite IP address.
65+
# app1: clean and build
6866
- name: Clean and build in mros
6967
run: |
7068
docker exec app1 bash -c "
7169
cd /root/ws_mros &&
7270
pwd &&
7371
ls -la &&
74-
bash build.bash clean && # クリーンアップ
75-
bash build.bash all test_echoback_string"
76-
# app2: のコードをコンテナにコピーしてビルド
72+
bash build.bash clean &&
73+
bash build.bash all test/mros2/test_echoback_string"
74+
# app2:
7775
- name: Clone Native test stub source code to app2 and build and run
7876
run: |
7977
docker exec app2 bash -c "
@@ -89,21 +87,22 @@ jobs:
8987
- name: Run mROS and Native ROS
9088
shell: bash
9189
run : |
92-
# テスト対象をバックグラウンドで実行
90+
# Run native ROS respondeer in background
9391
docker exec app2 bash -c "source /opt/ros/humble/setup.bash &&
9492
cd mros2-host-examples &&
9593
source install/setup.bash &&
9694
ros2 run mros2_echoreply_string echoreply_node" &
9795
9896
docker exec app1 bash -c "cd /root/ws_mros && ./cmake_build/mros2-posix" &
99-
mros_pid=$! # テストプログラムのプロセスIDを取得
97+
mros_pid=$! # get mROS process id
10098
10199
docker ps
102100
103-
# mROSが終了するまで待つ
101+
# Wait until mROS finishes
104102
wait $mros_pid
105103
mros_status=$?
106-
# 結果に基づいてCIの成否を判断
104+
105+
# Judge CI success based on results
107106
if [ $mros_status -eq 0 ] ;then
108107
echo "Succeed pub/sub test process between mros2 and Native ROS"
109108
exit 0

.github/workflows/humble_test.yaml

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
1-
name: ci_humble
1+
#TODO fix file name and "name:" like "build and test"
2+
3+
name: build_and_test
24

35
on:
46
push:
57
branches:
68
- "main"
7-
- "feat/add_ci_config"
89
pull_request:
9-
types: [opened, synchronize, labeled]
10+
types: [opened, synchronize ]
1011
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')
12+
build_and_test:
13+
runs-on: ubuntu-latest
1714
container:
1815
image: osrf/ros:${{ matrix.ros_distribution }}-desktop
1916
timeout-minutes: 3
2017
strategy:
2118
fail-fast: false
2219
matrix:
23-
os: [ubuntu-22.04]
2420
ros_distribution: [humble]
2521
comm-target: [native , mros]
2622
comm-data-type: [string, twist]
2723
steps:
28-
- uses: actions/checkout@v3
24+
- uses: actions/checkout@v4
2925
with:
3026
submodules: recursive
3127
- name: update
@@ -54,7 +50,7 @@ jobs:
5450
shell: bash
5551
run: |
5652
bash build.bash clean
57-
bash build.bash all test_echoback_${{ matrix.comm-data-type }}
53+
bash build.bash all test/mros2/test_echoback_${{ matrix.comm-data-type }}
5854
mv cmake_build/ test_echoback_${{ matrix.comm-data-type }}/
5955
- name: Build Native ROS responder
6056
if: matrix.comm-target == 'native'
@@ -68,25 +64,25 @@ jobs:
6864
shell: bash
6965
run: |
7066
bash build.bash clean
71-
bash build.bash all test_echoback_${{ matrix.comm-data-type }}_responder
67+
bash build.bash all test/mros2/test_echoback_${{ matrix.comm-data-type }}_responder
7268
- name: Run Testing mROS and Native ROS
7369
if: matrix.comm-target == 'native'
7470
shell: bash
7571
run : |
7672
./test_echoback_${{ matrix.comm-data-type }}/mros2-posix &
77-
mros_pid=$! # mROSのプロセスIDを取得
73+
mros_pid=$! # get mROS process id
7874
79-
# Native ROSをバックグラウンドで実行
75+
# Run Native ROS in background
8076
cd ws_host/
8177
source /opt/ros/humble/setup.bash
8278
source install/setup.bash
8379
ros2 run mros2_echoreply_${{ matrix.comm-data-type }} echoreply_node &
8480
85-
# mROSが終了するまで待つ
81+
# Wait until mROS finishes
8682
wait $mros_pid
8783
mros_status=$?
8884
89-
# 結果に基づいてCIの成否を判断
85+
# Judge CI success based on results
9086
if [ $mros_status -eq 0 ] ;then
9187
echo "Succeed pub/sub test process between mros2 and Native ROS"
9288
exit 0
@@ -99,20 +95,20 @@ jobs:
9995
shell: bash
10096
run : |
10197
./test_echoback_${{ matrix.comm-data-type }}/mros2-posix &
102-
mros_pid=$! # テストプログラムのプロセスIDを取得
98+
mros_pid=$! # get mROS process id
10399
104-
# テスト対象をバックグラウンドで実行
100+
# Run mROS responder in background
105101
./cmake_build/mros2-posix &
106102
107-
# mROSが終了するまで待つ
103+
# Wait until mROS finishes
108104
wait $mros_pid
109105
mros_status=$?
110106
111-
# 結果に基づいてCIの成否を判断
107+
# Judge CI success based on results
112108
if [ $mros_status -eq 0 ] ;then
113-
echo "Succeed pub/sub test process between mros2 and Native ROS"
109+
echo "Succeed pub/sub test process between mros2 and mros2"
114110
exit 0
115111
else
116-
echo "Fail pub/sub test process between mros2 and Native ROS"
112+
echo "Fail pub/sub test process between mros2 and mros2"
117113
exit 1
118114
fi

README.md

Lines changed: 18 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,23 @@ 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+
To use the script, make it executable and run it:
71+
72+
```bash
73+
chmod +x update_ip.sh
74+
./update_ip.sh
75+
```
76+
77+
This script retrieves the current IP address and netmask of the system's active network interface and updates the specified files accordingly.
78+
Make sure to check the output to ensure the updates are correct before proceeding with the build.
79+
If multiple network interfaces are available, ensure the correct one is being used.
80+
81+
For troubleshooting, verify that the script runs without errors.
82+
If you encounter issues, check that the necessary network tools are installed and that your system has an active network connection.
83+
6784
## Getting Started
6885

6986
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: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,27 @@ 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+
28+
- **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.
29+
30+
- **test_echoback_string_responder**: This program subscribes to incoming string messages and echoes them back, facilitating the echo test for string messages.
31+
32+
- **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).
33+
34+
- **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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)