From f73835815429a381b41a2ef1fb5aa9894cf896c9 Mon Sep 17 00:00:00 2001 From: ipa-nhg Date: Tue, 5 Sep 2023 09:11:27 +0200 Subject: [PATCH 1/5] Add Humble distro support --- humble/Dockerfile | 81 +++++++++++++++++++++++++++++++++++++++++++++++ humble/README.md | 28 ++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 humble/Dockerfile create mode 100644 humble/README.md diff --git a/humble/Dockerfile b/humble/Dockerfile new file mode 100644 index 0000000..85448fd --- /dev/null +++ b/humble/Dockerfile @@ -0,0 +1,81 @@ +# Use an official Python runtime as a parent image +FROM ros:humble +ARG enable_ssh +ARG path_to_scripts +RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections + +RUN apt-get update && apt upgrade -y && apt-get install -y \ + cppcheck \ + cccc \ + clang-14 \ + git \ + libclang-14-dev \ + python3-pip \ + llvm-14-dev \ + wget \ + netbase \ + libmagic-dev \ + python-is-python3 + +RUN if [ $enable_ssh ] ; then apt-get install -y openssh-server ; fi + +ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/usr/lib/llvm-14/lib + +RUN pip3 install --upgrade pip +RUN pip3 install -Iv clang==14.0 +RUN pip3 install -e git+https://github.com/timtadh/pyflwor.git#egg=pyflwor +RUN pip3 install -e git+https://github.com/ipa320/ros_model_parser.git#egg=ros_model_parser +RUN pip3 install -e git+https://github.com/git-afsantos/bonsai#egg=bonsai-code +RUN pip3 install -e git+https://github.com/ipa-nhg/haros@FixPythonExtractTopic#egg=haros +# RUN pip3 install -e git+https://github.com/git-afsantos/haros#egg=haros + +RUN apt-get update && apt-get install -y ros-humble-desktop && apt upgrade -y + +SHELL ["bash", "-c"] + +RUN useradd -rm -d /home/extractor/ -u 1001 extractor +#RUN useradd -rm -d /home/extractor/ -s /bin/bash -g extractor -G sudo root -u 1001 extractor +RUN usermod -a -G sudo extractor +RUN usermod -a -G root extractor +RUN echo "extractor ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/extractor +USER extractor +RUN mkdir -p /home/extractor/ws/src + +RUN mkdir -p /home/extractor/results +RUN chown extractor:extractor /home/extractor/results +USER extractor +WORKDIR /home/extractor + +# SSH CONFIGURATION +RUN if [ $enable_ssh ] ; then mkdir -p /home/extractor/.ssh/ && \ + chmod 0700 /home/extractor/.ssh && \ + touch /home/extractor/.ssh/authorized_keys && \ + chmod 600 /home/extractor/.ssh/authorized_keys && \ + touch /home/extractor/.ssh/config && \ + chmod 600 /home/extractor/.ssh/config ; fi + +COPY --chown=extractor:root ssh_config/ /keys/ +RUN if [ $enable_ssh ] ; then cat /keys/ssh_key.pub >> /home/extractor/.ssh/authorized_keys ; fi +RUN if [ $enable_ssh ] ; then cat /keys/config >> /home/extractor/.ssh/config ; fi +#### +USER extractor + +ENV CMAKE_CXX_COMPILER /usr/lib/llvm-14/bin/clang++ +RUN source /opt/ros/$ROS_DISTRO/setup.bash;\ + cd /home/extractor/ws;\ + colcon build --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ;\ + source /home/extractor/ws/install/setup.bash; \ + haros init + +ENV PYTHON_VERSION 3 +RUN echo 'source /home/extractor/ws/install/setup.bash' >> /home/extractor/.bashrc + +#RUN echo "test" +COPY ${path_to_scripts}messages_generator_runner.sh / +COPY ${path_to_scripts}generate_messages_model_helper.sh / +COPY ${path_to_scripts}haros_runner.sh / +COPY ${path_to_scripts}ros_model_extractor.py / +COPY ${path_to_scripts}test.sh / + +EXPOSE 4005 +#CMD sudo chown -R extractor:extractor /home/extractor/results diff --git a/humble/README.md b/humble/README.md new file mode 100644 index 0000000..ccc85ce --- /dev/null +++ b/humble/README.md @@ -0,0 +1,28 @@ +# Use the docker container to run the ros-model plugin for HAROS + +Install docker https://docs.docker.com/install/linux/docker-ce/ubuntu/ + +Build the HAROS docker image, for your desired ROS distro version: +``` +cd path-to-ros-model-extractors-repo +[sudo] docker build --tag=haros_humble -f humble/Dockerfile . +``` + +Call the ros-model extractor plugin, remember you have to also clone the repository to be analysed: + +``` +[sudo] docker run -it haros_humble:latest /haros_runner.sh *package_name* *node_name* *type* *path_to_resulted_model* *workspace_path* "*github_repositoryA -b branch*" "*github_repositoryB*"... +``` + +For example: + +``` +[sudo] docker run -it haros_humble:latest /haros_runner.sh sick_safetyscanners2 sick_safetyscanners2_node node . /home/extractor/ws https://github.com/SICKAG/sick_safetyscanners2 + +[sudo] docker run -it haros_humble:latest /haros_runner.sh turtlesim turtlesim_node node . /home/extractor/ws "https://github.com/ros/ros_tutorials -b humble" + +[sudo] docker run -it haros_humble:latest /haros_runner.sh test_pkg test_node node . /home/extractor/ws "https://github.com/ipa-nhg/test_ros2_code_extractor -b ros2Parameters" + +``` + + From d95fa3f8826331870c133b3f71ea1da7eda2b0c2 Mon Sep 17 00:00:00 2001 From: ipa-nhg Date: Thu, 30 Nov 2023 09:00:58 +0100 Subject: [PATCH 2/5] Add clang version as argument to support also clang14 required by humble --- haros_runner.sh | 18 ++++++++++++++---- ros_model_extractor.py | 8 +++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/haros_runner.sh b/haros_runner.sh index e313dac..f04a7fa 100755 --- a/haros_runner.sh +++ b/haros_runner.sh @@ -61,6 +61,16 @@ else echo "ROS installation not found" fi +if [ -n $ROS_DISTRO ] +then + if [[ $ROS_DISTRO == "humble" ]] + then + clang_version=14 + else + clang_version=10 + fi +fi + echo "" #tree ${5} @@ -77,18 +87,18 @@ then then if [ "${2}" = "--all" ] then - python /ros_model_extractor.py --package "$1" --"${3}" --model-path "${4}" --ws "${5}" --repo $model_repo -a>> extractor.log + python /ros_model_extractor.py --clang-version $clang_version --package "$1" --"${3}" --model-path "${4}" --ws "${5}" --repo $model_repo -a>> extractor.log else - python /ros_model_extractor.py --package "$1" --name "$2" --"${3}" --model-path "${4}" --ws "${5}" --repo $model_repo>> extractor.log + python /ros_model_extractor.py --clang-version $clang_version --package "$1" --name "$2" --"${3}" --model-path "${4}" --ws "${5}" --repo $model_repo>> extractor.log fi #cat extractor.log elif [[ $PYTHON_VERSION == "3" ]] then if [ "${2}" = "--all" ] then - python3 /ros_model_extractor.py --package "$1" --"${3}" --model-path "${4}" --ws "${5}" --path-to-src "$path_to_src_code" --repo $model_repo -a >> extractor.log + python3 /ros_model_extractor.py --clang-version $clang_version --package "$1" --"${3}" --model-path "${4}" --ws "${5}" --path-to-src "$path_to_src_code" --repo $model_repo -a >> extractor.log else - python3 /ros_model_extractor.py --package "$1" --name "$2" --"${3}" --model-path "${4}" --ws "${5}" --path-to-src "$path_to_src_code" --repo $model_repo>> extractor.log + python3 /ros_model_extractor.py --clang-version $clang_version --package "$1" --name "$2" --"${3}" --model-path "${4}" --ws "${5}" --path-to-src "$path_to_src_code" --repo $model_repo>> extractor.log fi #cat extractor.log else diff --git a/ros_model_extractor.py b/ros_model_extractor.py index 1cbe400..e39782b 100755 --- a/ros_model_extractor.py +++ b/ros_model_extractor.py @@ -40,11 +40,12 @@ class RosExtractor(): def launch(self): self.parse_arg() ws = self.args.worspace_path - + clang_version= self.args.clang_version + #BONSAI PARSER parser = CppAstParser(workspace = ws) - parser.set_library_path("/usr/lib/llvm-10/lib") - parser.set_standard_includes("/usr/lib/llvm-10/lib/clang/10.0.0/include") + parser.set_library_path("/usr/lib/llvm-"+clang_version+"/lib") + parser.set_standard_includes("/usr/lib/llvm-"+clang_version+"/lib/clang/"+clang_version+".0.0/include") db_dir = os.path.join(ws, "build") if os.path.isfile(os.path.join(db_dir, "compile_commands.json")): parser.set_database(db_dir) @@ -402,6 +403,7 @@ def parse_arg(self): parser.add_argument('--path-to-src', required=False, dest='path_to_src') parser.add_argument('--repo', required=False, dest='repo') parser.add_argument('-a', action='store_true') + parser.add_argument('--clang-version', required=True, dest='clang_version') self.args = parser.parse_args() From 006a7b60c5b30e65a3728b920a6f2cc24815a492 Mon Sep 17 00:00:00 2001 From: ipa-nhg Date: Thu, 30 Nov 2023 09:01:35 +0100 Subject: [PATCH 3/5] Debug foxy docker image, fixed GPG key expired issue --- foxy/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/foxy/Dockerfile b/foxy/Dockerfile index 893941d..b1814e3 100644 --- a/foxy/Dockerfile +++ b/foxy/Dockerfile @@ -3,6 +3,7 @@ FROM ros:foxy ARG enable_ssh ARG path_to_scripts RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections +RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 4B63CF8FDE49746E98FA01DDAD19BAB3CBF125EA RUN apt-get update && apt upgrade -y && apt-get install -y \ cppcheck \ From 0ae9f61fa9c01104e5da138bb2fedd07bafd8d7f Mon Sep 17 00:00:00 2001 From: ipa-nhg Date: Thu, 30 Nov 2023 09:09:29 +0100 Subject: [PATCH 4/5] Update Humble documentation --- README.md | 1 + humble/README.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 36fb1d2..ec4965b 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ Please check the available examples for the supported distros: - [ROS1 melodic](melodic/README.md) - [ROS1 noetic](noetic/README.md) - [ROS2 foxy](foxy/README.md) +- [ROS2 humble](humble/README.md) ToDo: - Extractor of interfaces types (msgs, srvs and actions) diff --git a/humble/README.md b/humble/README.md index ccc85ce..079bd30 100644 --- a/humble/README.md +++ b/humble/README.md @@ -17,7 +17,7 @@ Call the ros-model extractor plugin, remember you have to also clone the reposit For example: ``` -[sudo] docker run -it haros_humble:latest /haros_runner.sh sick_safetyscanners2 sick_safetyscanners2_node node . /home/extractor/ws https://github.com/SICKAG/sick_safetyscanners2 +[sudo] docker run -it haros_humble:latest /haros_runner.sh aruco_ros --all node . /home/extractor/ws "https://github.com/pal-robotics/aruco_ros" [sudo] docker run -it haros_humble:latest /haros_runner.sh turtlesim turtlesim_node node . /home/extractor/ws "https://github.com/ros/ros_tutorials -b humble" From 49850bd35a47d7b97c20915ddd842e4146eb45e7 Mon Sep 17 00:00:00 2001 From: ipa-nhg Date: Thu, 30 Nov 2023 09:18:18 +0100 Subject: [PATCH 5/5] Debug ROS docker images, fixed GPG key expired issue --- humble/Dockerfile | 1 + melodic/Dockerfile | 3 ++- noetic/Dockerfile | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/humble/Dockerfile b/humble/Dockerfile index 85448fd..ba2da99 100644 --- a/humble/Dockerfile +++ b/humble/Dockerfile @@ -3,6 +3,7 @@ FROM ros:humble ARG enable_ssh ARG path_to_scripts RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections +RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 4B63CF8FDE49746E98FA01DDAD19BAB3CBF125EA RUN apt-get update && apt upgrade -y && apt-get install -y \ cppcheck \ diff --git a/melodic/Dockerfile b/melodic/Dockerfile index 184703f..0ac05bb 100644 --- a/melodic/Dockerfile +++ b/melodic/Dockerfile @@ -1,9 +1,10 @@ # Use an official Python runtime as a parent image -FROM osrf/ros:melodic-desktop +FROM ros:melodic ARG enable_ssh ARG path_to_scripts RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections +RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 4B63CF8FDE49746E98FA01DDAD19BAB3CBF125EA RUN apt-get update && apt upgrade -y && apt-get install -y \ cppcheck \ diff --git a/noetic/Dockerfile b/noetic/Dockerfile index 029bd3b..5569b41 100644 --- a/noetic/Dockerfile +++ b/noetic/Dockerfile @@ -1,9 +1,10 @@ # Use an official Python runtime as a parent image -FROM osrf/ros:noetic-desktop +FROM ros:noetic ARG enable_ssh ARG path_to_scripts RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections +RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 4B63CF8FDE49746E98FA01DDAD19BAB3CBF125EA RUN apt-get update && apt upgrade -y && apt-get install -y \ cppcheck \