Code Monkey home page Code Monkey logo

graphgnsslib's Introduction

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 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) to read/decode the GNSS 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.

Authors: Weisong Wen, Li-ta Hsu from the Intelligent Positioning and Navigation Laboratory, The Hong Kong Polytechnic University.

Related Papers: (paper is not exactly same with code)

if you use GraphGNSSLib for your academic research, please cite our related papers

Software flowchart of GraphGNSSLib, more information please refer to mannual and paper.

0. Docker support

If you are not familiar with ROS, we highly recommend using our docker container to enjoy GraphGNSSLib. For the details, please go to the branch test_docker step 5.

1. Prerequisites

1.1 Ubuntu and ROS

Ubuntu 64-bit 16.04, ROS Kinetic. ROS Installation. We only test it on Ubuntu 16.04 with ROS Kinetic.

1.2. Ceres Solver

Follow the following instructions to install Ceres-solver instead of using the latest version of Ceres-solver.

Step 1: Download the Ceres-solver which is compatible with GraphGNSSLib.

Step 2: make and install

sudo apt-get install cmake
# google-glog + gflags
sudo apt-get install libgoogle-glog-dev
# BLAS & LAPACK
sudo apt-get install libatlas-base-dev
# Eigen3
sudo apt-get install libeigen3-dev
# make Ceres-solver
mkdir ceres-bin
cd ceres-bin
cmake ../ceres-solver
sudo make -j4
sudo make test
sudo make install

1.3. Extra Libraries

sudo apt-get install ros-kinetic-novatel-msgs

2. Build GraphGNSSLib

Clone the repository and catkin_make:

mkdir GraphGNSSLib/src
cd ~/GraphGNSSLib/src
mkdir result
git clone https://github.com/weisongwen/GraphGNSSLib.git
cd ../
# if you fail in the last catkin_make, please source and catkin_make again
catkin_make
source ~/GraphGNSSLib/devel/setup.bash
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

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
  • Window Size: Batch
  • measurements considered: double-differenced pseudorange and carrier-phase measurements, Doppler measurements
  • result is saved by default
    ~/GraphGNSSLib/trajectory_psr_dop_fusion.csv

please enable the following in rtklib.h

#define RTK_FGO 0
  • Solution 1 to run the GNSS positioning Demo
    source ~/GraphGNSSLib/devel/setup.bash
    # read GNSS raw data and publish as ROS topic
    # we provide several datasets, enjoy it!
    roslaunch global_fusion dataublox_TST20190428.launch
    # run pseudorange and doppler fusion
    roslaunch global_fusion psr_doppler_fusion.launch

Trajectories of three methods (GNSS positioning using WLS with the red curve, GNSS positioning using EKF with the green curve, and GNSS positioning using FGO with blue curve throughout the test. The x-axis and y-axis denote the east and north directions, respectively

TST data collected by the Smartphone: Red dots from WLS, purple curve from FGO

4. Run GNSS RTK-FGO using static dataset

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
    ~/GraphGNSSLib/FGO_trajectoryllh_pdrtk.csv

please enable the following in rtklib.h

#define RTK_FGO 1
  • Solution 1 to run the RTK-FGO Demo
    source ~/GraphGNSSLib/devel/setup.bash
    # read GNSS raw data and publish as ROS topic
    roslaunch global_fusion dataublox_TST20200603.launch
    # run GNSS RTK
    roslaunch global_fusion psr_doppler_car_rtk.launch

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.

5. Docker Support

To run GraphGNSSLib with docker, first make sure docker are installed on your machine. If you want to use the docker to run the global_fusion:

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 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:

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 for non-linear optimization and RTKLIB for GNSS data decoding, etc. Some functions are originated from VINS-mono. The rviz_satellite is used for visualization. If there is any thing inappropriate, please contact me through [email protected] (Weisong WEN). Thank you very much for the maintainance by Mr. Zhong Yihan.

7. License

The source code is released under GPLv3 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].

