Skip to content

Commit

Permalink
Pull Request #2: Updated with working Docker containers and CLI appli…
Browse files Browse the repository at this point in the history
…cation
  • Loading branch information
ayhamalharbat committed Jun 4, 2024
2 parents 4b0ab8b + dca903f commit 2709500
Show file tree
Hide file tree
Showing 29 changed files with 1,605 additions and 3 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Setup and build packages

# To manually run the workflow on GH, use the workflow_dispatch event trigger
# on: workflow_dispatch

# To automatically run on every push to GH, use the push and pull_request event trigger
on:
push:
branches:
- main
pull_request:
branches:
- main

env:
USER: github.actor

jobs:
build:
runs-on: ubuntu-latest
container:
image: px4io/px4-dev-ros-noetic:latest
options: --privileged --ulimit core=-1 --security-opt seccomp=unconfined
steps:

- name: Check environment
run: |
export
ulimit -a
- name: Update ROS dependencies
run: |
. /opt/ros/$ROS_DISTRO/setup.sh
rosdep update
- name: Create dependency workspace
run: |
mkdir -p ~/dependencies
cd ~/dependencies
- name: Install PX4 Dependencies
run: |
mkdir -p ~/dependencies
cd ~/dependencies
wget https://raw.githubusercontent.com/PX4/PX4-Autopilot/main/Tools/setup/ubuntu.sh
wget https://raw.githubusercontent.com/PX4/PX4-Autopilot/main/Tools/setup/requirements.txt
chmod +x ~/dependencies/ubuntu.sh && . ~/dependencies/ubuntu.sh
- name: Install MAVROS using binaries
run: |
mkdir -p ~/dependencies
cd ~/dependencies
sudo apt-get install ros-$ROS_DISTRO-mavros ros-$ROS_DISTRO-mavros-extras
- name: Install ROS building dependencies
run: |
sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential -y
sudo apt install python3-catkin-tools python3-rosinstall-generator python3-osrf-pycommon -y
sudo apt-get install ros-$ROS_DISTRO-rqt ros-$ROS_DISTRO-rqt-common-plugins -y
pip install scipy
- name: Create new workspace
run: |
cd ~
mkdir -p sarax_ws/src
- name: Initialise catkin workspace
run: |
cd ~/sarax_ws/
. /opt/ros/$ROS_DISTRO/setup.sh
catkin init
wstool init src
- name: Clone Sarax project
run: |
cd ~/sarax_ws/src
git clone ${{ github.server_url }}/${{ github.repository }}.git
ls -l
- name: Get dependencies using rosdep
run: |
cd ~/sarax_ws/
. /opt/ros/$ROS_DISTRO/setup.sh
rosdep install --from-paths src --ignore-src -r -y --skip-keys="python-scipy"
- name: Build workspace
if: always()
run: |
cd ~/sarax_ws/
. /opt/ros/$ROS_DISTRO/setup.sh
catkin build
53 changes: 53 additions & 0 deletions .github/workflows/publish_docker_package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Publish docker image as package

# To manually run the workflow on GH, use the workflow_dispatch event trigger
# on: workflow_dispatch

# To test workflow using act, use the push event
# on:
# push:
# branches:
# - main

# To automatically run depending on the status of the build.yaml workflow, use workflow_run event trigger
on:
workflow_run:
workflows: [Setup and build packages]
types: [completed]

jobs:
on-success:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- run: echo 'The build workflows have passed'

on-failure:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- run: echo 'The build workflows have failed'

publish_package:
needs: on-success # Uncomment when on default branch (main)
runs-on: ubuntu-latest
steps:

- name: Checkout repository
uses: actions/checkout@v4

- name: Login to GH container registry
run: |
docker login --username ${{ github.actor }} --password ${{ secrets.GH_PAT }} ghcr.io
- name: Cleanup system
run: |
docker image prune
- name: Build Docker image
run: |
docker build --no-cache . -t ghcr.io/arief-ak/sarax-framework:latest
- name: Publish image
run: |
docker push ghcr.io/arief-ak/sarax-framework:latest
44 changes: 44 additions & 0 deletions .github/workflows/sitl_build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Sarax PX4 SITL

# To manually run the workflow on GH, use the workflow_dispatch event trigger
# on: workflow_dispatch

# To test workflow using act, use the push event
# on:
# push:
# branches:
# - main

# To automatically run depending on the status of the build.yaml workflow, use workflow_run event trigger
on:
workflow_run:
workflows: [Publish docker image as package]
types: [completed]

