Skip to content

Commit

Permalink
Husarion UGV nav2 package (#10)
Browse files Browse the repository at this point in the history
* nav2 demo

* add vnc rviz

* link fix

* Update README.md

* Update README.md

* use cyclone DDS (#2)

* removed white space

Signed-off-by: Jakub Delicat <[email protected]>

* Added lidar

Signed-off-by: Jakub Delicat <[email protected]>

* Applied precommit

Signed-off-by: Jakub Delicat <[email protected]>

* fixed readme

Signed-off-by: Jakub Delicat <[email protected]>

* Simplify Configuration

* delete slam config

* setup default sim topic

* Update compose.simulation.yaml

* Only PC2 support & nicer readme

* Small adjustment

* Nav2-estop (#8)

* Nav2 support namespace

* Fix typo in readme

* Small modification

* Use foxglove and simplify instruction.

* Update Readme

* Add laser scan

* Clean up

* Adjustments

* Fix

* Set frame id for loadded map (#7)

Signed-off-by: Jakub Delicat <[email protected]>

* Increase publish rate

* Create new package

* Add justfile

* Fix hardware

* Fix after laserscan test

* Add map autosaver

* Fix layout

* Remove healthcheck

* Layout

* Adjust local/global costmap

* Create docker folder

* Add map folder

* Fix use_sim_time

* Clean up parameters file

* Fix laserscan obstacle height

---------

Signed-off-by: Jakub Delicat <[email protected]>
Co-authored-by: Jakub Delicat <[email protected]>

* Configure smoother

* Add map_autosaver parameters

* Increase size of local cost map

* Apply suggestions from code review

Co-authored-by: Jakub Delicat <[email protected]>

* Jakub suggestions

* Further batch of suggestions

* Merge nav2_params.yaml

* Apply suggestions from code review

Co-authored-by: Jakub Delicat <[email protected]>

* Clean up

* Fix

* Update husarion_ugv_navigation/launch/bringup_launch.py

Co-authored-by: Jakub Delicat <[email protected]>

* Add launch argument table

* Simplify instruction

---------

Signed-off-by: Jakub Delicat <[email protected]>
Co-authored-by: Dawid <[email protected]>
Co-authored-by: Dawid Kmak <[email protected]>
Co-authored-by: Jakub Delicat <[email protected]>
Co-authored-by: Jakub Delicat <[email protected]>
  • Loading branch information
5 people authored Dec 17, 2024
1 parent e7ca942 commit 320b1df
Show file tree
Hide file tree
Showing 28 changed files with 2,579 additions and 2 deletions.
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: Create and Push Navigation Docker

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] # iron is not supported on arm

steps:

- name: Checkout
uses: actions/checkout@v4

- name: Build Docker Image
uses: husarion-ci/[email protected]
with:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
main_branch_name: ros2
repo_name: husarion-ugv-navigation
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 }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.vscode
__pycache__
maps
91 changes: 91 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
args: ["--maxkb=3000"]
- id: check-ast
- id: check-json
exclude: ^.vscode/
- id: check-merge-conflict
- id: check-symlinks
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: destroyed-symlinks
- id: detect-private-key
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: name-tests-test
- id: mixed-line-ending
- id: trailing-whitespace

- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black"]

- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.3
hooks:
- id: clang-format

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
name: codespell
description: Checks for common misspellings in text files.
entry: codespell
exclude_types: [rst, svg]
language: python
types: [text]

- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
rev: 0.2.3
hooks:
- id: yamlfmt
files: ^.github|./\.yaml
args: [--mapping, '2', --sequence, '4', --offset, '2', --width, '100']

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

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

- repo: local
hooks:
- id: ament_copyright
name: ament_copyright
description: Check if copyright notice is available in all files.
stages: [commit]
entry: ament_copyright
language: system

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

- repo: https://github.com/tier4/pre-commit-hooks-ros
rev: v0.10.0
hooks:
- id: prettier-package-xml
- id: sort-package-xml
95 changes: 93 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,93 @@
# panther-navigation
A GitHub template for Panther: creating a map a using Slam Toolbox
# husarion-ugv-autonomy

A GitHub template for Husarion UGVs: creating a map using Slam Toolbox and navigation with localization using Nav2.

![autonomy-result](https://github-readme-figures.s3.eu-central-1.amazonaws.com/panther/husarion_ugv/husarion_ugv_autonomy.gif)

## 📋 Requirement

### Justfile

To simplify the execution of this project, we are utilizing [just](https://github.com/casey/just). Install it with:

```bash
curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | sudo bash -s -- --to /usr/bin
```

### Robot Configuration

The provided example is configured for the Panther robot and supports any LIDAR that publishes `PointCloud2` or `LaserScan` data type by setting the appropriate environment variable.

> [!IMPORTANT]
> Before running the navigation demo, ensure the following:
>
> - This demo should be run on **User Computer** with IP address: **`10.15.20.3/24`**.
> - a LIDAR publishes messages of type: **`PointCloud2`** or **`LaserScan`**.
> - A static transformation between a LIDAR and a robot frame is provided. The value of the **`frame_id`** field inside the published message must connect to the robot's `base_link`.
## 🚀 Quick Start

### 🔧 Step 1: Environment configuration

Download this repository:

```bash
git clone https://github.com/husarion/panther-navigation
```

Setup environment:

```bash
cd panther-navigation

# The following configuration is only needed for the physical robot
export OBSERVATION_TOPIC={point_cloud_topic} # absolute topic name to match your LIDAR pointcloud2 topic (e.g. /scan)
export OBSERVATION_TOPIC_TYPE={msg_type} # Specify: `laserscan`, `pointcloud`
```

> [!NOTE]
> Additional arguments are detailed in the [Launch Arguments](#launch-arguments) section.
### 🧭 Step 2: Run navigation

🤖 Run Navigation on the Physical Robot:

```bash
just start-hardware
```

🖥️ Run Navigation in Simulation:

```bash
just start-simulation
```

### 🕹️ Step 3: Control the robot from a Web Browser

1. Install and run husarion-webui

```bash
just start-visualization
```

2. Open the your browser on your laptop and navigate to:

- http://{ip_address}:8080/ui (devices in the same LAN)
- http://{hostname}:8080/ui (devices in the same Husarnet Network)

## Launch Arguments

| Argument | Description <br/> ***Type:*** `Default` |
| ------------------------ | ----------------------------------------------------------------------------------------------------- |
| `autostart` | Automatically startup the nav2 stack. <br/> ***bool:*** `True` |
| `log_level` | Logging level. <br/> ***string*** `info` (choices: `debug`, `info`, `warning`, `error`, `custom`) |
| `map` | Path to map yaml file to load. <br/> ***string:*** `/maps/map.yaml` |
| `namespace` | Add namespace to all launched nodes. <br/> ***string:*** `env(ROBOT_NAMESPACE)` |
| `observation_topic` | Topic name for LaserScan or PointCloud2 observation messages type. <br/> `''` |
| `observation_topic_type` | Observation topic type. <br/> ***string:*** `pointcloud` (choices: `laserscan`, `pointcloud`) |
| `params_file` | Path to the parameters file to use for all nav2 related nodes. <br/> ***string:*** [`nav2_params.yaml](./husarion_ugv_navigation/config/nav2_params.yaml) |
| `pc2ls_params_file` | Path to the parameters file to use for pointcloud_to_laserscan node. <br/> ***string:*** [`pc2ls_params.yaml](./husarion_ugv_navigation/config/pc2ls_params.yaml) |
| `slam` | Whether run a SLAM. <br/> ***bool:*** `False` |
| `use_composition` | Whether to use composed bringup. <br/> ***bool:*** `True` |
| `use_respawn` | Whether to respawn if a node crashes. Applied when composition is disabled. <br/> ***bool:*** `False` |
| `use_sim_time` | Use simulation (Gazebo) clock if true. <br/> ***bool:*** `False` |
33 changes: 33 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
ARG ROS_DISTRO=humble
ARG PREFIX=

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

ARG PREFIX

WORKDIR /ros2_ws

COPY ./husarion_ugv_navigation /ros2_ws/src/husarion_ugv_navigation

RUN MYDISTRO=${PREFIX:-ros}; MYDISTRO=${MYDISTRO//-/} && \
apt-get update --fix-missing && \
apt upgrade -y && \
apt-get install -y \
ros-dev-tools && \
# Install dependencies
rm -rf /etc/ros/rosdep/sources.list.d/20-default.list && \
rosdep init && \
rosdep update --rosdistro $ROS_DISTRO && \
rosdep install -i --from-path src --rosdistro $ROS_DISTRO -y && \
# Build
source /opt/ros/$ROS_DISTRO/setup.bash && \
colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release && \
# Save version
echo $(cat /ros2_ws/src/husarion_ugv_navigation/package.xml | grep '<version>' | sed -r 's/.*<version>([0-9]+.[0-9]+.[0-9]+)<\/version>/\1/g') >> /version.txt && \
# Size optimalization
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/*
25 changes: 25 additions & 0 deletions docker/compose.hardware.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
x-common-config:
&common-config
network_mode: host
ipc: host

services:
navigation:
# image: husarion/husarion-ugv-navigation:humble-0.1.0-20241113
build:
context: ..
dockerfile: docker/Dockerfile
container_name: navigation
<<: *common-config
volumes:
- ../husarion_ugv_navigation:/ros2_ws/src/husarion_ugv_navigation
- ../maps:/maps
environment:
- RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
command: >
ros2 launch husarion_ugv_navigation bringup_launch.py
namespace:=panther
observation_topic:=${OBSERVATION_TOPIC:-err}
observation_topic_type:=${OBSERVATION_TOPIC_TYPE:-err}
slam:=True
use_sim_time:=False
43 changes: 43 additions & 0 deletions docker/compose.simulation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
x-common-config:
&common-config
network_mode: host
ipc: host

services:
husarion_ugv_gazebo:
image: husarion/panther-gazebo:humble-2.1.1-20240828
container_name: husarion_ugv_gazebo
<<: *common-config
runtime: nvidia
environment:
- RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
- DISPLAY
- NVIDIA_VISIBLE_DEVICES=all
- NVIDIA_DRIVER_CAPABILITIES=compute,utility,display
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix:rw
- ./config:/config
command: >
ros2 launch panther_gazebo simulation.launch.py
components_config_path:=/config/components.yaml
namespace:=panther
navigation:
# image: husarion/husarion-ugv-navigation:humble-0.1.0-20241113
build:
context: ..
dockerfile: docker/Dockerfile
container_name: navigation
<<: *common-config
volumes:
- ../husarion_ugv_navigation:/ros2_ws/src/husarion_ugv_navigation
- ../maps:/maps
environment:
- RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
command: >
ros2 launch husarion_ugv_navigation bringup_launch.py
namespace:=panther
observation_topic:=/panther/velodyne_points
observation_topic_type:=pointcloud
slam:=True
use_sim_time:=True
7 changes: 7 additions & 0 deletions docker/config/components.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
components:
- type: LDR20
parent_link: cover_link
xyz: 0.185 0.0 0.0
rpy: 0.0 0.0 0.0
device_namespace: None
Loading

0 comments on commit 320b1df

Please sign in to comment.