Skip to content

Commit

Permalink
Merge pull request weisongwen#18 from weisongwen/test_docker
Browse files Browse the repository at this point in the history
Add docker support by Zhong Yihan
  • Loading branch information
weisongwen authored Dec 27, 2022
2 parents 8c864d0 + ee3449d commit 36bea98
Show file tree
Hide file tree
Showing 8 changed files with 193 additions and 19 deletions.
8 changes: 0 additions & 8 deletions GraphGNSSLib.code-workspace

This file was deleted.

59 changes: 48 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
# GraphGNSSLib
### An Open-source Package for GNSS Positioning and Real-time Kinematic Using Factor Graph Optimization

This repository is the implementation of the open-sourced package, the GraphGNSSLib, which makes use of the factor graph optimization (FGO) to perform the postprocessing of GNSS positioning and real-time kinematic (RTK) positioning. In this package, measurements from the historical and current epochs are structured into a factor graph which is then solved by non-linear optimization. The package is based on C++ which is compatible with the robot operation system (ROS) platform. Meanwhile, this package combines the RTKLIB (**[version: 2.4.3 b33](http://www.rtklib.com/)**) to read/decode the GNSS [RINEX](https://en.wikipedia.org/wiki/RINEX) files. Users from Robotics field can easily have access to GNSS raw data for further study. We are still improving the code readibility with the hope that this package can benefit the research community.
This repository is the implementation of the open-sourced package, the GraphGNSSLib, which makes use of the factor graph optimization (FGO) to perform the GNSS positioning and real-time kinematic (RTK) positioning. In this package, measurements from the historical and current epochs are structured into a factor graph which is then solved by non-linear optimization. The package is based on C++ which is compatible with the robot operation system (ROS) platform. Meanwhile, this package combines the RTKLIB (**[version: 2.4.3 b33](http://www.rtklib.com/)**) to read/decode the GNSS [RINEX](https://en.wikipedia.org/wiki/RINEX) files. Users from Robotics field can easily have access to GNSS raw data for further study.

**Important Notes**:
- Be noted that the **GNSS Positioning** mentioned throughout the package means estimating the positioing of the GNSS receiver based on the combination of pseudorange and Doppler measurements uisng FGO.
- Be noted that the **GNSS-RTK Positioning** mentioned throughout the package means estimating the positioing (float solution) of the GNSS receiver based on the combination of double-differenced pseudorange, carrier-phase and the Doppler measurements using FGO. Finally, the ambiguity is resolved using LAMBDA algorithm via epoch-by-epoch manner.
- An very interesting article illustrating the advantage and potential of the FGO in GNSS positioning, see [**What is a factor graph?**](https://insidegnss.com/q-what-is-a-factor-graph/).
- Be noted that the **GNSS-RTK Positioning** mentioned throughout the package means estimating the positioing (float solution) of the GNSS receiver based on the combination of double-differenced pseudorange, carrier-phase and the Doppler measurements using FGO. Finally, the ambiguity is resolved using LAMBDA algorithm.

**Authors**: [Weisong Wen](https://weisongwen.wixsite.com/weisongwen), [Li-ta Hsu](https://www.polyu-ipn-lab.com/) from the [Intelligent Positioning and Navigation Laboratory](https://www.polyu-ipn-lab.com/), The Hong Kong Polytechnic University

**Related Papers:** (paper is not exactly same with code)
- Wen Weisong., Hsu, Li-Ta.* **Towards Robust GNSS Positioning and Real-Time Kinematic Using Factor Graph Optimization**, *ICRA 2021*, Xi'an, China. ([**Paper Link in arXiv**](https://arxiv.org/ftp/arxiv/papers/2106/2106.01594.pdf)) ([**Paper Link in IEEE**](https://ieeexplore.ieee.org/document/9562037)) ([**Video Link**](https://www.youtube.com/watch?v=rSrXFFv9PGs&t=312s)) (**Accepted**)
- Wen Weisong., Hsu, Li-Ta.* (2020) **GraphGNSSLib: An Open-source Package for GNSS Positioning and Real-time Kinematic Using Factor Graph Optimization**, GPS Solutions. (**Submitted**)

*if you use GraphGNSSLib for your academic research, please cite our related [papers](https://arxiv.org/ftp/arxiv/papers/2106/2106.01594.pdf)*
*if you use GraphGNSSLib for your academic research, please cite our related [papers](https://www.polyu-ipn-lab.com/)*

<p align="center">
<img width="712pix" src="img/software_flowchart.png">
</p>

<center> Software flowchart of GraphGNSSLib, more information please refer to our paper.</center>
<center> Software flowchart of GraphGNSSLib, more information please refer to mannual and paper.</center>

## 0. Docker support
If you are not familiar with ROS, we highly recommend using our docker container to enjoy GraphGNSSLib.
Expand Down Expand Up @@ -74,10 +73,15 @@ catkin_make
(**if you fail in this step, try to find another computer with clean system or reinstall Ubuntu and ROS**)

## 3. Run GNSS positioning via FGO using dataset [UrbanNav](https://www.polyu-ipn-lab.com/download)
The GNSS positioning via FGO is validated using dynamic dataset collected near TST of Hong Kong. Several parameters are as follows:
The GNSS positioning via FGO is validated using static dataset collected near TST of Hong Kong. Several parameters are as follows:
- GPS second span: **46701** to **47185**
- satellite system: **GPS/BeiDou**
- measurements considered: pseudorange and Doppler measurements
- Window Size: **Batch**
- measurements considered: double-differenced pseudorange and carrier-phase measurements, Doppler measurements
- result is saved by default
```c++
~/GraphGNSSLib/trajectory_psr_dop_fusion.csv
```

please enable the following in rtklib.h
```bash
Expand All @@ -102,7 +106,12 @@ please enable the following in rtklib.h
The GNSS RTK-FGO is validated using static dataset collected near TST of Hong Kong. Several parameters are as follows:
- GPS second span: **270149** to **270306**
- satellite system: **GPS/BeiDou**
- Window Size: **Batch**
- measurements considered: double-differenced pseudorange and carrier-phase measurements, Doppler measurements
- result is saved by default
```c++
~/GraphGNSSLib/FGO_trajectoryllh_pdrtk.csv
```

please enable the following in rtklib.h
```bash
Expand All @@ -122,8 +131,36 @@ please enable the following in rtklib.h
<center> Trajectories of three methods (RTK-EKF with the red dots and RTK-FGO with the blue dots throughout the test. The x-axis and y-axis denote the east and north directions, respectively.</center>


## 5. Acknowledgements
We use [Ceres-solver](http://ceres-solver.org/) for non-linear optimization and [RTKLIB](http://www.rtklib.com/) for GNSS data decoding, etc. Some functions are originated from [VINS-mono](https://github.com/HKUST-Aerial-Robotics/VINS-Mono). The [rviz_satellite](https://github.com/nobleo/rviz_satellite) is used for visualization. We appreciate the help and discussion from [Tim Pfeifer](https://www.tu-chemnitz.de/etit/proaut/en/team/timPfeifer.html) which inspired me to finish this work. If there is any thing inappropriate, please contact me through [email protected] ([Weisong WEN](https://weisongwen.wixsite.com/weisongwen)).
## 5. Docker Support

To run GraphGNSSLib with docker, first make sure [docker](https://docs.docker.com/install/linux/docker-ce/ubuntu/) are installed on your machine. If you want to use the docker to run the global_fusion:
```bash

cd ~/catkin_ws/src/GraphGNSSLib/docker
make build
sudo -E ./start.bash #Do not delete " -E "
source devel/setup.bash
# run pseudorange and doppler fusion
roslaunch global_fusion psr_doppler_fusion.launch
# you should open another ternimal to enter the docker.
# read GNSS raw data and publish as ROS topic
roslaunch global_fusion dataublox_TST20190428.launch
```

Also, there is a [video](https://www.youtube.com/watch?v=WMM2de_SxTw) showing the demo after you have built the docker_file in the directory GraphGNSSLib/docker

If you want to restart the container, please stop it first:
```bash
sudo ./stop.bash
#then restart it
sudo -E ./start.bash
```
The directory ~/shared_dir is created to connect the container and the host . In the container, it is located at ~/graph1/shared_dir, you can also download the code to shared_dir and compile the program in the container (Recommended for those who are interested in making changes to the source code)



## 6. Acknowledgements
We use [Ceres-solver](http://ceres-solver.org/) for non-linear optimization and [RTKLIB](http://www.rtklib.com/) for GNSS data decoding, etc. Some functions are originated from [VINS-mono](https://github.com/HKUST-Aerial-Robotics/VINS-Mono). The [rviz_satellite](https://github.com/nobleo/rviz_satellite) is used for visualization. If there is any thing inappropriate, please contact me through [email protected] ([Weisong WEN](https://weisongwen.wixsite.com/weisongwen)).

## 6. License
## 7. License
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 Weisong Wen <[email protected]>. For commercial inquiries, please contact Li-ta Hsu <[email protected]>.
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 \
libogre-1.9-dev\
libsuitesparse-dev \
python-catkin-tools \
ros-${ROS_DISTRO}-desktop-full \
ros-${ROS_DISTRO}-novatel-msgs \
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/GraphGNSSLib/

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

# Build GraphGNSSLib
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:GraphGNSSLib -f ./Dockerfile ..

clean:
@docker rmi -f ros:GraphGNSSLib
61 changes: 61 additions & 0 deletions docker/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/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=$!

GraphGNSSLib_DIR=$(abspath "..")

docker run \
-it \
--rm \
--net=host \
-v ${GraphGNSSLib_DIR}:/root/catkin_ws/src/GraphGNSSLib/ \
ros:GraphGNSSLib \
/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 global_fusion ${1}"

wait $ROSCORE_PID
# wait $RVIZ_PID

if [[ $? -gt 128 ]]
then
kill $ROSCORE_PID
# kill $RVIZ_PID
fi
19 changes: 19 additions & 0 deletions docker/start.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
docker container ls -a -f name=graph1 | grep graph1$ > /dev/null

if [ $? == 0 ]
then
docker container start graph1
docker exec -it graph1 /bin/bash

else
xhost +
SHARED_DOCKER_DIR=/root/graph1/shared_dir
SHARED_HOST_DIR=$HOME/shared_dir
if [ ! -d "$SHARED_HOST_DIR" ];then
mkdir $SHARED_HOST_DIR
fi
#docker run --gpus all -it -v /home/hrz/project/ros/melodic/LvisamTest:/root/LvisamTest -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY -e GDK_SCALE -e GDK_DPI_SCALE -e ROS_MASTER_URI=http://172.17.0.2:8899 -e ROS_HOSTNAME=172.17.0.2 --cpus 0.5 --cpuset-cpus=2 --name melodic melodic-gpu /bin/bash
docker run -it -v /tmp/.X11-unix:/tmp/.X11-unix -v $SHARED_HOST_DIR:$SHARED_DOCKER_DIR -e DISPLAY=unix$DISPLAY -e GDK_SCALE -e GDK_DPI_SCALE -e ROS_MASTER_URI=http://172.17.0.2:11311 -e ROS_HOSTNAME=172.17.0.2 --name graph1 ros:GraphGNSSLib /bin/bash
sudo chmod 777 $SHARED_HOST_DIR
fi
3 changes: 3 additions & 0 deletions docker/stop.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
docker container stop graph1
docker container rm graph1
Binary file added img/tst_0118.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 36bea98

Please sign in to comment.