Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/ros-docker-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
name: Build/Publish ROS Docker Image

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-22.04
strategy:
fail-fast: false
matrix:
ros_distro: [humble, jazzy]

steps:

- name: Checkout
uses: actions/checkout@v2

- name: Build Docker Image
uses: husarion-ci/ros-docker-img-action@v0.4
with:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
repo_name: livox-lidar
main_branch_name: ros2
build_type: ${{ inputs.build_type }}
ros_distro: ${{ matrix.ros_distro }}
platforms: linux/amd64, linux/arm64
# variables important only for stable release
target_distro: ${{ inputs.target_distro }}
target_release: ${{ inputs.target_release }}
target_date: ${{ inputs.target_date }}
56 changes: 56 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-merge-conflict
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-xml
- id: check-added-large-files
- id: check-ast
- id: check-json
- id: name-tests-test
files: ^.*\/test\/.*$
args: [--pytest-test-first]

- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
entry: codespell *

- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
rev: 0.2.3
hooks:
- id: yamlfmt
files: ^(?!.*compose).*$
args: [--mapping, '2', --sequence, '4', --offset, '2', --width, '100']


- repo: https://github.com/psf/black
rev: 23.12.0
hooks:
- id: black
args: [--line-length=99]

- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
args: ['--ignore=E501,W503'] # ignore too long line and line break before binary operator,
# black checks it

# Docs - RestructuredText hooks
- repo: https://github.com/PyCQA/doc8
rev: v1.1.1
hooks:
- id: doc8
args: [--max-line-length=100, --ignore=D001]
exclude: ^.*\/CHANGELOG\.rst/.*$

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v17.0.6
hooks:
- id: clang-format
48 changes: 48 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Define build stage for creating ROS packages
ARG ROS_DISTRO=jazzy
ARG PREFIX=

# =========================== package builder ===============================
FROM husarnet/ros:$ROS_DISTRO-ros-base AS pkg-builder

WORKDIR /ros2_ws

# Setup workspace
RUN git clone https://github.com/tu-darmstadt-ros-pkg/livox_ros_driver2 -b $ROS_DISTRO /ros2_ws/src/livox_ros_driver2 && \
git clone https://github.com/tu-darmstadt-ros-pkg/Livox-SDK2 -b $ROS_DISTRO /ros2_ws/src/livox_sdk2 && \
apt-get update -y && \
rosdep update --rosdistro $ROS_DISTRO && \
rosdep install --from-paths src --ignore-src -y


# Optional: Create healthcheck package
RUN cd src/ && \
source /opt/ros/$ROS_DISTRO/setup.bash && \
ros2 pkg create healthcheck_pkg --build-type ament_cmake --dependencies rclcpp sensor_msgs && \
sed -i '/find_package(sensor_msgs REQUIRED)/a \
add_executable(healthcheck_node src/healthcheck.cpp)\n \
ament_target_dependencies(healthcheck_node rclcpp sensor_msgs)\n \
install(TARGETS healthcheck_node DESTINATION lib/${PROJECT_NAME})' \
/ros2_ws/src/healthcheck_pkg/CMakeLists.txt
COPY ./husarion_utils/healthcheck.cpp /ros2_ws/src/healthcheck_pkg/src/

# Build
RUN source /opt/ros/$ROS_DISTRO/setup.bash && \
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release && \
echo $(cat /ros2_ws/src/livox_ros_driver2/package.xml | grep '<version>' | sed -r 's/.*<version>([0-9]+.[0-9]+.[0-9]+)<\/version>/\1/g') > /version.txt && \
rm -rf build log

