Skip to content

Commit

Permalink
Add ros2 driver
Browse files Browse the repository at this point in the history
  • Loading branch information
macstepien committed Aug 30, 2023
1 parent a184a2c commit d879031
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 119 deletions.
82 changes: 51 additions & 31 deletions .github/workflows/build-docker-image.yaml
Original file line number Diff line number Diff line change
@@ -1,40 +1,60 @@
name: Build/Publish Docker Image
name: Build/Publish ROS Docker Image

on:
push:
branches:
- "main"
on:
workflow_dispatch:
inputs:
build_type:
description: "Is it a \"development\" or a \"stable\" release?"
required: true
default: 'development'
type: choice
options:
- development
- stable
target_distro:
description: "In case of \"stable\" release specify the ROS distro of the existing docker image (eg. humble)"
type: string
default: "ardent"
target_release:
description: "In case of \"stable\" release specify the version of the existing docker image (eg. 1.0.12)"
type: string
default: "0.0.0"
target_date:
description: "In case of \"stable\" release specify the date of the existing docker image in format YYYYMMDD (eg. 20220124)"
type: string
default: "20131206"
repository_dispatch:
types: [rebuild]
pull_request:
types:
- closed
- opened

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
platforms: "linux/amd64, linux/arm64"
ros_distro: "humble"

steps:
- name: Checkout
uses: actions/checkout@v1
with:
ref: ${{ github.event.inputs.branch }}

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

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
version: latest

- name: Login to Docker Registry
uses: docker/login-action@v1
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Checkout
uses: actions/checkout@v2

- name: Build and push base tag
uses: docker/build-push-action@v2
- name: Build Docker Image
uses: husarion-ci/ros-docker-img-action@v0.5
with:
context: .
file: ./Dockerfile
platforms: linux/arm64, linux/amd64
push: true
tags: husarion/ouster:melodic
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
main_branch_name: ros2
build_type: ${{ inputs.build_type }}
dockerfile: ${{ matrix.dockerfile }}
ros_distro: ${{ matrix.ros_distro }}
platforms: ${{ matrix.platforms }}
# variables important only for stable release
target_distro: ${{ inputs.target_distro }}
target_release: ${{ inputs.target_release }}
target_date: ${{ inputs.target_date }}
60 changes: 30 additions & 30 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
ARG ROS_DISTRO=melodic
ARG ROS_DISTRO=humble

FROM ros:${ROS_DISTRO}-ros-core
FROM husarnet/ros:${ROS_DISTRO}-ros-core

# select bash as default shell
SHELL ["/bin/bash", "-c"]

RUN apt-get update && apt-get install -y \
build-essential \
cmake \
curl \
debhelper \
dpkg-dev \
fakeroot \
python-bloom \
python-rosdep \
python-rospkg

WORKDIR /ros_ws

RUN git clone --recurse-submodules https://github.com/ouster-lidar/ouster-ros.git src/ouster-ros

