Skip to content

Commit

Permalink
refactor docker, install.sh and DSDL
Browse files Browse the repository at this point in the history
  • Loading branch information
PonomarevDA committed Nov 23, 2024
1 parent 4840cde commit da445ec
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 87 deletions.
21 changes: 9 additions & 12 deletions .github/workflows/catkin_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/dsdl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 1 addition & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 0 additions & 19 deletions compile_dsdl.sh

This file was deleted.

11 changes: 0 additions & 11 deletions install_requirements.sh

This file was deleted.

35 changes: 8 additions & 27 deletions scripts/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down
9 changes: 9 additions & 0 deletions scripts/catkin_build.sh
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>

source /opt/ros/$ROS_DISTRO/setup.bash
cd /catkin_ws
git config --global http.sslverify false
catkin build
2 changes: 1 addition & 1 deletion scripts/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
57 changes: 57 additions & 0 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>

# 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

0 comments on commit da445ec

Please sign in to comment.