Skip to content

Commit

Permalink
Ros2 update (#36)
Browse files Browse the repository at this point in the history
* Simplify

* fix

* docker build pass

* Fix Realtime

* Formatting

* Fix build

* Readme, last fixes

* Typos

* rename

* Without lib lely

* Dawid Suggestions

* pre-commit suggestions

* remove odom

* Build Release

* undo rm

* Update compose.yaml

* Update compose.rviz.yaml

* Add suggestions

* Build Type and Test

* revert panther_lights

* Use build up-to

* typo

* Update README.md

Co-authored-by: Dawid Kmak <73443304+KmakD@users.noreply.github.com>

* Update demo/compose.rviz.yaml

Co-authored-by: Dawid Kmak <73443304+KmakD@users.noreply.github.com>

---------

Co-authored-by: Dawid Kmak <73443304+KmakD@users.noreply.github.com>
  • Loading branch information
rafal-gorecki and KmakD authored Mar 18, 2024
1 parent 658057f commit 0156b69
Show file tree
Hide file tree
Showing 16 changed files with 276 additions and 176 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
.dockerignore
.gitignore
Dockerfile.*
README.md
README.md
38 changes: 21 additions & 17 deletions .github/workflows/ros-docker-image.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
name: Build/Publish ROS Docker Image
---
name: Build/Publish ROS Docker Image

on:
on:
workflow_dispatch:
inputs:
build_type:
description: "Is it a \"development\" or a \"stable\" release?"
description: Is it a "development" or a "stable" release?
required: true
default: 'development'
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)"
description: In case of "stable" release specify the ROS distro of the existing docker image (eg.
humble)
type: string
default: "ardent"
default: ardent
target_release:
description: "In case of \"stable\" release specify the version of the existing docker image (eg. 1.0.12)"
description: In case of "stable" release specify the version of the existing docker image (eg.
1.0.12)
type: string
default: "0.0.0"
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)"
description: In case of "stable" release specify the date of the existing docker image in format
YYYYMMDD (eg. 20220124)
type: string
default: "20131206"
default: '20131206'
repository_dispatch:
types: [rebuild, ros-package-update]
pull_request:
Expand All @@ -39,12 +43,12 @@ jobs:

include:
- dockerfile: Dockerfile.hardware
platforms: "linux/arm64"
ros_distro: "humble"
platforms: linux/arm64
ros_distro: humble
- dockerfile: Dockerfile.simulation
repo_name: "panther-gazebo"
platforms: "linux/amd64"
ros_distro: "humble"
repo_name: panther-gazebo
platforms: linux/amd64
ros_distro: humble

steps:

Expand All @@ -55,8 +59,8 @@ jobs:
uses: husarion-ci/ros-docker-img-action@v0.5
with:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
main_branch_name: ros2-devel
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
main_branch_name: ros2
dockerfile: ${{ matrix.dockerfile }}
repo_name: ${{ matrix.repo_name }}
build_type: ${{ inputs.build_type }}
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ pyenv
Vagrantfile

.vscode
__pycache__/
__pycache__/
37 changes: 37 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
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']

# 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/.*$
50 changes: 19 additions & 31 deletions Dockerfile.hardware
Original file line number Diff line number Diff line change
@@ -1,47 +1,35 @@
FROM ros:humble-ros-core
ARG ROS_DISTRO=humble
ARG BUILD_TEST=OFF

SHELL ["/bin/bash", "-c"]
FROM husarnet/ros:${ROS_DISTRO}-ros-core

ENV HUSARION_ROS_BUILD_TYPE=hardware

WORKDIR /ros2_ws

RUN apt-get update && \
apt-get install -y \
git \
python3-dev \
python3-pip \
python3-colcon-common-extensions \
# required for lely instalation
software-properties-common && \
pip3 install \
rosdep \
vcstool && \
# ----------------------------------
# Install Lely CANOpen - later to be removed
add-apt-repository ppa:lely/ppa && \
apt-get update && \
apt-get install -y \
liblely-coapp-dev \
liblely-co-tools \
python3-dcf-tools && \
# ----------------------------------
git clone https://github.com/husarion/panther_ros.git src/panther_ros -b ros2-control && \
ros-dev-tools && \
# Setup workspace
git clone -b ros2-devel https://github.com/husarion/panther_ros.git src/panther_ros && \
vcs import src < src/panther_ros/panther/panther_hardware.repos && \
rm -r src/panther_ros/panther_gazebo && \
cd src/panther_msgs && \
git checkout origin/ros2-control && \
cd /ros2_ws && \
# Install dependencies
rosdep init && \
rosdep update --rosdistro $ROS_DISTRO && \
rosdep install --from-paths src -y -i --skip-keys mecanum_drive_controller && \
rosdep install --from-paths src -y -i && \
# Build
source /opt/ros/$ROS_DISTRO/setup.bash && \
colcon build --symlink-install --cmake-args "-DCMAKE_BUILD_TYPE=$BUILD_TYPE" "-DCMAKE_EXPORT_COMPILE_COMMANDS=On" -Wall -Wextra -Wpedantic && \
colcon build --symlink-install --packages-up-to panther --cmake-args -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=$BUILD_TEST && \
# Get version
echo $(cat /ros2_ws/src/panther_ros/panther/package.xml | grep '<version>' | sed -r 's/.*<version>([0-9]+.[0-9]+.[0-9]+)<\/version>/\1/g') >> /version.txt && \
# Size optimalization
rm -rf build log && \
export SUDO_FORCE_REMOVE=yes && \
apt-get remove -y \
ros-dev-tools && \
apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

