Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .ci_local_test/ros2_openvino_toolkit_test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# ros2 openvino toolkit env master f1b1ca4d914186a1881b87f103be9c6e910c9d80

ARG ROS_VERSION
FROM osrf/ros:${ROS_VERSION}
ARG VERSION


LABEL maintainer="Jiawei Wu <[email protected]>"

SHELL ["/bin/bash", "-c"]

# ignore the warning
ARG DEBIAN_FRONTEND=noninteractive
ARG APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1
RUN apt-get update && apt-get install --assume-yes apt-utils

# install openvino 2022.3

# https://docs.openvino.ai/2022.3/openvino_docs_install_guides_installing_openvino_apt.html
RUN apt update && apt install --assume-yes curl wget gnupg2 lsb-release
RUN wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB && \
apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB && echo "deb https://apt.repos.intel.com/openvino/2022 focal main" | tee /etc/apt/sources.list.d/intel-openvino-2022.list
RUN apt update && apt-cache search openvino && apt install -y openvino-2022.3.0


# install librealsense2
RUN apt-get install -y --no-install-recommends \
software-properties-common
# https://github.com/IntelRealSense/librealsense/blob/master/doc/distribution_linux.md
# Make sure you set http-proxy in below commands if your environment needs.

RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE || apt-key adv --keyserver-options --keyserver hkp://keyserver.ubuntu.com:80 --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE
#RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE || apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE
RUN add-apt-repository "deb https://librealsense.intel.com/Debian/apt-repo $(lsb_release -cs) main" -u \
&& apt-get install -y --no-install-recommends \
librealsense2-dkms \
librealsense2-utils \
librealsense2-dev \
librealsense2-dbg \
libgflags-dev \
libboost-all-dev \
&& rm -rf /var/lib/apt/lists/*

# other dependencies
RUN apt-get update && apt-get install -y python3-pip && python3 -m pip install -U \
numpy \
networkx \
pyyaml \
requests \
&& apt-get install -y --no-install-recommends libboost-all-dev
WORKDIR /usr/lib/x86_64-linux-gnu
RUN ln -sf libboost_python-py36.so libboost_python37.so
RUN pip install --upgrade pip
#RUN pip install openvino-dev[tensorflow2]==2022.3

# build ros2 openvino toolkit
WORKDIR /root
RUN mkdir -p catkin_ws/src
WORKDIR /root/catkin_ws/src
RUN git clone https://github.com/intel/ros2_object_msgs.git
##://github.com/intel/ros2_openvino_toolkit.git
RUN git clone -b ${VERSION} https://github.com/ros-perception/vision_opencv.git
RUN git clone -b ros2-development https://github.com/IntelRealSense/realsense-ros.git
RUN apt-get install ros-${VERSION}-diagnostic-updater
WORKDIR /root/catkin_ws
COPY jpg /root/jpg
#RUN source /opt/ros/${VERSION}/setup.bash && source /opt/intel/openvino_2022/setupvars.sh && colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release
37 changes: 37 additions & 0 deletions .ci_local_test/ros2_openvino_toolkit_test/docker_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

export DISPLAY=:0

export work_dir=$PWD


function run_container() {

docker images | grep ros2_openvino_docker

if [ $? -eq 0 ]
then
echo "the image of ros2_openvino_docker:01 existence"
docker rmi -f ros2_openvino_docker:01
fi

docker ps -a | grep ros2_openvino_container
if [ $? -eq 0 ]
then
docker rm -f ros2_openvino_container
fi
# Using jenkins server ros2_openvino_toolkit code instead of git clone code.
cd $work_dir && sed -i 's/RUN git clone -b ros2 https/#/g' Dockerfile
cd $work_dir && docker build --build-arg ROS_VERSION=galactic-desktop --build-arg VERSION=galactic -t ros2_openvino_docker:01 .
docker run -i --privileged=true -v $work_dir/ros2_openvino_toolkit:/root/catkin_ws/src/ros2_openvino_toolkit -v $work_dir/test_cases:/root/test_cases --name ros2_openvino_container ros2_openvino_docker:01 bash -c "cd /root/test_cases && ./run.sh galactic"

}

run_container
if [ $? -ne 0 ]
then
echo "Test fail"
exit -1
fi


Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions .ci_local_test/ros2_openvino_toolkit_test/test_cases/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#/bin/bash

if [[ $1 == '' ]]
then
export ros2_branch=galactic
else
export ros2_branch=$1
fi

export dynamic_vino_sample=/root/catkin_ws/install/openvino_node/share/openvino_node


source /opt/ros/$ros2_branch/setup.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

mkdir -p /opt/openvino_toolkit/models
#apt install -y python-pip
apt install -y python3.8-venv
cd ~ && python3 -m venv openvino_env && source openvino_env/bin/activate
python -m pip install --upgrade pip
pip install openvino-dev[tensorflow2,mxnet,caffe]


#Download the optimized Intermediate Representation (IR) of model (execute once)
cd ~/catkin_ws/src/ros2_openvino_toolkit/data/model_list && omz_downloader --list download_model.lst -o /opt/openvino_toolkit/models/
cd ~/catkin_ws/src/ros2_openvino_toolkit/data/model_list && sed -i 's/mask_rcnn_inception_resnet_v2_atrous_coco//' convert_model.lst
#cd ~/catkin_ws/src/ros2_openvino_toolkit/data/model_list && sed -i 's/deeplabv3//' convert_model.lst

cd ~/catkin_ws/src/ros2_openvino_toolkit/data/model_list && omz_converter --list convert_model.lst -d /opt/openvino_toolkit/models/ -o /opt/openvino_toolkit/models/convert

#Copy label files (execute once)
cp ~/catkin_ws/src/ros2_openvino_toolkit/data/labels/face_detection/face-detection-adas-0001.labels /opt/openvino_toolkit/models/intel/face-detection-adas-0001/FP32/
cp ~/catkin_ws/src/ros2_openvino_toolkit/data/labels/face_detection/face-detection-adas-0001.labels /opt/openvino_toolkit/models/intel/face-detection-adas-0001/FP16/
cp ~/catkin_ws/src/ros2_openvino_toolkit/data/labels/emotions-recognition/FP32/emotions-recognition-retail-0003.labels /opt/openvino_toolkit/models/intel/emotions-recognition-retail-0003/FP32/
cp ~/catkin_ws/src/ros2_openvino_toolkit/data/labels/object_segmentation/frozen_inference_graph.labels /opt/openvino_toolkit/models/intel/semantic-segmentation-adas-0001/FP32/
cp ~/catkin_ws/src/ros2_openvino_toolkit/data/labels/object_segmentation/frozen_inference_graph.labels /opt/openvino_toolkit/models/intel/semantic-segmentation-adas-0001/FP16/
cp ~/catkin_ws/src/ros2_openvino_toolkit/data/labels/object_detection/vehicle-license-plate-detection-barrier-0106.labels /opt/openvino_toolkit/models/intel/vehicle-license-plate-detection-barrier-0106/FP32

mkdir -p /opt/openvino_toolkit/models/convert/
#cp -r /root/public/ /opt/openvino_toolkit/models/convert/
32 changes: 32 additions & 0 deletions .ci_local_test/ros2_openvino_toolkit_test/test_cases/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

export ros2_branch=$1
if [[ $1 == '' ]]
then
export ros2_branch=galactic
else
export ros2_branch=$1
fi
source /root/test_cases/config.sh $ros2_branch

cd /root/catkin_ws && colcon build --symlink-install
cd /root/catkin_ws && source ./install/local_setup.bash

apt-get update
# apt-get install -y ros-$ros2_branch-diagnostic-updater
apt-get install python3-defusedxml
apt-get install -y python3-pip
pip3 install XTestRunner

cd /root/test_cases && ./ros2_openvino_tool_model_download.sh
mkdir -p /root/test_cases/log
echo "===cat pipeline_people_ci.yaml"
cat /root/catkin_ws/install/openvino_node/share/openvino_node/param/pipeline_people_ci.yaml


cd /root/test_cases/unittest && python3 run_all.py
if [ $? -ne 0 ]
then
exit -1
fi

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/opt/python3
import unittest
from test_cases import Test_Cases
from XTestRunner import HTMLTestRunner

def main():

suite = unittest.TestSuite()
suite.addTest(Test_Cases('test_1_pipeline_people_ci'))
suite.addTest(Test_Cases('test_2_pipeline_reidentification_ci'))
suite.addTest(Test_Cases('test_3_pipeline_image_ci'))
suite.addTest(Test_Cases('test_6_pipeline_vehicle_detection_ci'))
suite.addTest(Test_Cases('test_7_pipeline_person_attributes_ci'))

with (open('./result.html', 'wb')) as fp:
runner = HTMLTestRunner(
stream=fp,
title='ROS2 Openvino Test Report',
description='Test ROS2-galactic openvino all cases',
language='en',
)
result = runner.run(
testlist=suite,
rerun=0,
save_last_run=False
)

print(f"success count: {result.success_count}")
print(f"failure count: {result.failure_count}")
print(f"runtime:", result.case_end_time - result.case_start_time)
if result.failure_count == 0 and result.error_count == 0:
print(f"Test ALL PASS")
else:
print(f"Test FAIL")
exit(-1)

if __name__=="__main__":
main()

Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#from asyncio import sleep
from time import sleep
import unittest
import subprocess
import pdb
import os

class Test_Cases(unittest.TestCase):
def test_pipeline(self, launch_file, log_file, topic_list=['/rosout']):
print(f"{log_file} topic_list", topic_list)
log_file = f"/root/test_cases/log/" + log_file
kill_ros2_process()
subprocess.Popen([f"ros2 launch openvino_node {launch_file} > {log_file} &"],shell=True).communicate()
for topic in topic_list:
name=topic.split('/', -1)[-1]
sleep(2)
subprocess.Popen([f"ros2 topic echo {topic} > {name}.log &"], shell=True).communicate()
process_result = subprocess.Popen(["ps -ef | grep ros2 | grep -v 'grep' | awk '{print $2}'"],stdout=subprocess.PIPE, shell=True).communicate()
kill_ros2_process()
print(f"kill the test process done")
with open(f"{log_file}") as handle:
log = handle.read()
check_log = log.split("user interrupted with ctrl-c (SIGINT)")[0]
if f"pipeline_object_yolo" not in log_file:
self.assertIn('Analyzing Detection results', check_log)
self.assertNotIn('ERROR', check_log)
for topic in topic_list:
name = topic.split('/', -1)[-1]
with open(f"{name}.log") as topic_handle:
topic_info = topic_handle.read()
print("assertIn", self.assertIn("header", topic_info))
print(f"check all done")


def test_1_pipeline_people_ci(self):
topic_ls = ["/ros2_openvino_toolkit/age_genders_Recognition", \
"/ros2_openvino_toolkit/headposes_estimation", \
"/ros2_openvino_toolkit/face_detection", \
"/ros2_openvino_toolkit/emotions_recognition"]
launch_file = f"pipeline_people_ci_test.py"
log_file = f"pipeline_people_test_ci.log"
self.test_pipeline(launch_file, log_file, topic_list=topic_ls)

def test_2_pipeline_reidentification_ci(self):
topic_ls = ["/ros2_openvino_toolkit/reidentified_persons",]
launch_file = f"pipeline_reidentification_ci_test.py"
log_file = f"pipeline_reidentification_test_ci.log"
self.test_pipeline(launch_file, log_file, topic_list=topic_ls)

def test_3_pipeline_image_ci(self):
topic_ls = ["/ros2_openvino_toolkit/emotions_recognition", \
"/ros2_openvino_toolkit/headposes_estimation", \
"/ros2_openvino_toolkit/people/age_genders_Recognition"]
launch_file = f"pipeline_image_ci_test.py"
log_file = f"pipeline_image_test_ci.log"
self.test_pipeline(launch_file, log_file, topic_list=topic_ls)

def test_4_pipeline_segmentation_ci(self):
topic_ls = ["/ros2_openvino_toolkit/segmented_obejcts"]
launch_file = f"pipeline_segmentation_ci_test.py"
log_file = f"pipeline_segmentation_test_ci.log"
self.test_pipeline(launch_file, log_file, topic_list=topic_ls)

def test_5_pipeline_segmentation_image_ci(self):
topic_ls = ["/ros2_openvino_toolkit/segmented_obejcts"]
launch_file = f"pipeline_segmentation_image_ci_test.py"
log_file = f"pipeline_segmentation_image_test_ci.log"
self.test_pipeline(launch_file, log_file, topic_list=topic_ls)

def test_6_pipeline_vehicle_detection_ci(self):
topic_ls = ["/ros2_openvino_toolkit/detected_license_plates",
"/ros2_openvino_toolkit/detected_vehicles_attribs"]
launch_file = f"pipeline_vehicle_detection_ci_test.py"
log_file = f"pipeline_vehicle_detection_test_ci.log"
self.test_pipeline(launch_file, log_file, topic_list=topic_ls)

def test_7_pipeline_person_attributes_ci(self):
topic_ls = ["/ros2_openvino_toolkit/detected_objects", \
"/ros2_openvino_toolkit/person_attributes"]
launch_file = f"pipeline_person_attributes_ci_test.py"
log_file = f"pipeline_person_attributes_test_ci.log"
self.test_pipeline(launch_file, log_file, topic_list=topic_ls)

def test_8_pipeline_object_yolo_ci(self):
topic_ls = ["/ros2_openvino_toolkit/detected_objects"]
launch_file = f"pipeline_object_yolo_ci_test.py"
log_file = f"pipeline_object_yolo_test_ci.log"
self.test_pipeline(launch_file, log_file, topic_list=topic_ls)





def kill_ros2_process():
sleep(30)
process_result = subprocess.Popen(["ps -ef | grep ros2 | grep -v 'grep' | awk '{print $2}'"],stdout=subprocess.PIPE, shell=True).communicate()
print(process_result[0].decode('utf-8').replace('\n', ' '))
kill_process = 'kill -9 ' + process_result[0].decode('utf-8').replace('\n', ' ')
subprocess.Popen([kill_process], shell=True).communicate()



36 changes: 36 additions & 0 deletions .github/workflows/ros2_branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This is a basic workflow to help you get started with Actions

name: ros2_branch_CI

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "master" branch
push:
branches: [ "ros2" ]
pull_request:
branches: [ "ros2" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-20.04

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3


# Runs a set of commands using the runners shell
- name: ros2_openvino_toolkit_test
run: |
pwd
mkdir -p ../workspace_ci
cp -r ${GITHUB_WORKSPACE}/.ci_local_test/ros2_openvino_toolkit_test ../workspace_ci
cp -r ${GITHUB_WORKSPACE} ../workspace_ci/ros2_openvino_toolkit_test
cd ../workspace_ci/ros2_openvino_toolkit_test && ./docker_run.sh
Loading