Skip to content

Commit

Permalink
Foxy dockerfile (#165)
Browse files Browse the repository at this point in the history
* separate branch for humble

* humble dockerfile update

* galactic dockerfile update

* foxy dockerfile

* Galactic dockerfile (#167)

* separate branch for humble

* humble dockerfile update

* update readme

* galactic dockerfile update

* updated dockerfile and workflow

* formatting

* typo

* update versions

* typo

* try different naming scheme

* add required ros distro

* typo

* latest to 22.04

* separate clang format

* different argument format

* update lint version

* update setup ros as well

* lint cmakelists

* update workflow

* remove gcc10 from dockerfile

* Revert "remove gcc10 from dockerfile"

This reverts commit ca4d011.

* remove gcc10 in dockerfile

* Humble dockerfile (#166)

* humble dockerfile update

* update readme

* updated dockerfile and workflow

* formatting

* typo

* update versions

* typo

* try different naming scheme

* add required ros distro

* typo

* latest to 22.04

* separate clang format

* different argument format

* update lint version

* update setup ros as well

* lint cmakelists

* update workflow

* remove gcc10 in dockerfile

* use env variables for distro

* update readme

* changing platform syntax

* remove platform var

* syntax change again

* syntax again

* reword

* reword

* minor typo

* add colcon sequential arg

* rewording

* change platform

* minor arg change

* cmakelists format

* minor typo
  • Loading branch information
Serafadam authored Dec 2, 2022
1 parent e767261 commit ebc6d6f
Show file tree
Hide file tree
Showing 24 changed files with 720 additions and 749 deletions.
182 changes: 90 additions & 92 deletions .github/workflows/main.workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,117 +6,115 @@ on:
push:
branches:
- main
- devel
- humble
- galactic
- foxy
tags:
- 'v*'
pull_request:
branches:
- main
- devel
- humble
- galactic
- foxy
env:
ROS_DISTRO: foxy

jobs:

style:
clang-format-lint:
name: ament_clang_format
runs-on: ubuntu-20.04

strategy:
fail-fast: false
steps:
- uses: actions/checkout@v2

- name: Clang-Format lint

uses: DoozyX/clang-format-lint[email protected]
- uses: actions/checkout@v2.3.4
- uses: ros-tooling/[email protected]
with:
required-ros-distributions: ${{ env.ROS_DISTRO }}
- uses: ros-tooling/action-ros2-lint@0.1.3
with:
source: '.'
extensions: 'h,hpp,c,cpp'
clangFormatVersion: 10

ROS1-build:
runs-on: ${{ matrix.os }}
distribution: ${{ env.ROS_DISTRO }}
linter: clang_format
arguments: --config ./.clang-format
package-name: |
depthai_bridge
depthai_examples
depthai_ros_msgs
depthai_ros
linting:
name: ament_${{ matrix.linter }}
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
os: [ubuntu-18.04, ubuntu-20.04]

linter: [xmllint, pep257, lint_cmake]
steps:
- uses: actions/checkout@v2

- name: Melodic build
if: matrix.os == 'ubuntu-18.04'
uses: ros-tooling/[email protected]
with:
required-ros-distributions: melodic

- name: Noetic build
if: matrix.os == 'ubuntu-20.04'
uses: ros-tooling/[email protected]
with:
required-ros-distributions: noetic

- name: Installing libusb
run: sudo apt-get install libusb-1.0-0-dev

- name: Installing DepthAi Core
run: sudo wget -qO- https://raw.githubusercontent.com/luxonis/depthai-ros/$GITHUB_SHA/install_dependencies.sh | sudo bash

- name: Build depthai-bridge melodic
if: matrix.os == 'ubuntu-18.04'
uses: ros-tooling/[email protected]
with:
# vcs-repo-file-url: "${{ github.workspace }}/.github/workflows/examples.repos"
# package-name: depthai_examples
target-ros1-distro: melodic
skip-tests: true

- name: Build depthai-bridge noetic
if: matrix.os == 'ubuntu-20.04'
uses: ros-tooling/[email protected]
with:
# vcs-repo-file-url: "${{ github.workspace }}/.github/workflows/examples.repos"
# package-name: depthai_examples
target-ros1-distro: noetic
skip-tests: true

- uses: actions/[email protected]
- uses: ros-tooling/[email protected]
with:
required-ros-distributions: ${{ env.ROS_DISTRO }}
- uses: ros-tooling/[email protected]
with:
distribution: ${{ env.ROS_DISTRO }}
linter: ${{ matrix.linter }}
package-name: |
depthai_bridge
depthai_examples
depthai_ros_msgs
depthai_ros
ROS2-build:
docker-build:
name: Build and Upload to Docker Hub
runs-on: ubuntu-20.04
strategy:
matrix:
ros_distribution: [foxy]

fail-fast: false
env:
PUSH: ${{ (github.event_name != 'pull_request') && (github.repository == 'luxonis/depthai-ros') && startsWith(github.ref, 'refs/tags/v') }}
steps:
- uses: actions/checkout@v2

- name: ${{ matrix.ros_distribution }} build
uses: ros-tooling/[email protected]
with:
required-ros-distributions: ${{ matrix.ros_distribution }}
- name: Checkout
uses: actions/checkout@v3

- name: Installing libusb
run: sudo apt-get install libusb-1.0-0-dev
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Installing DepthAi Core
run: sudo wget -qO- https://raw.githubusercontent.com/luxonis/depthai-ros/$GITHUB_SHA/install_dependencies.sh | sudo bash

- name: Build depthai-bridge ${{ matrix.ros_distribution }}
uses: ros-tooling/[email protected]
with:
# vcs-repo-file-url: "${{ github.workspace }}/.github/workflows/examples.repos"
# package-name: depthai_examples
target-ros2-distro: ${{ matrix.ros_distribution }}
skip-tests: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v1
if: env.PUSH == 'true'
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASS }}
- name: Get Version
if: env.PUSH == 'true'
id: vars
run: echo ::set-output name=short_ref::${GITHUB_REF#refs/*/}

- name: Build
uses: docker/build-push-action@v3
if: env.PUSH == 'false'
with:
build-args: |
ROS_DISTRO=${{ env.ROS_DISTRO }}
USE_RVIZ=1
platforms: |
amd64
arm64
no-cache: true

# build_:
# runs-on: ubuntu-18.04
# steps:
# - uses: actions/checkout@v2
# - uses: ros-tooling/[email protected]
# with:
# required-ros-distributions: melodic
# - run: sudo wget -qO- https://raw.githubusercontent.com/luxonis/depthai-ros/noetic-devel/install_dependencies.sh | sudo bash
# - uses: ros-tooling/[email protected]
# with:
# # vcs-repo-file-url: "${{ github.workspace }}/.github/workflows/examples.repos"
# # package-name: depthai_examples
# target-ros1-distro: melodic
# skip-tests: true
- name: Build and Push
uses: docker/build-push-action@v3
if: env.PUSH == 'true'
with:
build-args: |
ROS_DISTRO=${{ env.ROS_DISTRO }}
USE_RVIZ=1
platforms: |
amd64
arm64
push: ${{ env.PUSH }}
no-cache: true
tags: |
luxonis/depthai-ros:${{ env.ROS_DISTRO }}-${{ steps.vars.outputs.short_ref }}
luxonis/depthai-ros:${{ env.ROS_DISTRO }}-latest
8 changes: 8 additions & 0 deletions .zshrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export ZSH="$HOME/.oh-my-zsh"

ZSH_THEME="robbyrussell"

plugins=(git)

source $ZSH/oh-my-zsh.sh

23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
ARG ROS_DISTRO=humble
FROM ros:${ROS_DISTRO}-ros-base
ARG USE_RVIZ
ARG BUILD_SEQUENTIAL=0
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get -y install --no-install-recommends software-properties-common git libusb-1.0-0-dev wget zsh python3-colcon-common-extensions

ENV DEBIAN_FRONTEND=dialog
RUN sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"

ENV WS=/ws
RUN mkdir -p $WS/src
COPY ./ .$WS/src/depthai_ros
RUN cd .$WS/ && rosdep install --from-paths src --ignore-src -y
RUN if [ "$BUILD_SEQUENTIAL" = "1" ] ; then cd .$WS/ && . /opt/ros/${ROS_DISTRO}/setup.sh && colcon build --executor sequential --cmake-args -DCMAKE_BUILD_TYPE=Release ; else cd .$WS/ && . /opt/ros/${ROS_DISTRO}/setup.sh && colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release; fi
RUN if [ "$USE_RVIZ" = "1" ] ; then echo "RVIZ ENABLED" && sudo apt install -y ros-${ROS_DISTRO}-rviz2 ros-${ROS_DISTRO}-rviz-imu-plugin ; else echo "RVIZ NOT ENABLED"; fi
RUN echo "if [ -f ${WS}/install/setup.zsh ]; then source ${WS}/install/setup.zsh; fi" >> $HOME/.zshrc
RUN echo 'eval "$(register-python-argcomplete3 ros2)"' >> $HOME/.zshrc
RUN echo 'eval "$(register-python-argcomplete3 colcon)"' >> $HOME/.zshrc
RUN echo "if [ -f ${WS}/install/setup.bash ]; then source ${WS}/install/setup.bash; fi" >> $HOME/.bashrc
ENTRYPOINT [ "/ws/src/depthai_ros/entrypoint.sh" ]
CMD ["zsh"]
73 changes: 34 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# depthai-ros
main branch supports ROS Melodic, ROS Noetic, ROS2 Foxy & Galactic. Might also work on kinetic too.
# Depthai ROS Repository
Hi and welcome to the main depthai-ros respository!

Supported ROS versions:
- Noetic
- Galactic
- Humble

For development check out respective git branches.

### Install from ros binaries

Expand All @@ -13,6 +18,32 @@ sudo udevadm control --reload-rules && sudo udevadm trigger
Install depthai-ros. (Available for Noetic, foxy, galactic and humble)
`sudo apt install ros-<distro>-depthai-ros`

## Docker
You can additionally build and run docker images on your local machine. To do that, add USB rules as in above step, clone the repository and inside it run (it matters on which branch you are on):
```
docker build --build-arg USE_RVIZ=1 -t depthai_ros .
```
If you find out that you run out of RAM during building, you can also set `BUILD_SEQUENTIAL=1` to build packages one at a time, it should take longer, but use less RAM.

`RUN_RVIZ` arg means rviz will be installed inside docker. If you want to run it you need to also execute following command (you'll have to do it again after restarting your PC):
```
xhost +local:docker
```

Then you can run your image in following way:
```
docker run -it -v /dev/:/dev/ --privileged -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix depthai_ros
```
will run an interactive docker session.
### Running on ROS1
```
docker run -it -v /dev/:/dev/ --privileged -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix depthai_ros roslaunch depthai_examples stereo_inertial_node.launch
```
Will only start `stereo_inertial_node` launch file (you can try different commands).
### Running on ROS2
```
docker run -it -v /dev/:/dev/ --privileged -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix depthai_ros roslaunch depthai_examples stereo_inertial_node.launch.py
```
## Install from source

### Install dependencies
Expand Down Expand Up @@ -42,42 +73,6 @@ The following setup procedure assumes you have cmake version >= 3.10.2 and OpenC
7. `catkin_make` (For ROS1) `colcon build` (for ROS2)
8. `source devel/setup.bash` (For ROS1) & `source install/setup.bash` (for ROS2)


<!--
7. `cd ~`
8. `git clone https://github.com/luxonis/depthai-core.git --branch develop`
9. `cd ~/depthai-core`
10. `mkdir build`
11. `cmake .. -D BUILD_SHARED_LIBS=ON`
12. `cmake --build . --parallel --config Release --target install`
13. `cd ~`
14. `mkdir -p dai_ws/src`
15. `cd dai_ws/src`
16. `git clone https://github.com/luxonis/depthai-ros.git --branch noetic-devel`
17. `git clone https://github.com/luxonis/depthai-ros-examples.git --branch noetic-devel`
18. `git clone https://github.com/ros-perception/vision_msgs.git --branch noetic-devel`
19. `cd ~/dai_ws`
20. `source /opt/ros/<ros-distro>/setup.zsh`
21. `catkin_make_isolated --cmake-args -D depthai_DIR=${depthai-core insall directory}/lib/cmake/depthai` -->

<!-- 1. `cd ~`
2. `git clone --recursive https://github.com/luxonis/depthai-core.git --branch develop`
3. `cd ~/depthai-core`
4. `mkdir build`
5. `cd build`
6. `cmake .. -DBUILD_SHARED_LIBS=ON`
7. `cmake --build . --config Release --target install`
8. `cd ~`
9. `mkdir -p dai_ws/src`
10. `cd dai_ws/src`
11. `git clone https://github.com/luxonis/depthai-ros.git --branch noetic-devel`
12. `git clone https://github.com/luxonis/depthai-ros-examples.git --branch noetic-devel`
13. `git clone https://github.com/ros-perception/vision_msgs.git --branch noetic-devel`
14. `cd ~/dai_ws`
15. `source /opt/ros/<ros-distro>/setup.bash` or `source /opt/ros/<ros-distro>/setup.zsh` if using zsh instead of bash
16. `catkin_make_isolated --cmake-args -Ddepthai_DIR=~/depthai-core/build/install/lib/cmake/depthai` (Melodic)
17. `catkin_make_isolated --cmake-args -D depthai_DIR=~/depthai-core/build/install/lib/cmake/depthai` (Noetic) -->

## Executing an example

### ROS1
Expand Down Expand Up @@ -132,4 +127,4 @@ ros2 launch depthai_examples mobile_publisher.launch.py camera_model:=OAK-D-LITE

### Users can write Custom converters and plug them in for bridge Publisher.
If there a standard Message or usecase for which we have not provided a ros msg or
converter feel free to create a issue or reach out to us on our discord community. We would be happy to add more.
converter feel free to create a issue or reach out to us on our discord community. We would be happy to add more.
2 changes: 1 addition & 1 deletion depthai-ros/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.10.2) # CMake version in Ubuntu 18.04 LTS
cmake_minimum_required(VERSION 3.10.2) # CMake version in Ubuntu 18.04 LTS

project(depthai-ros VERSION 2.5.3 LANGUAGES CXX C)

Expand Down
Loading

0 comments on commit ebc6d6f

Please sign in to comment.