Skip to content

Commit

Permalink
added ros images for r36.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
KalanaRatnayake committed Aug 6, 2024
1 parent 394e1eb commit d9c4877
Show file tree
Hide file tree
Showing 7 changed files with 484 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/r3630-humblebase.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Jetson ROS Humble Base r32.7.1

on:
workflow_dispatch:

workflow_run:
workflows: [Jetson Base r32.7.1]
types:
- completed

push:
branches:
- main
paths:
- ".github/workflows/r3271-humblebase.yml"
- "ros-images/r3271.humble_base.Dockerfile"
- "ros-images/ros_entrypoint.sh"

pull_request:
branches:
- main
paths:
- ".github/workflows/r3271-humblebase.yml"
- "ros-images/r3271.humble_base.Dockerfile"
- "ros-images/ros_entrypoint.sh"

env:
REGISTRY: ghcr.io
OWNER: kalanaratnayake
IMAGE_NAME: jetson-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: 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
# uses: docker/login-action@v3
# with:
# registry: ${{ env.REGISTRY }}
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push ROS Humble Base image
uses: docker/build-push-action@v5
with:
context: .
file: ./ros-images/r3271.humble_base.Dockerfile
push: true
platforms: linux/arm64
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }}:humble-ros-base-r32.7.1-buildcache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }}:humble-ros-base-r32.7.1-buildcache,mode=max
tags: |
${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }}:humble-base-r32.7.1
76 changes: 76 additions & 0 deletions .github/workflows/r3630-humblecore.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Jetson ROS Humble Core r32.7.1

on:
workflow_dispatch:

workflow_run:
workflows: [Jetson Base r32.7.1]
types:
- completed

push:
branches:
- main
paths:
- ".github/workflows/r3271-humblecore.yml"
- "ros-images/r3271.humble_core.Dockerfile"
- "ros-images/ros_entrypoint.sh"

pull_request:
branches:
- main
paths:
- ".github/workflows/r3271-humblecore.yml"
- "ros-images/r3271.humble_core.Dockerfile"
- "ros-images/ros_entrypoint.sh"

env:
REGISTRY: ghcr.io
OWNER: kalanaratnayake
IMAGE_NAME: jetson-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: 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
# uses: docker/login-action@v3
# with:
# registry: ${{ env.REGISTRY }}
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push ROS Humble Core image
uses: docker/build-push-action@v5
with:
context: .
file: ./ros-images/r3271.humble_core.Dockerfile
push: true
platforms: linux/arm64
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }}:humble-ros-core-r32.7.1-buildcache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }}:humble-ros-core-r32.7.1-buildcache,mode=max
tags: |
${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }}:humble-core-r32.7.1
121 changes: 121 additions & 0 deletions ros-images/r3620.humble_base.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#---------------------------------------------------------------------------------------------------------------------------
#----
#---- Start base image
#----
#---------------------------------------------------------------------------------------------------------------------------

FROM nvcr.io/nvidia/l4t-base:r36.2.0 AS base

#############################################################################################################################
#####
##### Install core packages, python3 and opencv
#####
#############################################################################################################################

RUN apt-get update -y
RUN apt-get install -y --no-install-recommends cmake \
build-essential \
wget \
unzip \
locales \
software-properties-common \
curl \
git \
gnupg2 \
ca-certificates \
pkg-config \
lsb-release\
python3 \
python3-dev \
python3-distutils \
python3-pip \
python3-venv \
libpython3-dev \
libboost-python-dev

RUN locale-gen en_US en_US.UTF-8 && update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8

ENV LANG=en_US.UTF-8
ENV PYTHONIOENCODING=utf-8

RUN python3 -m pip install --no-cache-dir numpy \
opencv-python

#############################################################################################################################
#####
##### Install ROS2 humble ros base
#####
#############################################################################################################################

ARG ROS_VERSION=humble

RUN add-apt-repository universe

RUN sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg

RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] \
http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null

RUN apt-get update -y

RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ros-${ROS_DISTRO}-ros-base
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ros-dev-tools

ENV ROS_DISTRO=${ROS_VERSION}
ENV ROS_ROOT=/opt/ros/${ROS_DISTRO}
ENV ROS_PYTHON_VERSION=3

RUN rosdep init && rosdep update

WORKDIR /

RUN apt-get clean

#############################################################################################################################
#####
##### Remove dev packages to reduce size
#####
#############################################################################################################################

RUN apt-get update -y

RUN apt-get autoremove -y

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

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

FROM scratch AS final

COPY --from=base / /

COPY ros-images/ros_entrypoint.sh /ros_entrypoint.sh

RUN chmod +x /ros_entrypoint.sh

#############################################################################################################################
#####
##### ROS Humble environment variables and configuration and set the default DDS middleware to cyclonedds
##### https://github.com/ros2/rclcpp/issues/1335
#####
#############################################################################################################################

ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp

ENV OPENBLAS_CORETYPE=ARMV8

ARG ROS_VERSION=humble

ENV ROS_DISTRO=${ROS_VERSION}

ENV ROS_ROOT=/opt/ros/${ROS_DISTRO}

WORKDIR /

ENTRYPOINT ["/ros_entrypoint.sh"]
44 changes: 44 additions & 0 deletions ros-images/r3620.humble_base.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
## jetson-ros:humble-base-r32.7.1

### Pull or Build

Pull the docker container
```bash
docker pull ghcr.io/kalanaratnayake/jetson-ros:humble-base-r32.7.1
```

Build the docker container
```bash
docker buildx build --load --platform linux/arm64 -f ros-images/r3271.humble_base.Dockerfile -t jetson-ros:humble-base-r32.7.1 .
```

or build with cache locally and push when image compilation can be slow on github actions and exceeds 6rs

```bash
docker buildx build --push \
--platform linux/arm64 \
--cache-from=type=registry,ref=ghcr.io/kalanaratnayake/jetson-ros:humble-ros-base-r32.7.1-buildcache \
--cache-to=type=registry,ref=ghcr.io/kalanaratnayake/jetson-ros:humble-ros-base-r32.7.1-buildcache,mode=max \
-f ros-images/r3271.humble_base.Dockerfile \
-t ghcr.io/kalanaratnayake/jetson-ros:humble-base-r32.7.1 .
```

### Start

Start the docker container
```bash
docker run --rm -it --runtime nvidia --network host --gpus all -e DISPLAY ghcr.io/kalanaratnayake/jetson-ros:humble-base-r32.7.1 bash
```

### Test

Run the following commands inside the docker container to confirm that the container is working properly.
```bash
ros2 run demo_nodes_cpp talker
```

Run the following commands on another instance of ros container or another Computer/Jetson device installed with ROS humble to check
connectivity over host network and discoverability (while the above command is running).
```bash
ros2 run demo_nodes_py listener
```
Loading

0 comments on commit d9c4877

Please sign in to comment.