diff --git a/.github/workflows/humble_docker_test.yaml b/.github/workflows/humble_docker_test.yaml index fb6b26b..d22cd05 100644 --- a/.github/workflows/humble_docker_test.yaml +++ b/.github/workflows/humble_docker_test.yaml @@ -1,25 +1,20 @@ -name: Humble_test_with_docker_NativeROS_string +name: buid_and_test_with_docker_NativeROS_string on: push: branches: - "main" pull_request: - types: [opened, synchronize, labeled] + types: [opened, synchronize] jobs: ci: - runs-on: ${{ matrix.os }} - if: | - ((github.event.action == 'labeled') && (github.event.label.name == 'TESTING') && (github.base_ref == 'main' )) || - ((github.event.action == 'synchronize') && (github.base_ref == 'main') && contains(github.event.pull_request.labels.*.name, 'TESTING')) || - (github.ref_name == 'main') + runs-on: ubuntu-latest container: image: osrf/ros:${{ matrix.ros_distribution }}-desktop timeout-minutes: 5 strategy: fail-fast: false matrix: - os: [ubuntu-22.04] ros_distribution: [humble] steps: - name: Checkout code @@ -31,14 +26,17 @@ jobs: - name: Install Docker Compose run: sudo apt-get update && sudo apt-get install -y docker-compose - # docker-compose.yml を使ってコンテナを起動 + # runs containers using docker-compose.yml - name: Build and run containers - run: docker-compose up -d + run: | + cd workspace/test/mros2 + docker-compose up -d + cd - - name: Wait for containers to start - run: sleep 20 # コンテナが確実に起動するのを待つ時間を長くする + run: sleep 20 # wait time for container startup. - name: List running containers - run: docker ps -a # 全コンテナが起動しているか確認 - - name: Show container logs # コンテナのログを確認する + run: docker ps -a # Check if all containers are running. + - name: Show container logs run: | docker logs app1 docker logs app2 @@ -52,28 +50,28 @@ jobs: docker exec app2 ping -c 4 172.19.0.2 # app2 から app1 へのPing - name: Test TCP connection between containers (netcat) run: | - # app2でポート8080をリスン + # Listen port 8080 on app2 docker exec -d app2 bash -c "nc -l -p 8080" - # app1からapp2へのTCP接続を確認 + # Check connection to app2 from app1 docker exec app1 bash -c "echo 'Test' | nc -w 3 172.19.0.3 8080" - # app1: ビルドの準備 (chmod +x update_ip.sh と ./update_ip.sh の実行) + # app1: prepare build (run chmod +x update_ip.sh and ./update_ip.sh) - name: Prepare build in mros run: | - docker cp $GITHUB_WORKSPACE app1:/root/ws_mros # ソースコードをapp1コンテナにコピー + docker cp $GITHUB_WORKSPACE app1:/root/ws_mros # Copy source code to app1 docker exec app1 bash -c " cd /root/ws_mros && - chmod +x update_ip.sh && # 権限変更 - ./update_ip.sh" # IPアドレス更新スクリプトの実行 - # app1: クリーンビルド + chmod +x update_ip.sh && # Change grant + ./update_ip.sh" # Run script to overwrite IP address. + # app1: clean and build - name: Clean and build in mros run: | docker exec app1 bash -c " cd /root/ws_mros && pwd && ls -la && - bash build.bash clean && # クリーンアップ - bash build.bash all test_echoback_string" - # app2: のコードをコンテナにコピーしてビルド + bash build.bash clean && + bash build.bash all test/mros2/test_echoback_string" + # app2: - name: Clone Native test stub source code to app2 and build and run run: | docker exec app2 bash -c " @@ -89,21 +87,22 @@ jobs: - name: Run mROS and Native ROS shell: bash run : | - # テスト対象をバックグラウンドで実行 + # Run native ROS respondeer in background docker exec app2 bash -c "source /opt/ros/humble/setup.bash && cd mros2-host-examples && source install/setup.bash && ros2 run mros2_echoreply_string echoreply_node" & docker exec app1 bash -c "cd /root/ws_mros && ./cmake_build/mros2-posix" & - mros_pid=$! # テストプログラムのプロセスIDを取得 + mros_pid=$! # get mROS process id docker ps - # mROSが終了するまで待つ + # Wait until mROS finishes wait $mros_pid mros_status=$? - # 結果に基づいてCIの成否を判断 + + # Judge CI success based on results if [ $mros_status -eq 0 ] ;then echo "Succeed pub/sub test process between mros2 and Native ROS" exit 0 diff --git a/.github/workflows/humble_test.yaml b/.github/workflows/humble_test.yaml index 0464e49..03bb208 100644 --- a/.github/workflows/humble_test.yaml +++ b/.github/workflows/humble_test.yaml @@ -1,26 +1,22 @@ -name: ci_humble +#TODO fix file name and "name:" like "build and test" + +name: build_and_test on: push: branches: - "main" - - "feat/add_ci_config" pull_request: - types: [opened, synchronize, labeled] + types: [opened, synchronize ] jobs: - ci: - runs-on: ${{ matrix.os }} - if: | - ((github.event.action == 'labeled') && (github.event.label.name == 'TESTING') && (github.base_ref == 'main' )) || - ((github.event.action == 'synchronize') && (github.base_ref == 'main') && contains(github.event.pull_request.labels.*.name, 'TESTING')) || - (github.ref_name == 'main') + build_and_test: + runs-on: ubuntu-latest container: image: osrf/ros:${{ matrix.ros_distribution }}-desktop timeout-minutes: 3 strategy: fail-fast: false matrix: - os: [ubuntu-22.04] ros_distribution: [humble] comm-target: [native , mros] comm-data-type: [string, twist] @@ -54,7 +50,7 @@ jobs: shell: bash run: | bash build.bash clean - bash build.bash all test_echoback_${{ matrix.comm-data-type }} + bash build.bash all test/mros2/test_echoback_${{ matrix.comm-data-type }} mv cmake_build/ test_echoback_${{ matrix.comm-data-type }}/ - name: Build Native ROS responder if: matrix.comm-target == 'native' @@ -68,25 +64,25 @@ jobs: shell: bash run: | bash build.bash clean - bash build.bash all test_echoback_${{ matrix.comm-data-type }}_responder + bash build.bash all test/mros2/test_echoback_${{ matrix.comm-data-type }}_responder - name: Run Testing mROS and Native ROS if: matrix.comm-target == 'native' shell: bash run : | ./test_echoback_${{ matrix.comm-data-type }}/mros2-posix & - mros_pid=$! # mROSのプロセスIDを取得 + mros_pid=$! # get mROS process id - # Native ROSをバックグラウンドで実行 + # Run Native ROS in background cd ws_host/ source /opt/ros/humble/setup.bash source install/setup.bash ros2 run mros2_echoreply_${{ matrix.comm-data-type }} echoreply_node & - # mROSが終了するまで待つ + # Wait until mROS finishes wait $mros_pid mros_status=$? - # 結果に基づいてCIの成否を判断 + # Judge CI success based on results if [ $mros_status -eq 0 ] ;then echo "Succeed pub/sub test process between mros2 and Native ROS" exit 0 @@ -99,20 +95,20 @@ jobs: shell: bash run : | ./test_echoback_${{ matrix.comm-data-type }}/mros2-posix & - mros_pid=$! # テストプログラムのプロセスIDを取得 + mros_pid=$! # get mROS process id - # テスト対象をバックグラウンドで実行 + # Run mROS responder in background ./cmake_build/mros2-posix & - # mROSが終了するまで待つ + # Wait until mROS finishes wait $mros_pid mros_status=$? - # 結果に基づいてCIの成否を判断 + # Judge CI success based on results if [ $mros_status -eq 0 ] ;then - echo "Succeed pub/sub test process between mros2 and Native ROS" + echo "Succeed pub/sub test process between mros2 and mros2" exit 0 else - echo "Fail pub/sub test process between mros2 and Native ROS" + echo "Fail pub/sub test process between mros2 and mros2" exit 1 fi \ No newline at end of file diff --git a/README.md b/README.md index dd01bca..4715483 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ sudo apt-get update && sudo apt-get install -y \ libssl-dev libreadline-dev zlib1g-dev \ make autoconf automake cmake \ pkg-config curl \ - net-tools netcat jinja2 + net-tools netcat python3-jinja2 ``` Please check the IP address and netmask of the execution environment. @@ -64,6 +64,19 @@ You need to edit the below files to set IP address and netmask. * IP address and netmask to `include/netif.h` * IP address to `include/rtps/config.h` +Alternatively, you can use the provided `update_ip.sh` script to automatically update these files according to your building environment. 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. + +To use the script, make it executable and run it: + + ```bash + chmod +x update_ip.sh + ./update_ip.sh + ``` + +This script retrieves the current IP address and netmask of the system's active network interface and updates the specified files accordingly. Make sure to check the output to ensure the updates are correct before proceeding with the build. If multiple network interfaces are available, ensure the correct one is being used. + +For troubleshooting, verify that the script runs without errors. If you encounter issues, check that the necessary network tools are installed and that your system has an active network connection. + ## Getting Started 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). diff --git a/update_ip.sh b/update_ip.sh index 86300c9..41cdd1a 100755 --- a/update_ip.sh +++ b/update_ip.sh @@ -1,13 +1,13 @@ #!/bin/bash -# IPアドレスを取得 +# Retrieve IP address IP_ADDRESS=$(hostname -I | awk '{print $1}') if [ -z "$IP_ADDRESS" ]; then echo "Error: Failed to retrieve IP address." exit 1 fi -# ネットマスクを取得(IPアドレスに対応するネットマスクを抽出) +# Retrieve netmask (extract the netmask corresponding to the IP address) INTERFACE=$(ip -o addr show | grep "$IP_ADDRESS" | awk '{print $2}') NETMASK=$(ip -o -f inet addr show $INTERFACE | awk '/inet/ {print $4}' | cut -d'/' -f2) if [ -z "$NETMASK" ]; then @@ -15,7 +15,7 @@ if [ -z "$NETMASK" ]; then exit 1 fi -# CIDRからネットマスクを計算 +# Calculate netmask from CIDR function cidr_to_netmask() { local cidr=$1 local mask="" @@ -41,14 +41,14 @@ function cidr_to_netmask() { NETMASK=$(cidr_to_netmask $NETMASK) echo "Retrieved Netmask for IP $IP_ADDRESS: $NETMASK" -# IPアドレスをドットで分割 +# Split the IP address by dots IFS='.' read -r -a IP_PARTS <<< "$IP_ADDRESS" -# ネットマスクをドットで分割 +# Split the netmask by dots IFS='.' read -r -a NETMASK_PARTS <<< "$NETMASK" echo "Netmask parts: ${NETMASK_PARTS[0]}, ${NETMASK_PARTS[1]}, ${NETMASK_PARTS[2]}, ${NETMASK_PARTS[3]}" -# include/rtps/config.h のIPアドレス置換 +# Replace the IP address in include/rtps/config.h echo "Running sed on include/rtps/config.h" 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]}};\ include/rtps/config.h -# include/netif.h のIPアドレスとネットマスク置換 +# Replace the IP address and netmask in include/netif.h sed -i 's/#define NETIF_IPADDR ".*"/#define NETIF_IPADDR "'$IP_ADDRESS'"/' include/netif.h sed -i 's/#define NETIF_NETMASK ".*"/#define NETIF_NETMASK "'$NETMASK'"/' include/netif.h -# 結果を表示して確認 +# Display the result for confirmation echo "Updated IP Address: $IP_ADDRESS" echo "Updated include/rtps/config.h:" grep -E 'Needs to be set in lwipcfg.h too.' include/rtps/config.h echo "Updated include/netif.h:" -grep -E 'NETIF_IPADDR' include/netif.h \ No newline at end of file +grep -E 'NETIF_IPADDR' include/netif.h diff --git a/workspace/test/README.md b/workspace/test/README.md index 91ffa0f..8d7f9bf 100644 --- a/workspace/test/README.md +++ b/workspace/test/README.md @@ -8,3 +8,27 @@ We plan to maintain them in the near future, as they remain useful (see #1). (embeddedRTPS and lwip-posix) * embeddedRTPS layer: [fastdds-comp](https://github.com/mROS-base/mros2-posix/tree/main/workspace/test/fastdds-comp) + + +## mros2 Directory Overview + +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: + +``` +mros2/ +├── docker-compose.yml +├── test_echoback_string +├── test_echoback_string_responder +├── test_echoback_twist +└── test_echoback_twist_responder +``` + +- **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` + +- **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. + +- **test_echoback_string_responder**: This program subscribes to incoming string messages and echoes them back, facilitating the echo test for string messages. + +- **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). + +- **test_echoback_twist_responder**: This program subscribes to incoming Twist messages and echoes them back, facilitating the echo test for Twist messages. diff --git a/docker-compose.yml b/workspace/test/mros2/docker-compose.yml similarity index 100% rename from docker-compose.yml rename to workspace/test/mros2/docker-compose.yml diff --git a/workspace/test_echoback_string/Filelists.cmake b/workspace/test/mros2/test_echoback_string/Filelists.cmake similarity index 100% rename from workspace/test_echoback_string/Filelists.cmake rename to workspace/test/mros2/test_echoback_string/Filelists.cmake diff --git a/workspace/test_echoback_string/app.cpp b/workspace/test/mros2/test_echoback_string/app.cpp similarity index 100% rename from workspace/test_echoback_string/app.cpp rename to workspace/test/mros2/test_echoback_string/app.cpp diff --git a/workspace/test_echoback_string/templates.hpp b/workspace/test/mros2/test_echoback_string/templates.hpp similarity index 100% rename from workspace/test_echoback_string/templates.hpp rename to workspace/test/mros2/test_echoback_string/templates.hpp diff --git a/workspace/test_echoback_string_responder/Filelists.cmake b/workspace/test/mros2/test_echoback_string_responder/Filelists.cmake similarity index 100% rename from workspace/test_echoback_string_responder/Filelists.cmake rename to workspace/test/mros2/test_echoback_string_responder/Filelists.cmake diff --git a/workspace/test_echoback_string_responder/app.cpp b/workspace/test/mros2/test_echoback_string_responder/app.cpp similarity index 100% rename from workspace/test_echoback_string_responder/app.cpp rename to workspace/test/mros2/test_echoback_string_responder/app.cpp diff --git a/workspace/test_echoback_string_responder/templates.hpp b/workspace/test/mros2/test_echoback_string_responder/templates.hpp similarity index 100% rename from workspace/test_echoback_string_responder/templates.hpp rename to workspace/test/mros2/test_echoback_string_responder/templates.hpp diff --git a/workspace/test_echoback_twist/Filelists.cmake b/workspace/test/mros2/test_echoback_twist/Filelists.cmake similarity index 100% rename from workspace/test_echoback_twist/Filelists.cmake rename to workspace/test/mros2/test_echoback_twist/Filelists.cmake diff --git a/workspace/test_echoback_twist/app.cpp b/workspace/test/mros2/test_echoback_twist/app.cpp similarity index 100% rename from workspace/test_echoback_twist/app.cpp rename to workspace/test/mros2/test_echoback_twist/app.cpp diff --git a/workspace/test_echoback_twist/templates.hpp b/workspace/test/mros2/test_echoback_twist/templates.hpp similarity index 100% rename from workspace/test_echoback_twist/templates.hpp rename to workspace/test/mros2/test_echoback_twist/templates.hpp diff --git a/workspace/test_echoback_twist_responder/Filelists.cmake b/workspace/test/mros2/test_echoback_twist_responder/Filelists.cmake similarity index 100% rename from workspace/test_echoback_twist_responder/Filelists.cmake rename to workspace/test/mros2/test_echoback_twist_responder/Filelists.cmake diff --git a/workspace/test_echoback_twist_responder/app.cpp b/workspace/test/mros2/test_echoback_twist_responder/app.cpp similarity index 100% rename from workspace/test_echoback_twist_responder/app.cpp rename to workspace/test/mros2/test_echoback_twist_responder/app.cpp diff --git a/workspace/test_echoback_twist_responder/templates.hpp b/workspace/test/mros2/test_echoback_twist_responder/templates.hpp similarity index 100% rename from workspace/test_echoback_twist_responder/templates.hpp rename to workspace/test/mros2/test_echoback_twist_responder/templates.hpp