diff --git a/.github/workflows/catkin_build.yml b/.github/workflows/catkin_build.yml index 2fddc83..a52c164 100644 --- a/.github/workflows/catkin_build.yml +++ b/.github/workflows/catkin_build.yml @@ -12,27 +12,16 @@ jobs: container: image: ros:noetic steps: - - run: apt-get update && apt-get install -y git - - run: apt-get install -y python3-pip ros-noetic-catkin python3-catkin-tools + - name: Handle issue with actions/checkout when Git version is less than 2.18 + run: apt-get update && apt-get install -y git - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: path: catkin_ws/src/dronecan_communicator submodules: recursive - name: Install requirements - run: | - cd catkin_ws/src/dronecan_communicator - ./scripts/install_requirements.sh - ./scripts/install_libuavcan.sh - - # - name: Generate custom dsdl - # run: | - # cd catkin_ws/src/dronecan_communicator - # ./scripts/compile_dsdl.sh + run: ./catkin_ws/src/dronecan_communicator/scripts/install.sh - name: catkin build - run: | - source /opt/ros/$ROS_DISTRO/setup.bash - cd catkin_ws - catkin build + run: source /opt/ros/$ROS_DISTRO/setup.bash && cd catkin_ws && catkin build diff --git a/CMakeLists.txt b/CMakeLists.txt index 21424b6..6787ef0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,14 @@ cmake_minimum_required(VERSION 3.0.2) project(uavcan_communicator) +execute_process( + COMMAND bash ${CMAKE_SOURCE_DIR}/scripts/install_libuavcan.sh + RESULT_VARIABLE install_libuavcan_result +) +if(NOT install_libuavcan_result EQUAL 0) + message(FATAL_ERROR "install_libuavcan.sh failed. Aborting.") +endif() + find_package(catkin REQUIRED COMPONENTS roscpp std_msgs @@ -30,9 +38,9 @@ target_include_directories(${PROJECT_NAME}_uavcan_communicator set_target_properties(${PROJECT_NAME}_uavcan_communicator PROPERTIES OUTPUT_NAME uavcan_communicator PREFIX "") add_dependencies(${PROJECT_NAME}_uavcan_communicator ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) target_link_libraries(${PROJECT_NAME}_uavcan_communicator - ${catkin_LIBRARIES} - ${UAVCAN_LIB} - rt + ${catkin_LIBRARIES} + ${UAVCAN_LIB} + rt ) install(TARGETS ${PROJECT_NAME}_uavcan_communicator diff --git a/README.md b/README.md index 970fef2..df00ea5 100644 --- a/README.md +++ b/README.md @@ -51,9 +51,7 @@ cd catkin_ws/src git clone --recursive git@github.com:RaccoonlabDev/uavcan_communicator.git cd uavcan_communicator git submodule update --init --recursive -./scripts/install_requirements.sh -./scripts/install_libuavcan.sh -./scripts/compile_dsdl.sh +./scripts/install.sh ``` ## 3. Running diff --git a/scripts/Dockerfile b/scripts/Dockerfile index 732ab7a..74726cb 100644 --- a/scripts/Dockerfile +++ b/scripts/Dockerfile @@ -1,38 +1,20 @@ +# This software is distributed under the terms of the GPL v3 License. +# Copyright (c) 2022-2023 Dmitry Ponomarev. +# Author: Dmitry Ponomarev ARG ROS_DISTRO=noetic - FROM ros:$ROS_DISTRO LABEL description="DroneCAN communicator" LABEL maintainer="ponomarevda96@gmail.com" SHELL ["/bin/bash", "-c"] WORKDIR /catkin_ws/src/dronecan_communicator -# 1. Install basic requirements -RUN apt-get update && apt-get upgrade -y && apt-get install -y git ros-$ROS_DISTRO-catkin python3-pip python3-catkin-tools -RUN if [[ "$ROS_DISTRO" = "melodic" ]] ; then apt-get install -y python-pip python-catkin-tools ; fi - -# 2. Install package requirements -COPY scripts/install_libuavcan.sh scripts/install_libuavcan.sh -COPY scripts/install_requirements.sh scripts/install_requirements.sh -COPY scripts/requirements.txt scripts/requirements.txt -COPY libs/ libs/ -RUN scripts/install_requirements.sh -RUN scripts/install_libuavcan.sh - -# 3. Copy main package files -COPY CMakeLists.txt CMakeLists.txt -COPY package.xml package.xml -COPY src/ src/ - -# 4. For custom DroneCAN msgs -# COPY custom_msgs/ custom_msgs/ -# RUN ./scripts/compile_dsdl.sh - -# 5. Build -RUN source /opt/ros/$ROS_DISTRO/setup.bash && cd /catkin_ws && catkin build +# 1. Install requirements +COPY scripts/install.sh scripts/install.sh +RUN ./scripts/install.sh -# 6. Copy auxilliary package files -COPY config/ config/ -COPY launch/ launch/ +# 2. Build ROS +COPY . /catkin_ws/src/dronecan_communicator +RUN /catkin_ws/src/dronecan_communicator/scripts/catkin_build.sh CMD source /opt/ros/$ROS_DISTRO/setup.bash && \ source /catkin_ws/devel/setup.bash && \ diff --git a/scripts/catkin_build.sh b/scripts/catkin_build.sh new file mode 100755 index 0000000..810966a --- /dev/null +++ b/scripts/catkin_build.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# This software is distributed under the terms of the GPL v3 License. +# Copyright (c) 2022-2023 Dmitry Ponomarev. +# Author: Dmitry Ponomarev + +source /opt/ros/$ROS_DISTRO/setup.bash +cd /catkin_ws +git config --global http.sslverify false +catkin build diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100755 index 0000000..969a2a2 --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,13 @@ +#!/bin/bash +CRNT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +REPO_DIR="$(dirname "$CRNT_DIR")" + +set -e + +apt-get update +apt-get install -y git \ + can-utils \ + ros-$ROS_DISTRO-catkin \ + ros-$ROS_DISTRO-mavros-msgs \ + python3-pip \ + python3-catkin-tools diff --git a/scripts/install_libuavcan.sh b/scripts/install_libuavcan.sh index 61d8c4d..56e3c70 100755 --- a/scripts/install_libuavcan.sh +++ b/scripts/install_libuavcan.sh @@ -1,11 +1,14 @@ #!/bin/bash -# Instruction from https://github.com/UAVCAN/libuavcan/tree/legacy-v0#using-in-a-gnulinux-application +CRNT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +REPO_DIR="$(dirname "$CRNT_DIR")" + +set -e -cd "$(dirname "$0")" -cd ../libs/libuavcan +# Install libuavcan +# Instruction from https://github.com/UAVCAN/libuavcan/tree/legacy-v0#using-in-a-gnulinux-application +cd ${REPO_DIR}/libs/libuavcan mkdir -p build cd build -rm -r * # handle case if build directory is not empty bacause it may lead to fail cmake .. make sudo make install diff --git a/scripts/install_requirements.sh b/scripts/install_requirements.sh deleted file mode 100755 index caeaee7..0000000 --- a/scripts/install_requirements.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) - -sudo apt-get install -y can-utils ros-$ROS_DISTRO-mavros-msgs -pip install -r $SCRIPT_DIR/requirements.txt diff --git a/scripts/requirements.txt b/scripts/requirements.txt deleted file mode 100644 index 1aec434..0000000 --- a/scripts/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -pyuavcan_v0 -monotonic # for python 2.7 -pyquaternion