Skip to content

Commit

Permalink
Add part of VSLAM-demo code
Browse files Browse the repository at this point in the history
Signed-off-by: jike5 <[email protected]>

Signed-off-by: jike5 <[email protected]>

Signed-off-by: jike5 <[email protected]>

Signed-off-by: jike5 <[email protected]>

Signed-off-by: jike5 <[email protected]>
  • Loading branch information
jike5 committed Oct 28, 2022
1 parent 7ee3f86 commit ab43e15
Show file tree
Hide file tree
Showing 14 changed files with 539 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Implement VSLAM algorithm based on KubeEdge

This project aims to develop a Visiual SLAM application on an edge-side robot and implementing compute offloading to reduce the compute and memory resource pressure on edge-side.

## Prerequisites

1. Kubeedge 1.10.1+
2. Edgemesh 1.11.0+

## Steps to reproduce

1. Make sure your cluster is set up and [edgemesh](https://kubeedge.io/en/docs/advanced/edgemesh/) is enabled.

2. Clone the community/sig-robotics respository.

```bash
git clone https://github.com/kubeedge/community
```

3. Prepare your RGBD dataset or RGBD-sensors on the edge-side.

> We use [TUM Datasets](https://vision.in.tum.de/data/datasets/rgbd-dataset/download) and its format in our development and test process.
4. With all nodes running on the cluster, we create the deployment by using the yaml file below.

> For example, we have a cloud node and two edge nodes, named edge01 and edge02
`cloud-deployment.yaml`

```yaml
spec:
template:
spec:
nodeName: edge02
```
`edge-deployment.yaml`

```yaml
spec:
template:
spec:
nodeName: edge01
```

Download [TUM Datasets](https://vision.in.tum.de/data/datasets/rgbd-dataset/download) to your edge node, and mount it within k8s.

```yaml
spec:
template:
spec:
- name: data-mount
hostPath:
path: [your_absolute_path]/workspace/data
```

5. Make sure you have replace the `PATH_TO_SEQUENCE_FOLDER` ,`ASSOCIATIONS_FILE` in [edge-deployment.yaml](edge-deployment.yaml) and `TUN_NAME` in [cloud-deployment.yaml](cloud-deployment.yaml)to your own parameters.

```yaml
env:
- name: PATH_TO_SEQUENCE_FOLDER
value: /workspace/data/YOUR_DATA_FOLDER
- name: ASSOCIATIONS_FILE
value: /workspace/Edgeslam/Examples/RGB-D/YOUR_CONFIG.yaml
```

```yaml
env:
- name: TUM_NAME
value: TUM2
```

6. Create the applications deployment.

```bash
kubectl apply -f edge-deployment.yaml
kubectl apply -f cloud-deployment.yaml
```

7. If your edge-side node support X11 GUI, you will see a frame windows and a map window. The trajectory will be saved under `/workspace/edgeslam/Examples` folder.

## Validation

The works we has used for reference including [ORB_SLAM2](https://github.com/raulmur/ORB_SLAM2), and combined the performance on [TUM datasets](https://vision.in.tum.de/data/datasets/rgbd-dataset/download). We illustrate the overall framework of ours in the chart and figures.

| RMSE | ORBSLAM2 | Ours |
| :--------: | :------: | :--: |
| fr2_desk | 0.05 | 0.12 |
| fr3_office | 0.02 | 0.04 |

<img src="images/results.png" alt="results" style="zoom:50%;" />

**Conclusion**: Through the cloud-edge collaboration, the computational pressure on edge devices is reduced while ensuring better localization accuracy results.

## Development Tools

Due to the different application scenarios of robots, for cases that customer require, we provide some tools and environments to accelerate development process.

You can locally build a mutually isolated cloud and side container. To simulate edgemesh network communication, we need to first define a docker-network:

```bash
docker network create orbslam-cloud
```

Start the containers:

```bash
sudo ./scripts/run_container_cloud.sh
sudo ./scripts/run_container_edge.sh
```

## Reference

* [raulmur/ORB_SLAM2](https://github.com/raulmur/ORB_SLAM2)
* [droneslab/edgeslam](https://github.com/droneslab/edgeslam)
* [turlucode/ros-docker-gui](https://github.com/turlucode/ros-docker-gui)
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM jike5/orbslam2-dev:latest

LABEL maintainer="[email protected]"
USER root

# # Clone code
WORKDIR /workspace
RUN git clone https://github.com/jike5/Edgeslam

# Build
RUN cd /workspace/Edgeslam && chmod +x build.sh \
&& chmod +x build_ros.sh \
&& rm -rf ./build \
&& ./build.sh

RUN cd /workspace/Edgeslam/Examples/ROS/Edge_SLAM \
&& rm -rf build \
&& mkdir build

ENV ROS_PACKAGE_PATH "/opt/ros/melodic/share:/workspace/Edgeslam/Examples/ROS"

WORKDIR /workspace/Edgeslam/Examples/ROS/Edge_SLAM/build
RUN bash -c "source /opt/ros/melodic/setup.bash && export ROS_PACKAGE_PATH=/opt/ros/melodic/share:/workspace/Edgeslam/Examples/ROS && cmake .. -DROS_BUILD_TYPE=Release && make -j"

RUN echo "source /workspace/Edgeslam/Examples/ROS/Edge_SLAM/build/devel/setup.bash" >> ~/.bashrc

WORKDIR /workspace/Edgeslam/Examples
RUN chmod +x cloud_run.sh edge_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
FROM jike5/ros-melodic:cpu

RUN apt-get update

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get install -y gnupg2 curl lsb-core vim wget python-pip libpng16-16 libjpeg-turbo8 libtiff5

RUN apt-get install -y \
# Base tools
cmake \
build-essential \
git \
unzip \
pkg-config \
python-dev \
# OpenCV dependencies
python-numpy \
# Pangolin dependencies
libgl1-mesa-dev \
libglew-dev \
libpython2.7-dev \
# orbslam2 must use Eigen3.3.2, we will install another later
# libeigen3-dev \
apt-transport-https \
ca-certificates\
software-properties-common

RUN apt-get update && apt-get install -y \
# websocketpp dependencies
libarmadillo-dev\
libasio-dev\
# network tools
iputils-ping net-tools iproute2 telnet

# # build Eigen3
RUN wget https://github.com/eigenteam/eigen-git-mirror/archive/refs/tags/3.3.2.zip \
&& unzip 3.3.2 \
&& cd eigen-git-mirror-3.3.2 \
&& mkdir build \
&& cd build \
&& cmake .. \
&& make install \
&& cp -r /usr/local/include/eigen3/Eigen /usr/local/include

# # Build Pangolin
RUN git clone https://github.com/stevenlovegrove/Pangolin.git \
&& cd Pangolin \
&& git checkout 7987c9b \
&& mkdir build \
&& cd build \
&& cmake .. \
&& make \
&& make install

COPY docker/orbslam2-dev/ros_entrypoint.sh /ros_entrypoint.sh
RUN chmod +x /ros_entrypoint.sh
ENV ROS_DISTRO melodic
ENV LANG en_US.UTF-8

ENTRYPOINT ["/ros_entrypoint.sh"]

USER $USERNAME
# terminal colors with xterm
ENV TERM xterm
CMD ["bash"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2019 The KubeEdge Authors.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -e

# setup ros environment
source "/opt/ros/$ROS_DISTRO/setup.bash"
exec "$@"
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Refer: https://github.com/turlucode/ros-docker-gui

FROM ubuntu:18.04

LABEL Description="ROS-Melodic-Desktop (Ubuntu 18.04)"

# Install packages without prompting the user to answer any questions
ENV DEBIAN_FRONTEND noninteractive

# Install packages
RUN apt-get update && apt-get install -y \
locales \
lsb-release \
mesa-utils \
git \
subversion \
nano \
terminator \
xterm \
wget \
curl \
htop \
libssl-dev \
build-essential \
dbus-x11 \
software-properties-common \
gdb valgrind && \
apt-get clean && rm -rf /var/lib/apt/lists/*

# Install cmake 3.22.1
RUN git clone https://gitlab.kitware.com/cmake/cmake.git && \
cd cmake && git checkout tags/v3.22.1 && ./bootstrap --parallel=8 && make -j8 && make install && \
cd .. && rm -rf cmake

# Install tmux 3.2
RUN apt-get update && apt-get install -y automake autoconf pkg-config libevent-dev libncurses5-dev bison && \
apt-get clean && rm -rf /var/lib/apt/lists/*
RUN git clone https://github.com/tmux/tmux.git && \
cd tmux && git checkout tags/3.2 && ls -la && sh autogen.sh && ./configure && make -j8 && make install

# Install new paramiko (solves ssh issues)
RUN apt-add-repository universe
RUN apt-get update && apt-get install -y python-pip python build-essential && apt-get clean && rm -rf /var/lib/apt/lists/*
RUN /usr/bin/yes | pip install --upgrade "pip < 21.0"
RUN /usr/bin/yes | pip install --upgrade virtualenv
RUN /usr/bin/yes | pip install --upgrade paramiko
RUN /usr/bin/yes | pip install --ignore-installed --upgrade numpy protobuf

# Locale
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
ENV ROS_DISTRO melodic

# Terminator Config
RUN mkdir -p /root/.config/terminator/
COPY docker/ros-melodic/terminator_config /root/.config/terminator/config
COPY docker/ros-melodic/terminator_background.png /root/.config/terminator/background.png

# Install ROS
RUN sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
RUN apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

RUN apt-get update && apt-get install -y --allow-downgrades --allow-remove-essential --allow-change-held-packages \
libpcap-dev \
libopenblas-dev \
gstreamer1.0-tools libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev \
ros-melodic-desktop-full python-rosinstall python-rosinstall-generator python-wstool build-essential python-rosdep \
ros-melodic-socketcan-bridge \
ros-melodic-geodesy && \
apt-get clean && rm -rf /var/lib/apt/lists/*

# Configure ROS
RUN rosdep init && rosdep update
RUN echo "source /opt/ros/melodic/setup.bash" >> /root/.bashrc
RUN echo "export ROSLAUNCH_SSH_UNKNOWN=1" >> /root/.bashrc

# Entry script - This will also run terminator
COPY docker/ros-melodic/entrypoint_setup.sh /
ENTRYPOINT ["/entrypoint_setup.sh"]

# ---
CMD ["terminator"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## ros-melodic image

This image provide a ROS iamge with GUI sipport. We referenced this [repository](https://github.com/turlucode/ros-docker-gui), but still made a lot of improvements to better match our application scenarios.

You can use the Dockerfile build the ros-melodic image:

```
docker build . -t jike5/ros-melodic:cpu -f docker/ros-melodic/Dockerfile
```

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -e

# setup ros environment
source "/opt/ros/$ROS_DISTRO/setup.bash"
exec "$@"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[global_config]
title_receive_bg_color = "#64d8ff"
enabled_plugins = TerminalShot, LaunchpadCodeURLHandler, APTURLHandler, Logger, LaunchpadBugURLHandler
title_transmit_bg_color = "#15b0dc"
[keybindings]
[profiles]
[[default]]
use_system_font = False
background_darkness = 0.69
background_type = transparent
background_image = /root/.config/terminator/background.png
scroll_background = False
font = Monospace 12
scrollback_infinite = True
[layouts]
[[default]]
[[[child1]]]
type = Terminal
parent = window0
[[[window0]]]
type = Window
parent = ""
[plugins]
Loading

0 comments on commit ab43e15

Please sign in to comment.