diff --git a/README.md b/README.md index e533dde68..7cff4c3c0 100644 --- a/README.md +++ b/README.md @@ -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 or Peiliang LI . diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 000000000..c46cfe86a --- /dev/null +++ b/docker/Dockerfile @@ -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 diff --git a/docker/Makefile b/docker/Makefile new file mode 100644 index 000000000..95bc50e68 --- /dev/null +++ b/docker/Makefile @@ -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 diff --git a/docker/run.sh b/docker/run.sh new file mode 100755 index 000000000..c20ca90f6 --- /dev/null +++ b/docker/run.sh @@ -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 diff --git a/pose_graph/CMakeLists.txt b/pose_graph/CMakeLists.txt index d1c70e555..cc8a02897 100644 --- a/pose_graph/CMakeLists.txt +++ b/pose_graph/CMakeLists.txt @@ -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}") diff --git a/pose_graph/src/pose_graph.cpp b/pose_graph/src/pose_graph.cpp index 40b3f8058..ada506522 100644 --- a/pose_graph/src/pose_graph.cpp +++ b/pose_graph/src/pose_graph.cpp @@ -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); }