graphgnsslib's People

Contributors

darrenwong avatar pirkaklo avatar weisongwen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

graphgnsslib's Issues

Questions about the dataset you use

Dear author, thank you very much for your open source work.
I can't understand why you use static data to test GNSS-RTK. Why not use dynamic data testing?
For GNSS-PPP, the positioning accuracy is poor, and using static data to test the positioning accuracy seems to be a correct choice.
In addition, I would like to ask, if I want to test the RTK data set I collected, where the code needs to be modified, I only see the need to modify rtklib.h file, I hope you can answer my doubts, thank you!

Can you test your code just by modifying the coordinates of the reference station?

image

Comparison results of rtklib localization and factor map localization under good conditions

Professor Wen, I cloned your code today and collected static gnss data under open and good environment.

Finally, the localization results of fgo and rtklib were compared, and the conclusion was drawn that the positioning accuracy of fgo is much worse than that of rtklib.
rtklib's data can be well stabilized around a value (with an error of centimeters), while fgo's data often experiences sudden drift (sometimes with an error of 2-3 meters).
May I ask this conclusion is correct? Is it possible to achieve centimeter level accuracy in RTK localization using GraphgnssLib.

A code logic problem

Wen博士, 对于psr_doppler_car_rtk_dyna.h中的addDopplerFactors函数, 每个历元都掉用了 dopplerConstraint::create 工厂函数,在这个函数里一直在重复参数块的清除和循环重新绑定,直接添加最新的状态不可以吗,有什么特殊的逻辑?感谢回答

The question about GraphGNSSLib

Dear Welson
I have a question for you, when i run the RTK-FGO Demo, as fellow:

source ~/GraphGNSSLib/devel/setup.bash
roslaunch global_fusion dataublox_TST20200603.launch
roslaunch global_fusion psr_doppler_car_rtk.launch

I find that the positioning error is larger than the results mentioned in your paper.
The maximum positioning error in ENU direction is 3.2 meters。
So, i want to know why? It is related to the computer? or other reasons?
Thank you very much !

If possible, I would like to add your WeChat. My WeChat account is j15212774116.

[Bug] the results of NAN in the WeightedLeastSquare function

Hi, Professor @weisongwen there is a bug in the WeightedLeastSquare function in the gnss_tools.h file.
That is, you use 0 and 1 to represent whether the satellite is Beidou or GPS in the third and fourth columns of the eH_Matrix

However, if all satellites are Beidou or GPS in this case, then during this step of calculation
eDeltaPos = (eH_Matrix.transpose() * weight_matrix * eH_Matrix).inverse() * eH_Matrix.transpose() * weight_matrix * eDeltaPr;

eH_Matrix.transpose() * weight_matrix * eH_Matrix is a singular matrix and cannot be inverted, resulting in a nan result finally.

Unable to obtain the same result as solution 2

@weisongwen Thanks for your reply, Professor Wen. It seems that I have fallen into confusion. I will list them one by one:

1、As you wrote in the MD, the results of RTK position (solution 2) will be saved by default in ~/GraphGNSSLib/trajectory_psr_dop_fusion.csv. However, I cannot find the function to log the results.

But I did find the log function factor_graph.logResults(logPath); in psr_doppler_fusion.launch. As you said, the default name is ~/GraphGNSSLib/trajectory_psr_dop_fusion.csv, but I see that the name is <param name="logPath" type="string" value="$(findglobal_fusion)/FGO_trajectoryllh_psr_dop_fusion.csv" />. It seems different.

2、I was confused about the meaning of ref_lat, ref_lon, and ref_alt. Initially, I thought they were transformed from station_x, station_y, and station_z to represent llh coordinate, but after testing, I found that they represent different positions. Then I looked up the previous issue and found that it seems to be related to the enu coordinate system?, What I want to know is whether this value will affect the final positioning result?

