Skip to content

Commit

Permalink
add docker
Browse files Browse the repository at this point in the history
  • Loading branch information
shaozu committed Mar 13, 2019
1 parent cd8a2bd commit 3ef026a
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 3 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,21 @@ For rolling shutter camera (carefully calibrated, reprojection error under 0.5 p

(global shutter camera + synchronized high-end IMU, e.g. VI-Sensor) > (global shutter camera + synchronized low-end IMU) > (global camera + unsync high frequency IMU) > (global camera + unsync low frequency IMU) > (rolling camera + unsync low frequency IMU).

## 6. Docker Support

## 6. Acknowledgements
To further facilitate the building process, we add docker in our code. Docker environment is like a sandbox, thus makes our code environment-independent. To run with docker, first make sure [ros](http://wiki.ros.org/ROS/Installation) and [docker](https://docs.docker.com/install/linux/docker-ce/ubuntu/) are installed on your machine. Then add your account to `docker` group by `sudo usermod -aG docker $YOUR_USER_NAME`. **Relaunch the terminal**, type:
```
cd ~/catkin_ws/src/VINS-Mono/docker
make build
./run.sh LAUNCH_FILE_NAME # ./run.sh euroc.launch
```
Note that the docker building process may take a while depends on your network and machine. After VINS-Mono successfully started, open another terminal and play your bag file, then you should be able to see the result.


## 7. Acknowledgements
We use [ceres solver](http://ceres-solver.org/) for non-linear optimization and [DBoW2](https://github.com/dorian3d/DBoW2) for loop detection, and a generic [camera model](https://github.com/hengli/camodocal).

## 7. Licence
## 8. Licence
The source code is released under [GPLv3](http://www.gnu.org/licenses/) license.

We are still working on improving the code reliability. For any technical issues, please contact Tong QIN <tong.qinATconnect.ust.hk> or Peiliang LI <pliapATconnect.ust.hk>.
Expand Down
46 changes: 46 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
FROM ros:kinetic-perception

ENV CERES_VERSION="1.12.0"
ENV CATKIN_WS=/root/catkin_ws

# set up thread number for building
RUN if [ "x$(nproc)" = "x1" ] ; then export USE_PROC=1 ; \
else export USE_PROC=$(($(nproc)/2)) ; fi && \
apt-get update && apt-get install -y \
cmake \
libatlas-base-dev \
libeigen3-dev \
libgoogle-glog-dev \
libsuitesparse-dev \
python-catkin-tools \
ros-${ROS_DISTRO}-cv-bridge \
ros-${ROS_DISTRO}-image-transport \
ros-${ROS_DISTRO}-message-filters \
ros-${ROS_DISTRO}-tf && \
rm -rf /var/lib/apt/lists/* && \
# Build and install Ceres
git clone https://ceres-solver.googlesource.com/ceres-solver && \
cd ceres-solver && \
git checkout tags/${CERES_VERSION} && \
mkdir build && cd build && \
cmake .. && \
make -j$(USE_PROC) install && \
rm -rf ../../ceres-solver && \
mkdir -p $CATKIN_WS/src/VINS-Mono/

# Copy VINS-Mono
COPY ./ $CATKIN_WS/src/VINS-Mono/
# use the following line if you only have this dockerfile
# RUN git clone https://github.com/HKUST-Aerial-Robotics/VINS-Mono.git

# Build VINS-Mono
WORKDIR $CATKIN_WS
ENV TERM xterm
ENV PYTHONIOENCODING UTF-8
RUN catkin config \
--extend /opt/ros/$ROS_DISTRO \
--cmake-args \
-DCMAKE_BUILD_TYPE=Release && \
catkin build && \
sed -i '/exec "$@"/i \
source "/root/catkin_ws/devel/setup.bash"' /ros_entrypoint.sh
16 changes: 16 additions & 0 deletions docker/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
all: help

help:
@echo ""
@echo "-- Help Menu"
@echo ""
@echo " 1. make build - build all images"
# @echo " 1. make pull - pull all images"
@echo " 1. make clean - remove all images"
@echo ""

build:
@docker build --tag ros:vins-mono -f ./Dockerfile ..

clean:
@docker rmi -f ros:vins-mono
63 changes: 63 additions & 0 deletions docker/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash
trap : SIGTERM SIGINT

function abspath() {
# generate absolute path from relative path
# $1 : relative filename
# return : absolute path
if [ -d "$1" ]; then
# dir
(cd "$1"; pwd)
elif [ -f "$1" ]; then
# file
if [[ $1 = /* ]]; then
echo "$1"
elif [[ $1 == */* ]]; then
echo "$(cd "${1%/*}"; pwd)/${1##*/}"
else
echo "$(pwd)/$1"
fi
fi
}

if [ "$#" -ne 1 ]; then
echo "Usage: $0 LAUNCH_FILE" >&2
exit 1
fi

roscore &
ROSCORE_PID=$!
sleep 1

rviz -d ../config/vins_rviz_config.rviz &
RVIZ_PID=$!

VINS_MONO_DIR=$(abspath "..")

docker run \
-it \
--rm \
--net=host \
-v ${VINS_MONO_DIR}:/root/catkin_ws/src/VINS-Mono/ \
ros:vins-mono \
/bin/bash -c \
"cd /root/catkin_ws/; \
catkin config \
--env-cache \
--extend /opt/ros/$ROS_DISTRO \
--cmake-args \
-DCMAKE_BUILD_TYPE=Release; \
catkin build; \
source devel/setup.bash; \
roslaunch vins_estimator ${1}"

wait $ROSCORE_PID
wait $RVIZ_PID
wait $ROSBAG_PID

if [[ $? -gt 128 ]]
then
kill $ROSCORE_PID
kill $RVIZ_PID
kill $ROSBAG_PID
fi
2 changes: 1 addition & 1 deletion pose_graph/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ add_executable(pose_graph
)

target_link_libraries(pose_graph ${catkin_LIBRARIES} ${OpenCV_LIBS} ${CERES_LIBRARIES})
message("catkin_lib ${catkin_LIBRARIES}")
# message("catkin_lib ${catkin_LIBRARIES}")
1 change: 1 addition & 0 deletions pose_graph/src/pose_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,7 @@ void PoseGraph::publish()
posegraph_visualization->publish_by(pub_pose_graph, path[sequence_cnt].header);
}
}
base_path.header.frame_id = "world";
pub_base_path.publish(base_path);
//posegraph_visualization->publish_by(pub_pose_graph, path[sequence_cnt].header);
}
Expand Down

0 comments on commit 3ef026a

Please sign in to comment.