-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ci and test for native ros and mROS 2
- Loading branch information
Showing
5 changed files
with
209 additions
and
0 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,70 @@ | ||
name: ci_humble | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
- "feat/add_ci_config" | ||
pull_request: | ||
types: [opened, synchronize, labeled] | ||
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') | ||
container: | ||
image: osrf/ros:${{ matrix.ros_distribution }}-desktop | ||
timeout-minutes: 5 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-22.04] | ||
ros_distribution: [humble] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
- name: update | ||
run: sudo apt-get update | ||
- name: setup and install tools | ||
run: > | ||
sudo apt-get install -y git wget build-essential gcc g++ libssl-dev libreadline-dev | ||
zlib1g-dev make autoconf automake cmake pkg-config curl net-tools netcat python3-jinja2 | ||
- name: Clone Test Stub | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: mROS-base/mros2-host-examples | ||
path: ws_host/src/mros2-host-examples | ||
- name: Run IP update script | ||
run: | | ||
chmod +x update_ip.sh | ||
./update_ip.sh | ||
- name: Build | ||
run: | | ||
pwd | ||
ls -la | ||
bash build.bash clean | ||
bash build.bash all echoreply_string | ||
mv cmake_build cmake_build_echo_reply_strting | ||
- name: Build TestPrograms | ||
run: | | ||
pwd | ||
ls -la | ||
bash build.bash clean | ||
bash build.bash all test_echoreply_string | ||
- name: Buidl and Run test stub for Test with Comunicate Native ROS | ||
shell: bash | ||
run: | | ||
cd ws_host/ | ||
source /opt/ros/humble/setup.bash | ||
colcon build --packages-select mros2_echoreply_string | ||
source install/setup.bash | ||
ls -la | ||
pwd | ||
ros2 run mros2_echoreply_string echoreply_node & | ||
- name: Run Test programs for Comunicate Native ROS | ||
run : | | ||
./cmake_build/mros2-posix | ||
# - name: Run Test for Comunicate mROS to mROS |
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,27 @@ | ||
#!/bin/bash | ||
|
||
# IPアドレスを取得 | ||
IP_ADDRESS=$(hostname -I | awk '{print $1}') | ||
|
||
# IPアドレスをドットで分割 | ||
IFS='.' read -r -a IP_PARTS <<< "$IP_ADDRESS" | ||
|
||
# include/rtps/config.h のIPアドレス置換 | ||
|
||
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:]]*}; \ | ||
\/\/ Needs to be set in lwipcfg.h too./\ | ||
${IP_PARTS[0]}, ${IP_PARTS[1]}, ${IP_PARTS[2]}, ${IP_PARTS[3]}};\ | ||
\/\/ Needs to be set in lwipcfg.h too./" \ | ||
include/rtps/config.h | ||
# 変更結果を確認 | ||
|
||
# include/netif.h のIPアドレス置換 | ||
sed -i 's/#define NETIF_IPADDR ".*"/#define NETIF_IPADDR "'$IP_ADDRESS'"/' include/netif.h | ||
|
||
# 結果を表示して確認 | ||
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 |
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,3 @@ | ||
set(apl_SRCS | ||
${PROJECT_SOURCE_DIR}/workspace/${MROS2_APPNAME}/app.cpp | ||
) |
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,98 @@ | ||
|
||
/** | ||
* このプログラムとechoreply_stringを使う | ||
* 10回くらい送信して返ってくるかチェックする | ||
*/ | ||
|
||
#include "mros2.h" | ||
#include "std_msgs/msg/string.hpp" | ||
|
||
#include "cmsis_os.h" | ||
#include "netif.h" | ||
#include "netif_posix_add.h" | ||
|
||
#include <stdio.h> | ||
#include <string.h> | ||
#include <pthread.h> | ||
|
||
bool result = true; | ||
auto TestMessagePreFix = "TestMessage"; | ||
std::string expect = ""; | ||
int sub_counter = 0; | ||
pthread_mutex_t mutex_expect_sting; | ||
|
||
void userCallback(std_msgs::msg::String *msg) | ||
{ | ||
pthread_mutex_lock(&mutex_expect_sting); | ||
sub_counter++; | ||
printf("*test count : %d\r\n", sub_counter); | ||
auto actual = msg->data; | ||
// FIXME 受信データに改行や不要な文字が含まれている模様 | ||
actual.erase(std::remove(actual.begin(), actual.end(), '\n'), actual.end()); | ||
actual.erase(std::remove(actual.begin(), actual.end(), '\r'), actual.end()); | ||
|
||
printf("expect : '%s',\r\nactural: '%s'\r\n", expect.c_str(), actual.c_str()); | ||
printf("expect length: %lu, actual length: %lu\r\n", expect.size(), actual.size()); | ||
if (strcmp(expect.c_str(), actual.c_str()) == 0) | ||
{ | ||
printf("****SUCCEED****'\r\n"); | ||
result = result & true; | ||
} | ||
else | ||
{ | ||
printf("FAIL different data responsed.\r\n"); | ||
result = result & false; | ||
} | ||
pthread_mutex_unlock(&mutex_expect_sting); | ||
printf("\r\n"); | ||
|
||
if (sub_counter > 10) | ||
{ | ||
if (result) | ||
{ | ||
printf("All tests succeed.\r\n"); | ||
std::exit(0); | ||
} | ||
printf("Some tests faild.\r\n"); | ||
std::exit(-1); | ||
} | ||
} | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
netif_posix_add(NETIF_IPADDR, NETIF_NETMASK); | ||
|
||
osKernelStart(); | ||
|
||
printf("mros2-posix start!\r\n"); | ||
printf("app name: echoback_string\r\n"); | ||
mros2::init(0, NULL); | ||
MROS2_DEBUG("mROS 2 initialization is completed\r\n"); | ||
|
||
mros2::Node node = mros2::Node::create_node("mros2_test_node"); | ||
mros2::Publisher pub = node.create_publisher<std_msgs::msg::String>("to_linux", 10); | ||
auto msg = std_msgs::msg::String(); | ||
msg.data = "initial"; | ||
pub.publish(msg); | ||
osDelay(1000); | ||
mros2::Subscriber sub = node.create_subscription<std_msgs::msg::String>("to_stm", 10, userCallback); | ||
|
||
MROS2_INFO("ready to pub/sub message\r\n"); | ||
auto count = 0; | ||
sub_counter = 0; | ||
while (true) | ||
{ | ||
auto msg = std_msgs::msg::String(); | ||
pthread_mutex_lock(&mutex_expect_sting); | ||
expect = TestMessagePreFix + std::to_string(count++); | ||
msg.data = expect; | ||
printf("publishing msg: '%s'\r\n", msg.data.c_str()); | ||
pub.publish(msg); | ||
pthread_mutex_unlock(&mutex_expect_sting); | ||
|
||
osDelay(1000); | ||
} | ||
|
||
mros2::spin(); | ||
return 0; | ||
} |
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,11 @@ | ||
|
||
#include "std_msgs/msg/string.hpp" | ||
|
||
|
||
template mros2::Publisher mros2::Node::create_publisher<std_msgs::msg::String>(std::string topic_name, int qos); | ||
template void mros2::Publisher::publish(std_msgs::msg::String &msg); | ||
|
||
|
||
|
||
template mros2::Subscriber mros2::Node::create_subscription(std::string topic_name, int qos, void (*fp)(std_msgs::msg::String*)); | ||
template void mros2::Subscriber::callback_handler<std_msgs::msg::String>(void *callee, const rtps::ReaderCacheChange &cacheChange); |