Skip to content

Commit

Permalink
added docker file for jetson nano
Browse files Browse the repository at this point in the history
  • Loading branch information
KalanaRatnayake committed Jul 19, 2024
1 parent 1a1266a commit 526527d
Show file tree
Hide file tree
Showing 3 changed files with 188 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/boxmot_humble_j_nano.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: ROS Humble BOXMOT Jetson Nano

on:
workflow_dispatch:

push:
branches:
- main
paths-ignore:
- README.md

pull_request:
branches:
- main
paths-ignore:
- README.md

env:
REGISTRY: ghcr.io
OWNER: kalanaratnayake
IMAGE_NAME: boxmot-ros

# https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
# only cancel in-progress jobs or runs for the current workflow - matches against branch & tags
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:

build-and-push-image:
runs-on: ubuntu-latest

permissions:
contents: write
packages: write

steps:
- name: Remove unnecessary files
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Check out the repository
uses: actions/checkout@v4

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

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
run: |
docker login --username ${{ env.OWNER }} --password ${{ secrets.GH_PAT }} ghcr.io
- name: Build and Push
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile.jetson-nano
platforms: linux/arm64
push: true
tags: |
${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }}:latest-j-nano
${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }}:humble-j-nano
80 changes: 80 additions & 0 deletions docker/Dockerfile.jetson-nano
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#---------------------------------------------------------------------------------------------------------------------------
#----
#---- Start base image
#----
#---------------------------------------------------------------------------------------------------------------------------

FROM ghcr.io/kalanaratnayake/foxy-ros-pytorch:1-13-humble-core-r32.7.1 as base

## Parameters
ENV ROS_DISTRO=humble
ENV WORKSPACE_ROOT=/boxmot

#############################################################################################################################
#####
##### Clone and build Yolo packages
#####
#############################################################################################################################

WORKDIR ${WORKSPACE_ROOT}/src

RUN git clone https://github.com/KalanaRatnayake/boxmot_ros.git
RUN git clone https://github.com/KalanaRatnayake/yolo_ros.git
RUN git clone https://github.com/KalanaRatnayake/detection_msgs.git

RUN pip3 install --no-cache-dir -r ${WORKSPACE_ROOT}/src/boxmot_ros/requirements.txt
RUN pip3 install --no-cache-dir -r ${WORKSPACE_ROOT}/src/yolo_ros/requirements.txt

WORKDIR ${WORKSPACE_ROOT}

RUN . /opt/ros/${ROS_DISTRO}/install/setup.sh && colcon build \
--merge-install \
--cmake-args -DCMAKE_BUILD_TYPE=Release

WORKDIR /

#############################################################################################################################
#####
##### Remove workspace source and build files that are not relevent to running the system
#####
#############################################################################################################################

RUN rm -rf ${WORKSPACE_ROOT}/src
RUN rm -rf ${WORKSPACE_ROOT}/log
RUN rm -rf ${WORKSPACE_ROOT}/build

RUN rm -rf /var/lib/apt/lists/*
RUN rm -rf /tmp/*

RUN apt-get clean

#---------------------------------------------------------------------------------------------------------------------------
#----
#---- Start final release image
#----
#---------------------------------------------------------------------------------------------------------------------------


FROM ghcr.io/kalanaratnayake/foxy-ros-pytorch:1-13-humble-core-r32.7.1 as final

## Parameters

ENV WORKSPACE_ROOT=/boxmot

ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp

ENV LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libgomp.so.1

WORKDIR /

COPY --from=base / /

COPY docker/workspace_entrypoint.sh /workspace_entrypoint.sh

RUN chmod +x /workspace_entrypoint.sh

ENTRYPOINT [ "/workspace_entrypoint.sh" ]

WORKDIR ${WORKSPACE_ROOT}

CMD ros2 launch boxmot_ros docker.launch.py
42 changes: 42 additions & 0 deletions docker/compose.jnano.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
services:
yolo:
image: ghcr.io/kalanaratnayake/boxmot-ros:humble-j-nano
environment:
- TRACKING_MODEL=deepocsort
- REID_MODEL=osnet_x0_25_msmt17.pt
- INPUT_TOPIC=/yolo_ros/detection_result
- PUBLISH_ANNOTATED_IMAGE=True
- BOXMOT_ANNOTATED_TOPIC=/boxmot_ros/annotated_image
- BOXMOT_DETAILED_TOPIC=/boxmot_ros/tracking_result
- BOXMOT_THRESHOLD=0.25
- BOXMOT_DEVICE='0'
- YOLO_MODEL=yolov10x.pt
# - YOLO_MODEL=weights/yolov9t.pt ---> for custom weights
- INPUT_RGB_TOPIC=/camera/color/image_raw
- INPUT_DEPTH_TOPIC=/camera/depth/points
- SUBSCRIBE_DEPTH=True
- PUBLISH_ANNOTATED_IMAGE=True
- YOLO_ANNOTATED_TOPIC=/yolo_ros/annotated_image
- YOLO_DETAILED_TOPIC=/yolo_ros/detection_result
- YOLO_THRESHOLD=0.25
- YOLO_DEVICE='0'
restart: unless-stopped
privileged: true
network_mode: host
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
volumes:
- type: volume
source: boxmot
target: /boxmot
# - type: bind ---> for custom weights
# source: ./weights
# target: /boxmot/weights

volumes:
yolo:

0 comments on commit 526527d

Please sign in to comment.