Skip to content

Commit

Permalink
building with new husarion-snap-common
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikN committed Jul 18, 2024
1 parent 4a86d90 commit 4bbd98d
Show file tree
Hide file tree
Showing 16 changed files with 436 additions and 195 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Build snap
on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
include:
- ros_distro: humble
- ros_distro: jazzy

# outputs:
# snap-file: ${{ steps.build-snap.outputs.snap }}

steps:

- name: Checkout
uses: actions/checkout@v4
with:
fetch-tags: true

- name: Render snapcraft.yaml
run: |
pip install jinja2
export ROS_DISTRO=${{ matrix.ros_distro }}
./render_template.py ./snapcraft_template.yaml.jinja2 snap/snapcraft.yaml
- name: Build snap
uses: snapcore/action-build@v1
with:
snapcraft-channel: latest/edge
id: build-snap
env:
SNAPCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS: 1

- name: Make sure the snap is installable
run: |
sudo snap install --dangerous ${{ steps.build-snap.outputs.snap }}
# # Save snap for subsequent job(s)
# - uses: actions/upload-artifact@v3
# with:
# name: husarion-camera-snap
# path: ${{ steps.build-snap.outputs.snap }}

# publish:
# if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
# needs: build
# runs-on: ubuntu-latest

# steps:

# # Retrieve the snap
# - uses: actions/download-artifact@v3
# with:
# name: husarion-camera-snap
# path: .

# # Publish the snap on the store
# # by default on 'edge' but on 'candidate' for tags
# - uses: snapcore/action-publish@v1
# env:
# SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }}
# with:
# snap: ${{needs.build.outputs.snap-file}}
# release: ${{ startsWith(github.ref, 'refs/tags/') && '${{ matrix.ros_distro }}/candidate' || '${{ matrix.ros_distro }}/edge'}}
54 changes: 54 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build and publish snap
on:
push:
tags:
- '*'
branches:
- main
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
include:
- ros_distro: humble
- ros_distro: jazzy

steps:

- name: Checkout
uses: actions/checkout@v4
with:
fetch-tags: true

- name: Render snapcraft.yaml
run: |
pip install jinja2
export ROS_DISTRO=${{ matrix.ros_distro }}
./render_template.py ./snapcraft_template.yaml.jinja2 snap/snapcraft.yaml
- name: Build snap
uses: snapcore/action-build@v1
with:
snapcraft-channel: latest/edge
id: build-snap
env:
SNAPCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS: 1

- name: Make sure the snap is installable
run: |
sudo snap install --dangerous ${{ steps.build-snap.outputs.snap }}
# Publish the snap on the store
# by default on 'edge' but on 'candidate' for tags
- name: Publish snap
uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }}
with:
snap: ${{ steps.build-snap.outputs.snap }}
release: ${{ matrix.ros_distro }}/${{ startsWith(github.ref, 'refs/tags/') && 'candidate' || 'edge' }}
61 changes: 0 additions & 61 deletions .github/workflows/snap.yaml

This file was deleted.

108 changes: 71 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,16 @@ Snap for OAK-x cameras customized for Husarion robots
| `husarion-depthai.start` | Start the `husarion-depthai.daemon` service |
| `husarion-depthai.stop` | Stop the `husarion-depthai.daemon` service |
| `husarion-depthai` | Start the application in the foreground (run in the current terminal). Remember to stop the daemon first |
| `husarion-depthai.image-view` | Preview the image from the camera |

## Setup FFMPEG
## Setup Camera Params

The default values for `ffmpeg-image-transport` are:

```bash
$ sudo snap get husarion-depthai driver.ffmpeg-image-transport
Key Value
driver.ffmpeg-image-transport.encoding libx264
driver.ffmpeg-image-transport.preset ultrafast
driver.ffmpeg-image-transport.tune zerolatency
```

to check available options run:

```bash
ffmpeg -encoders
```

find the list of available presets by running
The default config parameters for camera node are selected with:

```bash
ffmpeg -h encoder=$SELECTED_ENCODER`
$ sudo snap set husarion-depthai driver.camera-config=default
```

## Setup Astra Params

Default astra params are stored in the following file:

```bash
$ sudo snap get husarion-depthai driver.params-file
/var/snap/husarion-depthai/common/depthai_params.yaml
```

The default `depthai_params.yaml` file content:
The default config is get from: `/var/snap/husarion-depthai/common/camera-config-default.yaml` file:

```yaml
---
Expand Down Expand Up @@ -111,6 +85,12 @@ The default `depthai_params.yaml` file content:
i_low_bandwidth: true #false
i_low_bandwidth_quality: 20
i_max_q_size: 30
# i_width: 1280 #valid if i_output_isp: false
# i_height: 720 #valid if i_output_isp: false
# i_interleaved: false
# scaling 1920x1080 1:3 to 640x360
# https://docs-beta.luxonis.com/develop/ros/depthai-ros-driver#Available%20sensors%20and%20their%20resolutions%3A
# IMX378, 1080P is 1920x1080, i_isp_den=3 and i_isp_num=2 will give 1280x720 (/16=)
i_output_isp: true
i_preview_height: 300
i_preview_size: 300
Expand All @@ -136,24 +116,78 @@ The default `depthai_params.yaml` file content:

```

To set a new params create a copy of the `depthai_params.yaml` file:
You can create your own config file: `/var/snap/husarion-depthai/common/camera-config-<MY_NAME>.yaml`:

```bash
sudo cp \
/var/snap/husarion-depthai/camera-config-default.yaml \
/var/snap/husarion-depthai/camera-config-myconfig.yaml
```

Modify the content of the `camera-config-myconfig.yaml` file, eg:

```bash
sudo vim /var/snap/depthai-camera/common/camera-config-myconfig.yaml
```

And set the new path to the config file:

```bash
sudo snap set depthai-camera driver.camera-params=myconfig
```

## Setup FFMPEG Params

The default values for `ffmpeg-image-transport` are:

```bash
$ sudo snap set husarion-depthai driver.ffmpeg-config=default
```

The default config is get from: `/var/snap/husarion-depthai/common/ffmpeg-config-default.yaml` file:

```yaml
---
/**:
ros__parameters:
ffmpeg_image_transport:

# find the list of available encoders by running `ffmpeg -encoders`
encoding: libx264

# find the list of available presets by running `ffmpeg -h encoder=libx264`
preset: ultrafast
tune: zerolatency
```
You can create your own config file: `/var/snap/husarion-depthai/common/ffmpeg-config-<MY_NAME>.yaml`:

```bash
sudo cp \
/var/snap/husarion-depthai/common/depthai_params.yaml \
/var/snap/husarion-depthai/common/depthai_params2.yaml
/var/snap/husarion-depthai/ffmpeg-config-default.yaml \
/var/snap/husarion-depthai/ffmpeg-config-myconfig.yaml
```

Modify the content of the `astra-params2.yaml` file, eg:
Modify the content of the `ffmpeg-config-myconfig.yaml` file, eg:

```bash
sudo vim /var/snap/husarion-depthai/common/depthai_params2.yaml
sudo vim /var/snap/husarion-depthai/common/ffmpeg-config-myconfig.yaml
```

And set the new path to the config file:

```bash
sudo snap set husarion-depthai driver.params-file=/var/snap/husarion-depthai/common/depthai_params2.yaml
sudo snap set husarion-depthai driver.ffmpeg-params=myconfig
```

List of all available parameters for OAK-x cameras is [here](https://docs.luxonis.com/software/ros/depthai-ros/driver/)
To check available options run:

```bash
ffmpeg -encoders
```

find the list of available presets by running

```bash
ffmpeg -h encoder=$SELECTED_ENCODER`
```
34 changes: 32 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
build:
[private]
default:
@just --list --unsorted

build target="humble":
#!/bin/bash
export SNAPCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS=1

if [ {{target}} == "humble" ]; then
export ROS_DISTRO=humble
export CORE_VERSION=core22
elif [ {{target}} == "jazzy" ]; then
export ROS_DISTRO=jazzy
export CORE_VERSION=core24
else
echo "Unknown target: $target"
exit 1
fi

./render_template.py ./snapcraft_template.yaml.jinja2 snap/snapcraft.yaml

snapcraft

install:
Expand All @@ -21,7 +39,7 @@ clean:
export SNAPCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS=1
snapcraft clean

iterate:
iterate target="humble":
#!/bin/bash
start_time=$(date +%s)

Expand All @@ -31,8 +49,20 @@ iterate:
sudo rm -rf squashfs-root/
sudo rm -rf husarion-depthai*.snap
export SNAPCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS=1

if [ {{target}} == "humble" ]; then
export ROS_DISTRO=humble
elif [ {{target}} == "jazzy" ]; then
export ROS_DISTRO=jazzy
else
echo "Unknown target: {{target}}"
exit 1
fi

snapcraft clean
./render_template.py ./snapcraft_template.yaml.jinja2 snap/snapcraft.yaml
snapcraft

unsquashfs husarion-depthai*.snap
sudo snap try squashfs-root/
sudo snap connect husarion-depthai:raw-usb
Expand Down
Loading

0 comments on commit 4bbd98d

Please sign in to comment.