#define ref_lon 114.179000972 /* Weisong: reference longitude */
#define ref_lat 22.3011535667 /* Weisong: reference latitude */
#define ref_alt 6.42821512092 /* Weisong: reference altitude */

#define station_x -2414266.9200 /* Weisong: pose x of base station */
#define station_y 5386768.9870  /* Weisong: pose y of base station */
#define station_z 2407460.0310  /* Weisong: pose z of station */

3、No matter how I change the opt in the code, I still cannot get the same result as in your paper. Is the data (solution 2 static) the same as in your paper? Or did I make some mistakes?
Here are the results of my run, with orange representing rtklib, blue representing fgo, and red representing groundtruth.
image

Something about the Stuck problem

Dear Dr Wen:
Thank you for sharing the repository, I'm trying to run the code, but It is stuck in the "---> psr_doppler_car_rtk_node Started", and nothing happended next.
The raw data read and publish launch "dataublox_TST20190428.launch" is running perfectly. After launching this, I typed Ctrl+C to stop, and then roslaunch the "psr_doppler_fusion.launch" but it is stuck, I don't konw whether I missed something important? Can you help me with this peoblem?

missing GNSS_Raw_Array.h file

Hi, thanks for the nice work. In gnss_tools.h, there is a missing include file at "#include <nlosExclusion/GNSS_Raw_Array.h>". I didn't find the file in that location and other locations. Would you please tell me how to access the file?

question about graphgnsslib

Hi, thanks for your work!
Could you tell pls what's the logic under checkCarrierPhaseConsistency?

Any ideas how to extend your solution to work with other satellite types
like glonass, etc. (all satellites which rtklib currently supports?)
for rtk (psr_doppler_car_rtk)?

ros-noetic-novatel-msgs which in ubuntu told me that can't finde the software bag

您好,当我运行sudo apt-get install ros-kinetic-novatel-msgs这行安装程序的时候,因为我是ubuntu20.04.6所以,我改成了ros-noetic-novatel-msgs,显示无法定位软件,我去了ROS-noetic,搜索novetal ,只是提供个gps-driver等包,我想了解一下在ubuntu20.04系统如何进行正确的编译

2024-06-13 19-58-20 的屏幕截图

catkin_make failing on first go

Hi,

When I am running catkin_make for the first time, it is failing with the following error:

WARNING: Catkin package name "nlosExclusion" does not follow the naming conventions. It should start with a lower case letter and only contain lower case letters, digits, and underscores.
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~  traversing 3 packages in topological order:
-- ~~  - nlosExclusion
-- ~~  - global_fusion
-- ~~  - rviz_satellite
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'nlosExclusion'
-- ==> add_subdirectory(GraphGNSSLib/nlosExclusion)
-- Could NOT find nodelet (missing: nodelet_DIR)
-- Could not find the required component 'nodelet'. The following CMake error indicates that you either need to install the package with the same name or change your environment so that it can be found.
CMake Error at /usr/share/catkin/cmake/catkinConfig.cmake:82 (find_package):
  Could not find a package configuration file provided by "nodelet" with any
  of the following names:

    nodeletConfig.cmake
    nodelet-config.cmake

  Add the installation prefix of "nodelet" to CMAKE_PREFIX_PATH or set
  "nodelet_DIR" to a directory containing one of the above files.  If
  "nodelet" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  GraphGNSSLib/nlosExclusion/CMakeLists.txt:4 (find_package)

In my CMakeLists.txt, I get this same error for all of the contents of this

find_package(catkin REQUIRED COMPONENTS
  message_filters
  nodelet
  roscpp
  pcl_conversions
  sensor_msgs
  tf2
  tf2_ros
  pcl_ros
  rospy
  std_msgs
  message_generation
)

The question about GraphGNSSLib

When using data collected by ourself, the command " roslaunch global_fusion dataublox_TST20190428.launch " cannot be run.
So why? what do we need to pay attention to ?

Thank you !

