Skip to content

Commit

Permalink
Workflow update
Browse files Browse the repository at this point in the history
  • Loading branch information
rafal-gorecki committed Jan 5, 2024
1 parent 660c902 commit 4130675
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 92 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/build-docker-image-gazebo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ on:
# - 'ros1'
pull_request:
types: [closed]

jobs:
build:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
include:
- ros-distro: melodic
- ros-distro: noetic

steps:
Expand All @@ -23,19 +22,19 @@ jobs:

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
version: latest

- name: Login to Docker Registry
uses: docker/login-action@v1
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push (production)
if: github.ref_name == 'ros1'
uses: docker/build-push-action@v2
Expand All @@ -62,4 +61,4 @@ jobs:
ROS_DISTRO=${{ matrix.ros-distro }}
tags: husarion/rosbot:${{ matrix.ros-distro }}-simulation-${{ github.head_ref || github.ref_name }}
cache-from: type=registry,ref=husarion/rosbot:${{ matrix.ros-distro }}-simulation-${{ github.head_ref || github.ref_name }}
cache-to: type=inline
cache-to: type=inline
21 changes: 7 additions & 14 deletions .github/workflows/build-docker-image-hardware.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,16 @@ on:
workflow_dispatch:
pull_request:
types: [closed]

jobs:
build:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
include:
- ros-distro: melodic
ros-noetic-msgs: 0
rosbot-fw-release: 0.16.1
platforms: "linux/amd64, linux/arm64, linux/arm/v7"
- ros-distro: noetic
ros-noetic-msgs: 1
rosbot-fw-release: 0.16.1
rosbot-fw-release: 0.16.2
platforms: "linux/amd64, linux/arm64"

steps:
Expand All @@ -30,19 +25,19 @@ jobs:

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
version: latest

- name: Login to Docker Registry
uses: docker/login-action@v1
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push (production)
if: github.ref_name == 'ros1'
uses: docker/build-push-action@v2
Expand All @@ -53,9 +48,8 @@ jobs:
push: true
build-args: |
ROS_DISTRO=${{ matrix.ros-distro }}
ROS_NOETIC_MSGS=${{ matrix.ros-noetic-msgs }}
ROSBOT_FW_RELEASE=${{ matrix.rosbot-fw-release }}
tags: husarion/rosbot:${{ matrix.ros-distro }}
tags: husarion/rosbot:${{ matrix.ros-distro }}
cache-from: type=registry,ref=husarion/rosbot:${{ matrix.ros-distro }}
cache-to: type=inline

Expand All @@ -69,8 +63,7 @@ jobs:
push: true
build-args: |
ROS_DISTRO=${{ matrix.ros-distro }}
ROS_NOETIC_MSGS=${{ matrix.ros-noetic-msgs }}
ROSBOT_FW_RELEASE=${{ matrix.rosbot-fw-release }}
tags: husarion/rosbot:${{ matrix.ros-distro }}-${{ github.head_ref || github.ref_name }}
cache-from: type=registry,ref=husarion/rosbot:${{ matrix.ros-distro }}-${{ github.head_ref || github.ref_name }}
cache-to: type=inline
cache-to: type=inline
77 changes: 10 additions & 67 deletions Dockerfile.hardware
Original file line number Diff line number Diff line change
@@ -1,68 +1,7 @@
ARG ROS_DISTRO=melodic


## =========================== STM32 firmware===============================
# FROM --platform=linux/amd64 ubuntu:18.04 as stm32_firmware_builder
# TODO: wget from releases instead
FROM --platform=linux/amd64 ubuntu:20.04 AS stm32_firmware_builder

ARG ROSBOT_FW_RELEASE=0.16.1
ARG ROS_NOETIC_MSGS=0

SHELL ["/bin/bash", "-c"]

# ENV PIO_VERSION="5.1.0"
RUN apt update && apt install -y \
python3 \
python3-pip \
git \
wget \
tree

# https://docs.platformio.org/en/latest/core/installation.html#system-requirements
# RUN pip3 install -U platformio==${PIO_VERSION}
RUN pip3 install -U platformio

RUN git clone https://github.com/husarion/rosbot-stm32-firmware.git --branch ${ROSBOT_FW_RELEASE} && \
mkdir -p ~/.platformio/packages/framework-mbed/features/ && \
cp rosbot-stm32-firmware/.mbedignore ~/.platformio/packages/framework-mbed/features/.mbedignore

WORKDIR /rosbot-stm32-firmware

RUN git submodule update --init --recursive

# RUN wget https://github.com/husarion/rosbot-stm32-firmware/archive/refs/tags/${ROSBOT_FW_RELEASE}.tar.gz && \
# tar -xf *.tar.gz && \
# mv rosbot-stm32-firmware* rosbot-stm32-firmware && \
# mkdir -p ~/.platformio/packages/framework-mbed/features/ && \
# cp rosbot-stm32-firmware/.mbedignore ~/.platformio/packages/framework-mbed/features/.mbedignore