RUN echo $(cat /ros2_ws/src/panther_ros/panther/package.xml | grep '<version>' | sed -r 's/.*<version>([0-9]+.[0-9]+.[0-9]+)<\/version>/\1/g') >> /version.txt

COPY ./ros_entrypoint.sh /
ENTRYPOINT ["/ros_entrypoint.sh"]
# Setup envs from eeprom
RUN sed -i "/# <additional-user-commands>/i set -e -a && source /run/husarion/panther_config.env" /*_entrypoint.sh
41 changes: 18 additions & 23 deletions Dockerfile.simulation
Original file line number Diff line number Diff line change
@@ -1,38 +1,33 @@
FROM ros:humble-ros-core
ARG ROS_DISTRO=humble
ARG BUILD_TEST=OFF

SHELL ["/bin/bash", "-c"]
FROM husarnet/ros:${ROS_DISTRO}-ros-core

ENV HUSARION_ROS_BUILD_TYPE=simulation

WORKDIR /ros2_ws

RUN apt-get update && \
apt-get install -y \
git \
python3-dev \
python3-pip \
python3-colcon-common-extensions && \
pip3 install \
rosdep \
vcstool && \
git clone https://github.com/husarion/ros_components_description.git src/ros_components_description && \
git clone https://github.com/husarion/panther_ros.git -b ros2-devel && \
vcs import src < panther_ros/panther/panther_simulation.repos && \
mv panther_ros/panther_description/ src/panther_description && \
mv panther_ros/panther_controller/ src/panther_controller && \
mv panther_ros/panther_bringup/ src/panther_bringup && \
mv panther_ros/panther_gazebo/ src/panther_gazebo && \
rm -rf panther_ros && \
ros-dev-tools && \
# Setup workspace
git clone -b ros2-devel https://github.com/husarion/panther_ros.git src/panther_ros && \
vcs import src < src/panther_ros/panther/panther_hardware.repos && \
vcs import src < src/panther_ros/panther/panther_simulation.repos && \
# Install dependencies
rosdep init && \
rosdep update --rosdistro $ROS_DISTRO && \
rosdep install --from-paths src -y -i && \
# Build
source /opt/ros/$ROS_DISTRO/setup.bash && \
colcon build --symlink-install --cmake-args "-DCMAKE_BUILD_TYPE=$BUILD_TYPE" "-DCMAKE_EXPORT_COMPILE_COMMANDS=On" -Wall -Wextra -Wpedantic && \
colcon build --symlink-install --packages-up-to panther --cmake-args -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=$BUILD_TEST && \
# Get version
echo $(cat /ros2_ws/src/panther_ros/panther/package.xml | grep '<version>' | sed -r 's/.*<version>([0-9]+.[0-9]+.[0-9]+)<\/version>/\1/g') >> /version.txt && \
# Size optimalization
rm -rf build log && \
export SUDO_FORCE_REMOVE=yes && \
apt-get remove -y \
ros-dev-tools && \
apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

RUN echo $(cat /ros2_ws/src/panther_gazebo/package.xml | grep '<version>' | sed -r 's/.*<version>([0-9]+.[0-9]+.[0-9]+)<\/version>/\1/g') >> /version.txt

COPY ./ros_entrypoint.sh /
ENTRYPOINT ["/ros_entrypoint.sh"]
61 changes: 33 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,60 @@
# panther-docker

Docker images dedicated to Husarion Panther ROS system and simulation.

## Docker Images

Docker images are automatically deployed to Docker Hub. Image tag includes information about the ROS distribution, the version of the [panther_ros](https://github.com/husarion/panther_ros/tree/ros2-devel) repository, and the date of release. Additionally stable image versions are tagged with `stable` and recommended for production use.
Docker images are automatically deployed to Docker Hub. Image tag includes information about the ROS distribution, the version of the [panther_ros](https://github.com/husarion/panther_ros/tree/ros2-devel) repository, and the date of release. Additionally stable image versions are tagged with `stable` and recommended for production use.
Below, you can find a list of available Docker images. To access the latest tag, simply follow provided links:

- [husarion/panther](https://hub.docker.com/r/husarion/panther) - ROS packages for Panther robot,
- [husarion/panther](https://hub.docker.com/r/husarion/panther) - ROS packages for Panther robot,
- [husarion/panther-gazebo](https://hub.docker.com/r/husarion/panther-gazebo) - Simulation for Panther robot in Gazebo-classic.

## Updating Panther Software

> **Note**
> Latest Panther Docker images are compatible with Built-in Computer OS version 2.0.0 and newer. If your operating system is older, please ensure you update it before proceeding. **[COMMING SOON]** Follow [operating system reinstallation](ros2-os-instalation-link) for more info.
> [!Note] Latest Panther Docker images are compatible with Built-in Computer OS version 2.0.0 and newer. If your operating system is older, please ensure you update it before proceeding. **[COMING SOON]** Follow [operating system reinstallation](ros2-os-instalation-link) for more info.
Connect to Panther's Built-in Computer:

```bash
ssh husarion@10.15.20.2
```

Edit Docker compose file:
```bash
nano compose.yaml
```
## Quick Start

Update Docker image tag:
```yaml
panther_ros:
image: husarion/panther:<newest-stable-tag> # example tag: humble-2.0.0-20231208-stable
```
Depending on your needs, you can run Docker to quickly launch the physical robot or run a simulation. To do this, clone this repository to your robot or computer.

Restart Docker containers:
```bash
docker compose up -d --force-recreate
git clone -b ros2 https://github.com/husarion/panther-docker.git
cd panther-docker/demo
```

## Running Simulation
### 🤖 Robot

1. Activate Panther

```bash
docker compose -f compose.minimal-setup.yaml up
```

2. Launch Visualization on PC

```bash
xhost local:root
docker compose -f compose.rviz.yaml up
```

> [!NOTE]
> To use the latest version of the image, run the `docker compose pull` command and rerun above commands.
### 💻 Gazebo Simulation

To give Docker access to your screen run:
```bash
xhost local:docker
```

Depending on your hardware configuration your `compose.yaml` file may differ. For Intel and AMD users you will need the following configuration: [compose.simulation.yaml](./demo/simulation/compose.simulation.yaml).
To launch the simulation, from the directory containing Docker compose file run:
```bash
docker compose -f compose.simulation.yaml up
xhost local:docker
docker compose -f compose.simulation.yaml up
```

Nvidia users have to install NVIDIA Container Toolkit. Installation steps can be found [here](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html). With NVIDIA Container Toolkit installed following Docker compose file will be needed: [compose.simulation-gpu.yaml](./demo/simulation/compose.simulation-gpu.yaml).
To launch the simulation, from the directory containing Docker compose file run:
```bash
docker compose -f compose.simulation-gpu.yaml up
```
> [!NOTE]
> If you have an NVIDIA GPU, it is worth changing the compose configuration from cpu-config to gpu-config. For this purpose, it is necessary to install [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html). With NVIDIA Container Toolkit installed, modify following Docker compose file by replacing `*cpu-config` with `*gpu-config`: [compose.simulation.yaml](./demo/compose.simulation.yaml).
3 changes: 3 additions & 0 deletions demo/.env.cpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DISPLAY=${DISPLAY:?You need to define display env}
LIBGL_ALWAYS_SOFTWARE=1
QT_X11_NO_MITSHM=1
3 changes: 3 additions & 0 deletions demo/.env.gpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DISPLAY=${DISPLAY:?You need to define display env}
NVIDIA_VISIBLE_DEVICES=all
NVIDIA_DRIVER_CAPABILITIES=all
16 changes: 12 additions & 4 deletions demo/compose.minimal-setup.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
x-common-config:
&common-config
network_mode: host
restart: always
ipc: host
tty: true
restart: always
environment:
- RMW_IMPLEMENTATION=rmw_cyclonedds_cpp # Default FastDDS do not work
- ROS_DOMAIN_ID=${ROS_DOMAIN_ID:-0}

services:
panther_ros:
image: husarion/panther:humble-nightly
image: husarion/panther:humble
container_name: panther_ros
<<: *common-config
devices:
Expand All @@ -22,6 +22,14 @@ services:
- /sys/bus/iio/devices:/sys/bus/iio/devices
- /run/husarion/panther_config.env:/run/husarion/panther_config.env
- /run/husarion/panther_config.yaml:/run/husarion/panther_config.yaml
# Realtime hardware (https://control.ros.org/master/doc/ros2_control/controller_manager/doc/userdoc.html#determinism)
ulimits:
rtprio:
soft: 99
hard: 99
memlock:
soft: 102400
hard: 102400
command: >
ros2 launch panther_bringup bringup.launch.py
Expand All @@ -33,6 +41,6 @@ services:
- /dev/input/js0
command: >
bash -c
"ros2 launch
"ros2 launch
joy2twist gamepad_controller.launch.py
joy2twist_params_file:=$(ros2 pkg prefix joy2twist)/share/joy2twist/config/joy2twist_panther.yaml"
Loading

0 comments on commit 0156b69

Please sign in to comment.