Issue with Dynamic Theta Update in Graduated Non-Convexity for Ceres Solver

I am working on implementing the Geman-McClure loss function with a dynamic update of the theta parameter in each iteration to achieve Graduated Non-Convexity (GNC) results in the Ceres Solver. Despite following the recommended approach, my current implementation does not seem to influence the Ceres solver's behavior as expected. I would greatly appreciate your guidance on this matter. Below is a rough outline of my code:

// Geman-McClure
else if (loss == "Geman"){
double a =2;
loss_function = new GemanMcClureLoss(a);
}

// Geman-McClure loss function class
class GemanMcClureLoss : public ceres::LossFunction
{
public:
explicit GemanMcClureLoss(double delta) : delta_(delta), delta_square(delta * delta) {}

virtual void Evaluate(double s, double rho[3]) const override
{
    const double aux = 1.0 / (delta_ + s);

    rho[0] = delta_ * s * aux;
    rho[1] = delta_square * aux * aux;
    rho[2] = -2. * rho[1] * aux;
}

private:
const double delta_;
const double delta_square;
};

// Main loop for iterating and updating theta
int max_iter = 5;

for (int iter = 0; iter < max_iter; ++iter) {
ceres::Problem problem;

// Add residual blocks with Geman-McClure loss
ceres::CostFunction* cost_function = new ceres::AutoDiffCostFunction<ResidualFunction, 1, 1>(new ResidualFunction(res));
problem.AddResidualBlock(cost_function, loss_function, &initial_x);

// Solver configuration and solving
ceres::Solver::Options options;
ceres::Solver::Summary summary;
ceres::Solve(options, &problem, &summary);

// Update theta value and reset the loss function's theta
theta /= 1.4;
loss_function->UpdateTheta(theta);
}

Datasets help wanted: Tight coupling of IMU and GNSS

hi,thanks for your contribution!
We want to use Tight coupling algorithm to fuse raw imu data and gnss raw data.But the datasets does not provide extrinsic Parameters between imu and antenna, timestamp.At the same time,FGO is not fuse imu. Can help?

Code get Stucked when running it

Hello Dr. Weisong,

I had the same issue as seen in #6

image001
image002

However, when I ran the code as suggested in #6 :
First run roslaunch global_fusion psr_doppler_fusion.launch first, and then
run roslaunch global_fusion dataublox_TST20190428.launch shortly after.

It seems to work fine but it still got stucked again as seen in the below image.
Screenshot from 2022-04-26 09-28-53

I first ran this on this terminal: roslaunch global_fusion psr_doppler_fusion.launch
Screenshot from 2022-04-26 10-05-33

then I ran this next: roslaunch global_fusion dataublox_TST20190428.launch
Screenshot from 2022-04-26 10-06-00

Kindly let me know if am missing any step(s).

Should I run these steps on the same terminal? and not on separate terminals

source ~/GraphGNSSLib/devel/setup.bash
roslaunch global_fusion dataublox_TST20190428.launch
roslaunch global_fusion psr_doppler_fusion.launch

Thank you for your help.

Have some problem with the ceres and cmakelist

I am sorry for disturb you in this panel:
I have a problem:
我安装了ceres-slover在/usr/local/ceres-solver2.0.0的文件夹,同时在cmakelist里面也通过set设置了相关的Ceres-DIR目录,C++版本设置为14
2024-07-29 12-49-26 的屏幕截图
2024-07-29 12-49-30 的屏幕截图
同时在相应的程序实现中,我也将include<ceres/ceres.h>类似的版本改成了下面的版本
2024-07-29 12-50-53 的屏幕截图
但是程序依然报错:
2024-07-29 12-51-55 的屏幕截图
2024-07-29 12-52-03 的屏幕截图
2024-07-29 12-52-03 的屏幕截图
我发现ceres调用出错的地方,指向的还是默认的ceres库,并没有使用ceres2.0.0的库中的函数,请问这个如何调整才能正确运行?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.