# RUN apt-get update && \
RUN rosdep init && \
rosdep update --rosdistro=$ROS_DISTRO && \
rosdep install --from-paths src --ignore-src -y && \
source /opt/ros/$ROS_DISTRO/setup.bash && \
catkin_make -DCATKIN_ENABLE_TESTING=0 -DCMAKE_BUILD_TYPE=Release && \
apt clean && \
rm -rf /var/lib/apt/lists/*
WORKDIR /ros2_ws

COPY ./ros_entrypoint.sh /

ENTRYPOINT ["/ros_entrypoint.sh"]

CMD ["bash"]
# install everything needed
RUN apt-get update && apt-get install -y \
python3-pip \
python3-colcon-common-extensions \
python3-rosdep \
python3-vcstool \
git && \
apt-get upgrade -y && \
source "/opt/ros/$ROS_DISTRO/setup.bash" && \
git clone -b ros2 --recurse-submodules https://github.com/ouster-lidar/ouster-ros.git /ros2_ws/src/ouster-ros && \
rm -rf /etc/ros/rosdep/sources.list.d/20-default.list && \
rosdep init && \
rosdep update --rosdistro $ROS_DISTRO && \
rosdep install -i --from-path /ros2_ws/src --rosdistro $ROS_DISTRO -y && \
colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release && \
export SUDO_FORCE_REMOVE=yes && \
apt-get remove -y \
python3-colcon-common-extensions \
python3-rosdep \
python3-vcstool \
git && \
apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

RUN echo $(cat /ros2_ws/src/ouster-ros/ouster-ros/package.xml | grep '<version>' | sed -r 's/.*<version>([0-9]+.[0-9]+.[0-9]+)<\/version>/\1/g') > /version.txt
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Dockerized Ouster LiDAR package from [ouster-lidar/ouster-ros](https://github.co

```bash
docker run --rm -it \
husarion/ouster:melodic \
roslaunch ouster_ros sensor.launch \
husarion/ouster:humble \
ros2 launch ouster_ros sensor.composite.launch.xml \
timestamp_mode:=TIME_FROM_ROS_TIME \
metadata:=/ouster_metadata.json \
sensor_hostname:=10.15.20.5 \
Expand All @@ -23,20 +23,22 @@ For more information about the Ouster ROS package itself, please refer to [READM
### Ouster LiDAR container + rviz container

Connect Ouster LiDAR to the first computer and run:

```bash
git clone https://github.com/husarion/ouster-docker.git
cd ouster-docker/demo

source ./setup_virtual_desktop.sh

docker compose \
-f compose.ouster.yaml \
-f compose.rviz.yaml \
-f compose.vnc.yaml \
up
```

On the second computer connected to the same LAN with a connected display open `http://localhost:8080/vnc_auto.html` in the web browser
On the second computer connected to the same LAN and run:
```bash
git clone https://github.com/husarion/ouster-docker.git
cd ouster-docker/demo

docker compose \
-f compose.rviz.yaml \
up
```

17 changes: 9 additions & 8 deletions demo/compose.ouster.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
services:
x-net-config:
&net-config
network_mode: host
ipc: host
env_file: net.env

services:
ouster-lidar:
image: husarion/ouster:melodic
image: husarion/ouster:humble
container_name: ouster-ros
restart: on-failure
network_mode: host
environment:
- ROS_IP=10.15.20.3
- ROS_MASTER_URI=http://10.15.20.2:11311
<<: *net-config
command: >
roslaunch ouster_ros sensor.launch
ros2 launch ouster_ros sensor.composite.launch.xml
timestamp_mode:=TIME_FROM_ROS_TIME
metadata:=/ouster_metadata.json
viz:=false
Expand Down
27 changes: 15 additions & 12 deletions demo/compose.rviz.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
services:
x-net-config:
&net-config
network_mode: host
ipc: host
env_file: net.env

x-cpu-config:
&cpu-config
environment:
- DISPLAY=${DISPLAY:?err}
- LIBGL_ALWAYS_SOFTWARE=1

services:
rviz:
image: husarion/rviz:noetic
container_name: rviz
restart: on-failure
network_mode: host
ipc: host
image: husarion/rviz2:humble
<<: [ *net-config, *cpu-config ]
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix:rw
- ./config/default.rviz:/root/.rviz/default.rviz
environment:
- DISPLAY
- LIBGL_ALWAYS_SOFTWARE=1
- ROS_IP=10.15.20.3
- ROS_MASTER_URI=http://10.15.20.2:11311
- ./config/default.rviz:/root/.rviz2/default.rviz
14 changes: 0 additions & 14 deletions demo/compose.vnc.yaml

This file was deleted.

18 changes: 18 additions & 0 deletions demo/net.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# =======================================
# Network config options (uncomment one)
# =======================================

# 1. Fast DDS + LAN
# RMW_IMPLEMENTATION=rmw_fastrtps_cpp

# 2. Cyclone DDS + LAN
RMW_IMPLEMENTATION=rmw_cyclonedds_cpp

# 3. Fast DDS + VPN
# RMW_IMPLEMENTATION=rmw_fastrtps_cpp
# FASTRTPS_DEFAULT_PROFILES_FILE=/husarnet-fastdds.xml

# 4. Cyclone DDS + VPN
# RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
# FASTRTPS_DEFAULT_PROFILES_FILE=/husarnet-fastdds.xml
# CYCLONEDDS_URI=file:///husarnet-cyclonedds.xml
8 changes: 0 additions & 8 deletions demo/setup_virtual_desktop.sh

This file was deleted.

8 changes: 0 additions & 8 deletions ros_entrypoint.sh

This file was deleted.

0 comments on commit d879031

Please sign in to comment.