WORKDIR /rosbot-stm32-firmware

RUN export LC_ALL=C.UTF-8 && \
export LANG=C.UTF-8 && \
pio project init -e core2_diff -O \
"build_flags= \
-I\$PROJECTSRC_DIR/TARGET_CORE2 \
-DPIO_FRAMEWORK_MBED_RTOS_PRESENT \
-DPIO_FRAMEWORK_EVENT_QUEUE_PRESENT \
-DMBED_BUILD_PROFILE_RELEASE \
-DJOINT_STATES_ENABLE=1 \
-DROS_NOETIC_MSGS=${ROS_NOETIC_MSGS} \
-DKINEMATIC_TYPE=0" && \
pio project init -e core2_mec -O \
"build_flags= \
-I\$PROJECTSRC_DIR/TARGET_CORE2 \
-DPIO_FRAMEWORK_MBED_RTOS_PRESENT \
-DPIO_FRAMEWORK_EVENT_QUEUE_PRESENT \
-DMBED_BUILD_PROFILE_RELEASE \
-DJOINT_STATES_ENABLE=1 \
-DROS_NOETIC_MSGS=${ROS_NOETIC_MSGS} \
-DKINEMATIC_TYPE=1" && \
pio run
ARG ROS_DISTRO=noetic
ARG ROSBOT_FW_RELEASE=0.16.2

## =========================== ROS package builder ===============================

FROM ros:$ROS_DISTRO-ros-core AS pkg-builder

SHELL ["/bin/bash", "-c"]
Expand Down Expand Up @@ -93,7 +32,7 @@ WORKDIR /ros_ws
# clone robot github repositories
RUN mkdir -p src && \
git clone https://github.com/husarion/rosbot_ros.git --branch=melodic src/rosbot_ros && \
git clone https://github.com/husarion/rosbot_ekf.git --branch=master src/rosbot_ekf
git clone https://github.com/husarion/rosbot_ekf.git --branch=master src/rosbot_ekf

# build ROS workspace
RUN source /opt/ros/$ROS_DISTRO/setup.bash && \
Expand All @@ -103,9 +42,12 @@ RUN source /opt/ros/$ROS_DISTRO/setup.bash && \
## =========================== Final Stage ===============================
FROM ros:$ROS_DISTRO-ros-core

ARG ROSBOT_FW_RELEASE

SHELL ["/bin/bash", "-c"]

RUN apt update && apt install -y \
curl \
python3-pip \
stm32flash \
ros-$ROS_DISTRO-rosserial-python \
Expand All @@ -129,9 +71,10 @@ RUN apt update && apt install -y \
# copy ROS package from previous step
COPY --from=pkg-builder /ros_ws /ros_ws

# copy firmware built in previous stage
COPY --from=stm32_firmware_builder /rosbot-stm32-firmware/.pio/build/core2_diff/firmware.bin /root/firmware_diff.bin
COPY --from=stm32_firmware_builder /rosbot-stm32-firmware/.pio/build/core2_mec/firmware.bin /root/firmware_mecanum.bin
# copy firmware built
RUN cd /root && \
curl -LJ https://github.com/husarion/rosbot-stm32-firmware/releases/download/$ROSBOT_FW_RELEASE/firmware_diff.bin -o firmware_diff.bin && \
curl -LJ https://github.com/husarion/rosbot-stm32-firmware/releases/download/$ROSBOT_FW_RELEASE/firmware_mec.bin -o firmware_mecanum.bin

# copy scripts
COPY ./flash-firmware.py /
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.simulation
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG ROS_DISTRO=melodic
ARG ROS_DISTRO=noetic

FROM osrf/ros:$ROS_DISTRO-desktop

Expand Down Expand Up @@ -34,4 +34,4 @@ RUN apt-get update && \
# replace entrypoint
ENTRYPOINT ["/ros_ws/ros_entrypoint.sh"]

CMD ["bash"]
CMD ["bash"]
6 changes: 3 additions & 3 deletions flash-firmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@ def __init__(self, sys_arch, binary_file):

print(f"System architecture: {self.sys_arch}")

if self.sys_arch.stdout == b"armv7l\n":
if self.sys_arch == "armv7l\n":
# Setups ThinkerBoard pins
print("Device: ThinkerBoard\n")
self.port = "/dev/ttyS1"
boot0_pin_no = 164
reset_pin_no = 184

elif self.sys_arch.stdout == b"x86_64\n":
elif self.sys_arch == "x86_64\n":
# Setups UpBoard pins
print("Device: UpBoard\n")
self.port = "/dev/ttyS4"
boot0_pin_no = 17
reset_pin_no = 18

elif self.sys_arch.stdout == b"aarch64\n":
elif self.sys_arch == "aarch64\n":
# Setups RPi pins
print("Device: RPi\n")
self.port = "/dev/ttyAMA0"
Expand Down

0 comments on commit 4130675

Please sign in to comment.