Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to support the new models and the ros2model code generator #30

Merged
merged 2 commits into from
Feb 27, 2024
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
13 changes: 2 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)

[![MELODIC build status](https://github.com/ipa320/ros-model-extractors/actions/workflows/build_melodic.yml/badge.svg)](https://github.com/ipa320/ros-model-extractors/actions/workflows/build_melodic.yml)
[![NOETIC ros-model-extractors](https://github.com/ipa320/ros-model-extractors/actions/workflows/build_noetic.yml/badge.svg)](https://github.com/ipa320/ros-model-extractors/actions/workflows/build_noetic.yml)
[![FOXY build status](https://github.com/ipa320/ros-model-extractors/actions/workflows/build_foxy.yml/badge.svg)](https://github.com/ipa320/ros-model-extractors/actions/workflows/build_foxy.yml)


Technical Maintainer: [**ipa-nhg**](https://github.com/ipa-nhg/) (**Nadia Hammoudeh Garcia**, **Fraunhofer IPA**) - **[email protected]**

This repository contains the HAROS framework plugin to automatically generate models according to the DSLs defined for RosModel.
Expand All @@ -17,6 +12,7 @@ This package also contains a set of ROS containers where you can easily do the a

As related work you can read the following paper: [Bootstrapping MDE development from ROS manual code: Part 2—Model generation and leveraging models at runtime](https://link.springer.com/article/10.1007/s10270-021-00873-2?wt_mc=Internal.Event.1.SEM.ArticleAuthorOnlineFirst&utm_source=ArticleAuthorOnlineFirst&utm_medium=email&utm_content=AA_en_06082018&ArticleAuthorOnlineFirst_20210420)

:bangbang: The updated version of the development is only being supported for ROS2, the RO1 implementation (old version) is available under [ros1 branch](https://github.com/ipa320/ros-model-extractors/tree/ros1)

### HowTo Use the docker container to run the ros-model plugin for HAROS

Expand All @@ -26,7 +22,7 @@ Build the HAROS docker image, for your desired ROS distro version:

```
cd path-to-ros-model-extractors-repo
[sudo] docker build --tag=haros_ROSDISTRO -f ROSDISTRO/Dockerfile .
[sudo] docker build --tag=haros_ROSDISTRO -f docker/ROSDISTRO/Dockerfile .
```

Call the ros-model extractor plugin, remember you have to also clone the repository to be analysed:
Expand All @@ -48,13 +44,8 @@ Additionally, the analysis offers the option to analyze all the nodes of a packa
```

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)
- Parser for launch files and analysis of the full system

File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 11 additions & 7 deletions haros_runner.sh → docker/haros_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ then
then
source install/setup.bash
rosdep install -y -i -r --from-path src
colcon build --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
colcon build --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=1 --no-warn-unused-cli
source ${5}/install/setup.bash
colcon list > /tmp/colcon_list.txt
path_to_src_code=$(cat /tmp/colcon_list.txt | grep "^$1" | awk '{ print $2}')
Expand Down Expand Up @@ -91,16 +91,14 @@ then
else
python /ros_model_extractor.py --clang-version $clang_version --package "$1" --name "$2" --"${3}" --model-path "${4}" --ws "${5}" --repo $model_repo>> ${4}/extractor.log
fi
#cat extractor.log
elif [[ $PYTHON_VERSION == "3" ]]
then
if [ "${2}" = "--all" ]
then
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 >> ${4}/extractor.log
python3 /ros_code_analysis/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 >> ${4}/extractor.log
else
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>> ${4}/extractor.log
python3 /ros_code_analysis/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>> ${4}/extractor.log
fi
#cat extractor.log
else
echo "Python version not supported"
exit
Expand All @@ -115,8 +113,14 @@ echo "Extraction finished. See the following report:"
cat ${4}/extractor.log
echo "~~~~~~~~~~~"


#echo "~~~~~~~~~~~"
#echo "Compile commands file:"
#cat ${5}/build/compile_commands.json
#echo "~~~~~~~~~~~"

echo "###########"
for generated_model in "${4}"/*.ros
for generated_model in "${4}"/*.ros2
do
echo "~~~~~~~~~~~"
echo "Print of the model: $generated_model:"
Expand All @@ -128,4 +132,4 @@ echo "###########"
done

## Clean and finish
rm -rf ${5}/src/*
#find ${5}/src -maxdepth 1 -type d ! -iname ros2model -exec rm -rvf {} \;
19 changes: 11 additions & 8 deletions humble/Dockerfile → docker/humble/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ 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/ipa320/ros2model.git#egg=ros2model
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
Expand All @@ -41,6 +41,8 @@ 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 git clone https://github.com/ipa320/ros2model.git /home/extractor/ws/src/ros2model
RUN git clone https://github.com/ipa-nhg/ros2model.git -b PythonInstallTemplatesFolder /home/extractor/ws/src/ros2model

RUN mkdir -p /home/extractor/results
RUN chown extractor:extractor /home/extractor/results
Expand All @@ -55,7 +57,7 @@ RUN if [ $enable_ssh ] ; then mkdir -p /home/extractor/.ssh/ && \
touch /home/extractor/.ssh/config && \
chmod 600 /home/extractor/.ssh/config ; fi

COPY --chown=extractor:root ssh_config/ /keys/
COPY --chown=extractor:root docker/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
####
Expand All @@ -64,19 +66,20 @@ 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 ;\
colcon build --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=1 --no-warn-unused-cli ;\
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 /
#COPY ${path_to_scripts}messages_generator_runner.sh /
#COPY ${path_to_scripts}generate_messages_model_helper.sh /
COPY docker/haros_runner.sh /
COPY ros_code_analysis /

COPY helper_scripts/test.sh /

EXPOSE 4005
#CMD sudo chown -R extractor:extractor /home/extractor/results
5 changes: 3 additions & 2 deletions humble/README.md → docker/humble/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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 .
[sudo] docker build --tag=haros_humble -f docker/humble/Dockerfile .
```

Call the ros-model extractor plugin, remember you have to also clone the repository to be analysed:
Expand All @@ -21,7 +21,8 @@ For example:

[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"
[sudo] docker run -it haros_humble:latest /haros_runner.sh cpp_basic --all node . /home/extractor/ws "https://github.com/ipa-nhg/cpp_basic_ros2"


```

Expand Down
File renamed without changes.
File renamed without changes.
16 changes: 9 additions & 7 deletions noetic/Dockerfile → docker/noetic/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/usr/lib/llvm-10/lib
RUN pip3 install --upgrade pip
RUN pip3 install -Iv clang==10.0.1
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/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 pip3 install -e git+https://github.com/ipa320/ros2model.git#egg=ros2model

RUN apt-get update && apt-get install -y ros-noetic-desktop && apt upgrade -y

Expand All @@ -56,7 +57,7 @@ RUN if [ $enable_ssh ] ; then mkdir -p /home/extractor/.ssh/ && \
touch /home/extractor/.ssh/config && \
chmod 600 /home/extractor/.ssh/config ; fi

COPY --chown=extractor:root ssh_config/ /keys/
COPY --chown=extractor:root docker/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
####
Expand All @@ -75,11 +76,12 @@ RUN source /opt/ros/$ROS_DISTRO/setup.bash;\
ENV PYTHON_VERSION 3
RUN echo 'source /home/extractor/ws/devel/setup.bash' >> /home/extractor/.bashrc

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 /
#COPY ${path_to_scripts}messages_generator_runner.sh /
#COPY ${path_to_scripts}generate_messages_model_helper.sh /
COPY docker/haros_runner.sh /
COPY ros_code_analysis /

COPY helper_scripts/test.sh /

EXPOSE 4004
#CMD sudo chown -R extractor:extractor /home/extractor/results
File renamed without changes.
File renamed without changes.
44 changes: 0 additions & 44 deletions haros_runner.py

This file was deleted.

File renamed without changes.
Empty file.
Loading
Loading