Skip to content

Commit

Permalink
Merge pull request #25 from ipa320/humble
Browse files Browse the repository at this point in the history
Add Humble distro support
  • Loading branch information
ipa-nhg authored Nov 30, 2023
2 parents 54cbd0c + 49850bd commit af8567b
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions foxy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
18 changes: 14 additions & 4 deletions haros_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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
Expand Down
82 changes: 82 additions & 0 deletions humble/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# 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-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 4B63CF8FDE49746E98FA01DDAD19BAB3CBF125EA

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
28 changes: 28 additions & 0 deletions humble/README.md
Original file line number Diff line number Diff line change
@@ -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 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"
[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"
```


3 changes: 2 additions & 1 deletion melodic/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
3 changes: 2 additions & 1 deletion noetic/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
8 changes: 5 additions & 3 deletions ros_model_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()


Expand Down

0 comments on commit af8567b

Please sign in to comment.