diff --git a/.github/workflows/catkin_build.yml b/.github/workflows/catkin_build.yml index e806201..57b224e 100644 --- a/.github/workflows/catkin_build.yml +++ b/.github/workflows/catkin_build.yml @@ -14,16 +14,16 @@ jobs: container: image: ros:noetic steps: - - run: apt-get update && apt-get install -y git - - run: if [[ "$ROS_DISTRO" = "noetic" ]] ; then apt-get install -y python3-pip ros-noetic-catkin python3-catkin-tools ; fi + - name: Handle issue with actions/checkout when Git version is less than 2.18 + run: apt-get install git - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: path: catkin_ws/src/cyphal_communicator submodules: recursive - name: Install requirements - run: ./catkin_ws/src/cyphal_communicator/install_requirements.sh + run: ./catkin_ws/src/cyphal_communicator/scripts/install.sh --full - name: Catkin build run: source /opt/ros/noetic/setup.bash && cd catkin_ws && catkin build @@ -33,18 +33,15 @@ jobs: container: image: ros:noetic steps: - - run: apt-get update && apt-get install -y git python3-pip + - name: Handle issue with actions/checkout when Git version is less than 2.18 + run: apt-get install git - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: submodules: recursive - name: Install requirements - run: ./install_requirements.sh + run: ./scripts/install.sh --full - name: Catkin build - run: | - mkdir build - cd build - cmake .. -DARDUPILOT_JSON_SIM_INTERFACE=1 . - make + run: mkdir build && cd build && cmake .. -DARDUPILOT_JSON_SIM_INTERFACE=1 . && make diff --git a/.github/workflows/dsdl.yml b/.github/workflows/dsdl.yml index a34ce45..34fc1e0 100644 --- a/.github/workflows/dsdl.yml +++ b/.github/workflows/dsdl.yml @@ -13,7 +13,7 @@ jobs: submodules: recursive - name: Install requirements - run: pip install yakut + run: ./scripts/install.sh --dsdl - name: Generate DSDL run: ./scripts/generate_${{ matrix.language }}_from_dsdl.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 5447ffd..8225cb0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,7 @@ include_directories(${CYPHAL_REPO_DIR}) include_directories(${CYPHAL_REPO_DIR}/Udral) include_directories(src) include_directories(src/autopilot_interface) +include_directories(src/nunavut_out) add_executable(${PROJECT_NAME} ${CYPHAL_REPO_DIR}/Udral/actuator.cpp @@ -80,17 +81,3 @@ set(GIT_HASH "0x${GIT_HASH_64_BIT}") add_definitions(-DGIT_HASH=${GIT_HASH}) add_definitions(-DAPP_VERSION_MAJOR=0) add_definitions(-DAPP_VERSION_MINOR=8) - -# Generate DSDL when build -add_custom_target( - compile_dsdl ALL - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/compile_dsdl.sh - COMMENT "Compile DSDL" -) -add_custom_target( - gen_headers ALL - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/Libs/cyphal_application/scripts/nnvg_generate_c_headers.sh - COMMENT "Generate C headers" -) -add_dependencies(${PROJECT_NAME} compile_dsdl) -add_dependencies(${PROJECT_NAME} gen_headers) diff --git a/README.md b/README.md index de98b82..98be8d9 100644 --- a/README.md +++ b/README.md @@ -435,8 +435,6 @@ The cyphal communicator allows to use multiple interfaces. By default it is base ## 5. Installation -Build the package as usual ROS package with `catkin build`. It will automatically compile DSDL at the build time with [compile_dsdl.sh](compile_dsdl.sh) script. - Before running the communicator, you need to do 3 things: 1. Create virtual CAN. It is expected that you are using CAN-sniffer device such as [UAVCAN sniffer and programmer](https://docs.raccoonlab.co/guide/programmer_sniffer/). An example of script that creates SLCAN is [scripts/create_slcan.sh](scripts/create_slcan.sh). This script automatically detect a connected device and create `slcan0` port. You should create virtual CAN once after each sniffer connection to your PC. 2. Configure environment variables. This step is required for setting subjects port id and few pathes. As an example, you can run `source scripts/config.sh`. You should call this script in each shell session. diff --git a/compile_dsdl.sh b/compile_dsdl.sh deleted file mode 100755 index 67ccb5b..0000000 --- a/compile_dsdl.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -# This software is distributed under the terms of the GPL v3 License. -# Copyright (c) 2022-2023 Dmitry Ponomarev. -# Author: Dmitry Ponomarev - -REPO_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -DSDL_PATH=$REPO_DIR/public_regulated_data_types -ZUBAX_DSDL_PATH=$REPO_DIR/zubax_dsdl -YAKUT_COMPILE_OUTPUT=$REPO_DIR/compile_output - -cd $REPO_DIR - -git clone https://github.com/OpenCyphal/public_regulated_data_types.git -cd public_regulated_data_types && git checkout 935973b && cd .. -yakut compile $DSDL_PATH/uavcan $DSDL_PATH/reg -O $YAKUT_COMPILE_OUTPUT - -git clone https://github.com/Zubax/zubax_dsdl.git -cd zubax_dsdl && git checkout b14f6c8 && cd .. -yakut compile $DSDL_PATH/uavcan $ZUBAX_DSDL_PATH/zubax -O $YAKUT_COMPILE_OUTPUT diff --git a/install_requirements.sh b/install_requirements.sh deleted file mode 100755 index 6d3a544..0000000 --- a/install_requirements.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# This software is distributed under the terms of the GPL v3 License. -# Copyright (c) 2022-2023 Dmitry Ponomarev. -# Author: Dmitry Ponomarev - -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) - -sudo apt install -y ros-$ROS_DISTRO-mavros-msgs can-utils net-tools iproute2 - -python3 -m pip install --upgrade pip -python3 -m pip install -r $SCRIPT_DIR/requirements.txt diff --git a/scripts/Dockerfile b/scripts/Dockerfile index a6930cd..b71689e 100644 --- a/scripts/Dockerfile +++ b/scripts/Dockerfile @@ -5,38 +5,19 @@ ARG ROS_DISTRO=noetic FROM ros:$ROS_DISTRO LABEL description="Cyphal communicator" + SHELL ["/bin/bash", "-c"] WORKDIR /catkin_ws/src/cyphal_communicator +# 1. Install requirements +COPY scripts/install.sh /tmp/install.sh +RUN apt-get update && /tmp/install.sh --full && rm -rf /tmp/* -# 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 - -# 2. Install requirements -COPY install_requirements.sh install_requirements.sh -COPY requirements.txt requirements.txt -RUN ./install_requirements.sh - - -# 3. Copy the source files -COPY CMakeLists.txt CMakeLists.txt -COPY package.xml package.xml -COPY src/ src/ -COPY compile_dsdl.sh compile_dsdl.sh -COPY Libs/ Libs/ -COPY .git/ .git/ - -# 4. Build ROS -RUN ./Libs/cyphal_application/scripts/nnvg_generate_c_headers.sh -RUN source /opt/ros/$ROS_DISTRO/setup.bash && cd ../../ && git config --global http.sslverify false && catkin build - -# 5. Copy other files -COPY scripts/ scripts/ -COPY launch/ launch/ -COPY scripts/config.sh scripts/config.sh +# 2. Copy the source files +COPY . /catkin_ws/src/cyphal_communicator +# 3. Build ROS +RUN /catkin_ws/src/cyphal_communicator/scripts/catkin_build.sh CMD echo "main process has been started" && \ 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/docker.sh b/scripts/docker.sh index 2dd3924..af8adb0 100755 --- a/scripts/docker.sh +++ b/scripts/docker.sh @@ -24,7 +24,7 @@ DOCKERFILE_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pw DOCKERFILE_PATH=$DOCKERFILE_DIR/Dockerfile setup_image_name_and_version() { - TAG_NAME=v0.2.0 + TAG_NAME=v0.5.2 DOCKERHUB_REPOSITOTY=ponomarevda/cyphal_communicator if uname -m | grep -q 'aarch64'; then diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100755 index 0000000..ce7f679 --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# This software is distributed under the terms of the GPL v3 License. +# Copyright (c) 2022-2023 Dmitry Ponomarev. +# Author: Dmitry Ponomarev + +# Exit immediately if a command exits with a non-zero status +set -e + +install_dsdl() { + echo "Installing tools for C++/Python generation from DSDL..." + pip install yakut + echo "DSDL tools installed." +} + +install_full() { + echo "Installing full dependencies..." + sudo apt install -y git \ + ros-$ROS_DISTRO-mavros-msgs \ + ros-$ROS_DISTRO-catkin \ + python3-pip \ + python3-catkin-tools \ + can-utils \ + net-tools \ + iproute2 + echo "Full tools installed." +} + +usage() { + echo "Usage: $0 [goal]" + echo "Goals:" + echo " --dsdl - Install DSDL tools" + echo " --full - Install all dependencies (DSDL + additional tools)" + echo "Example:" + echo " $0 --ros" + exit 1 +} + +# Main script logic +if [[ $# -ne 1 ]]; then + usage +fi + +goal=$1 + +case $goal in + --dsdl) + install_dsdl + ;; + --full) + install_full + ;; + *) + echo "Invalid goal: $goal" + usage + exit 1 + ;; +esac