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

update Dockerfile, install.sh and github workflow #4

Merged
merged 1 commit into from
Nov 23, 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
21 changes: 5 additions & 16 deletions .github/workflows/catkin_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 11 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ cd catkin_ws/src
git clone --recursive [email protected]: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
Expand Down
36 changes: 9 additions & 27 deletions scripts/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
ARG ROS_DISTRO=noetic

FROM ros:$ROS_DISTRO
LABEL description="DroneCAN communicator"
LABEL maintainer="[email protected]"
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 && \
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
13 changes: 13 additions & 0 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -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
11 changes: 7 additions & 4 deletions scripts/install_libuavcan.sh
Original file line number Diff line number Diff line change
@@ -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
5 changes: 0 additions & 5 deletions scripts/install_requirements.sh

This file was deleted.

3 changes: 0 additions & 3 deletions scripts/requirements.txt

This file was deleted.