RUN apt update -y && \
apt-get install -y ros-$ROS_DISTRO-nav2-common && \
apt-get clean && \
rm -rf src && \
rm -rf /var/lib/apt/lists/*

COPY ./husarion_utils /husarion_utils

HEALTHCHECK --interval=2s --timeout=1s --start-period=20s --retries=1 \
CMD ["/husarion_utils/healthcheck.sh"]


# Ensure LIDAR stops spinning on container shutdown
STOPSIGNAL SIGINT
54 changes: 52 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,52 @@
# livox-docker
Docker images for Livox LIDARs
<h1 align="center">
Docker Images for Livox LIDARs
</h1>

The repository includes a GitHub Actions workflow that automatically deploys built Docker images to the [husarion/livox-docker](https://hub.docker.com/r/husarion/livox) Docker Hub repositories. This process is based on the fork of [tu-darmstadt-ros-pkg/livox_ros_driver2](https://github.com/tu-darmstadt-ros-pkg/livox_ros_driver2) repository.

[![ROS Docker Image](https://github.com/husarion/livox-docker/actions/workflows/ros-docker-image.yaml/badge.svg)](https://github.com/husarion/livox-docker/actions/workflows//ros-docker-image.yaml)


## Prepare Environment

1. Plugin the Device

Connect the device to the power supply and plug the ethernet cable to your PC or Husarion UGV router.

2. Check connection

Read the serial number of a Livox MID360 and remember last 2 numbers. These numbers are the part of its ip `192.168.1.1xx`.

To check the connection use the `ping` command:
```bash
ping 192.168.1.1xx
```

## Demo


1. Clone the Repository

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

2. Set the Appropriate IP
In [configuration](./demo/MID360_config.json) `lidar_config` > `ip` in the 28th line set this ip.

Your SBC should have ip `192.168.1.50`. For Husarion UGV SBC you can add to the ethernet interface configuration additional IP.
In file `/etc/netplan/01-network-manager-all.yaml` add to `addresses` `- 192.168.1.50/24`.

3. Activate the Device

```bash
docker compose up livox
```

4. Launch Visualization

```bash
xhost local:root
docker compose up rviz
```
7 changes: 7 additions & 0 deletions demo/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# =======================================
# Namespace config
# =======================================
# To use multimle devices on multible robot you have to specify following field

# Uncomment to add robot namespace
# ROBOT_NAMESPACE=robot
42 changes: 42 additions & 0 deletions demo/MID360_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"lidar_summary_info": {
"lidar_type": 8
},
"MID360": {
"lidar_net_info": {
"cmd_data_port": 56100,
"push_msg_port": 56200,
"point_data_port": 56300,
"imu_data_port": 56400,
"log_data_port": 56500
},
"host_net_info": {
"cmd_data_ip": "192.168.1.50",
"cmd_data_port": 56101,
"push_msg_ip": "192.168.1.50",
"push_msg_port": 56201,
"point_data_ip": "192.168.1.50",
"point_data_port": 56301,
"imu_data_ip": "192.168.1.50",
"imu_data_port": 56401,
"log_data_ip": "192.168.1.50",
"log_data_port": 56501
}
},
"lidar_configs": [
{
"ip": "192.168.1.160",
"pcl_data_type": 1,
"pattern_mode": 0,
"frame_id": "<frame_id>",
"extrinsic_parameter": {
"roll": 0.0,
"pitch": 0.0,
"yaw": 0.0,
"x": 0,
"y": 0,
"z": 0
}
}
]
}
33 changes: 33 additions & 0 deletions demo/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
x-common-config:
&common-config
network_mode: host
ipc: host
env_file: .env

services:
livox:
# image: husarion/livox-lidar:jazzy
build:
context: ..
dockerfile: Dockerfile
<<: *common-config
volumes:
- ./MID360_config.json:/ros2_ws/install/livox_ros_driver2/share/livox_ros_driver2/config/MID360_config.json
environment:
- RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
command: >
ros2 launch /husarion_utils/livox.launch.py

rviz:
image: husarion/rviz2:humble
<<: *common-config
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix:rw
- ./default.rviz:/root/.rviz2/default.rviz
- ./rviz.launch.py:/ros2_ws/rviz.launch.py
environment:
- DISPLAY=${DISPLAY:?err}
- LIBGL_ALWAYS_SOFTWARE=1
- RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
command: >
ros2 launch rviz.launch.py
Loading