jobs:
on-success:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- run: echo 'The Setup and build packages workflow passed'

on-failure:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- run: echo 'The Setup and build packages workflow failed'

build:
needs: on-success # Uncomment when on default branch (main)
runs-on: ubuntu-latest
container:
image: ghcr.io/arief-ak/sarax-framework:latest
options: --privileged --ulimit core=-1 --security-opt seccomp=unconfined
steps:

- name: Run sarax SITL
run: |
. /home/user/.bashrc
cd /home/user/sarax_ws && ls -l
cd /home/user/sarax_ws/PX4-Autopilot/
./sarax_plus_sitl.bash
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vscode/
84 changes: 84 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Pull px4-ros-noetic image
FROM px4io/px4-dev-ros-noetic

# Update the linux environment
RUN echo "Updating environment" \
&& sudo apt install nano -y \
&& sudo apt install figlet -y \
&& sudo apt update -y \
&& sudo apt upgrade -y

# Check environment
RUN echo "Checking environment" \
&& export \
&& ulimit -a

# Perform rosdep
RUN echo "Use rosdep to update dependencies" \
&& . /opt/ros/$ROS_DISTRO/setup.sh \
&& rosdep update

# Create a dependency workspace
RUN mkdir -p ~/dependencies \
&& cd ~/dependencies

# Install PX4 Dependencies
RUN cd ~/dependencies \
&& wget https://raw.githubusercontent.com/PX4/PX4-Autopilot/main/Tools/setup/ubuntu.sh \
&& wget https://raw.githubusercontent.com/PX4/PX4-Autopilot/main/Tools/setup/requirements.txt \
&& chmod +x ~/dependencies/ubuntu.sh && . ~/dependencies/ubuntu.sh

# Install MAVROS using binaries
RUN cd ~/dependencies \
&& sudo apt-get install ros-$ROS_DISTRO-mavros ros-$ROS_DISTRO-mavros-extras -y \
&& wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh \
&& chmod +x install_geographiclib_datasets.sh && ./install_geographiclib_datasets.sh

# Install ROS build dependencies
RUN sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential -y \
&& sudo apt install python3-catkin-tools python3-rosinstall-generator python3-osrf-pycommon -y \
&& sudo apt-get install ros-$ROS_DISTRO-rqt ros-$ROS_DISTRO-rqt-common-plugins -y \
&& pip install scipy

# Create a workspace
RUN echo "Creating sarax workspace" \
&& cd /home \
&& mkdir -p user/sarax_ws/src/sarax

# Clone the sarax branch from the PX4-Autopilot repository
RUN cd /home/user/sarax_ws/ \
&& git clone --recursive -b v1.13.2-sarax-sim https://github.com/SaxionMechatronics/PX4-Autopilot.git

# Initialise catkin workspace
RUN cd /home/user/sarax_ws/ \
&& . /opt/ros/$ROS_DISTRO/setup.sh \
&& catkin init \
&& wstool init src

# Copy the source into workspace source directory
COPY . /home/user/sarax_ws/src/sarax/

# Install dependencies using rosdep
RUN cd /home/user/sarax_ws/ \
&& . /opt/ros/$ROS_DISTRO/setup.sh \
&& rosdep install --from-paths src --ignore-src -r -y --skip-keys="python-scipy"

# Build the workspace
RUN cd /home/user/sarax_ws/ \
&& . /opt/ros/$ROS_DISTRO/setup.sh \
&& catkin build

# Export graphic libraries
RUN echo "# If running on WSL2, uncomment the following lines" >> ~/.bashrc \
&& echo "# export LD_LIBRARY_PATH=/usr/lib/wsl/lib" >> ~/.bashrc \
&& echo "# export LIBVA_DRIVER_NAME=d3d12" >> ~/.bashrc

# Export worskpace and update sourcing
RUN cd /home/user/sarax_ws/ \
&& echo "export SARAX_WS=$PWD" >> ~/.bashrc \
&& echo "source \$SARAX_WS/devel/setup.bash" >> ~/.bashrc \
&& echo "source \$SARAX_WS/src/sarax/scripts/container/docker_entrypoint.sh" >> ~/.bashrc

# Build the simulator to speed up running within the container
RUN cd /home/user/sarax_ws/PX4-Autopilot \
&& ./sarax_plus_sitl.bash
Loading

0 comments on commit 2709500

Please sign in to comment.