RTKLIB: Code comments + new Github repository

If you’ve spent any time perusing the RTKLIB source code you will surely be aware that it is very much what I would call “old-school” code. Comments are sparse and variable names tend to be short and not always very descriptive. The upside is that the code is quite compact, significant pieces of it can be seen on a single page which can sometimes be quite nice. The downside is it can be difficult to follow if you have not been poring over it for a long time. To help myself understand the code I have added a fair bit of commenting to most of the code used to calculate the carrier-phase solution, which is really the heart of the RTKLIB kinematic solution.  This is mostly in the rtkpos.c file.

The changes are too extensive to spell out here so I have forked the RTKLIB code in Github and posted my commented code there. If you are interested, you can download it from the demo1 branch at https://github.com/rtklibexplorer/RTKLIB.  

All the previous code changes are also there as well as a couple I have not yet posted about.  The receiver data I have been using for these posts is also there in the rtklib/data/demo1 folder.  The solution file updates for VS2010 c++ are in the rtklib/app/rnx2rtkp/msc folder and the modified executable is in the rtklib/bin folder.

14 thoughts on “RTKLIB: Code comments + new Github repository”

  1. Now that the weather in NY is getting nice again I am back playing with rtklib (demo5) and trying to remember how it all works again 🙂

    Anyway I am still using my old M8Ns with the 2.01 firmware so I can still used the TREK-MEAS. My question is how can I send correction data back to the M8N from rtklib based on the solution generated. Not sure if this is even possible.

    Thanks
    Mike

    Like

      1. Was afraid you were going to say that 🙂 but not unexpected. Oh, today I was trying to compile rtkrcv using the Makefile and VS2017 (used nmake.exe) but it would not compile – well it did run but a lot of errors. If you have any ideas please do – never tried this before so something completely new

        Thanks
        Mike

        Like

        1. Just a quick update. I manually converted the makefile to a .sln file using the rnx2rtkp sln file as the base. So I was able to get it to open and build. Yea. But got a bunch of errors with the included .h files, such as all the net stuff, termios.h..

          Like

          1. Hi Mike. I believe the main reason that rtkrcv won’t build with the VS compiler in windows is because it doesn’t support pthreads as you have found. If you do get this working and don’t mind sharing your work, go ahead and submit a pull request to my Github account and I will pull your changes into the demo5 code.

            Like

          2. rtkexplorer
            Believe it or not got it to compile with termiWin and pthreads but having a problem with it getting hung up sending data to the console. Keeps wanting a login password? Took a small break from it. But it I ever get it to be fully functional I will definitely put in a pull request.

            Mike

            Like

          3. Hi. Well I got it compiled and it sort of runs. By that I mean it seems to be connecting and reading the GPS and creating and writing to the appropriate files. But not sure about ntrip connection. The problem I have is that I am not sure if its me just not knowing how it should work or something with the program. I tried to send an email to rtklibexplorer.gmail with the attachment but it keeps giving me undeliverable. Was wondering if you had some time to look at the config file to see if its me or something I have to change in the cmd file (I am using the m8n_1hz.cmd file from your version). I also use this to start it rtkrcv -t 5 -r 2 -s -o rtk.conf.

            Thanks
            Mike

            Like

          4. Ok got it working better at least I can see the console now. A whole bunch of quirks are showing up that I need to work through before I can post with instructs. But using putting and telnet ports on the router I can now open the console and all commands work except for status. Don’t see anything on the monitor port so those two problems need to be resolved.

            What saved me time was I found someone on DIYDRONES that actually had it completed for windows which was where I was working to but without those changes would be longer: https://diydrones.com/profiles/blogs/rtk-rover-and-base-configuration-web-interface
            Mike

            Like

          5. Hi all. Ok got a pull request in for what I have so far. Unfortunately -d option will not work because there is no native console like \dev for windows but you can use the -p option to set up a tcp connection to act as the console. Works great. -s option is connected to /dev since it asks to overwrite files if they already exist. So for now I disabled it for windows but you can start the server when you use the -p option. If anyone has any ideas for code changes have a look at the pull request.

            Respectfully
            Mike

            Like

  2. Hi there, could you provide some writeup on how RTKLIB works? Or just more informative code comments on what’s a subprogram do.
    I got an assignment to try fitting RTK processing on small ARM uC, that means stripping down the code into barebones with fixed options, without the command switch, etc. And right now I’m lost on how the program flows.
    I figured out that the UI programs (rtkrcv) just parsing the commands and starting the rtkserver, and that is all i know. Rhe structure of the header isn’t help either.

    Like

    1. Hi ArdBot. Have you looked at Appendix E in the RTKLIB user manual? It has quite a good explanation on how RTKLIB works.

      Also, I have added a fair bit of commenting to the core routines in rtkpos.c and lambda.c where most of the solution computations are done. You can find my comments in the demo1 branch of my Github repository.

      I do also have a few pages of notes on the program flow and variables used through this section of the code. At some point, I will try to translate this into something readable and post it.

      Like

      1. I’m already figure out how the mathematics works, but my understanding of the library code itself is a mess. With (IMO) unnecessarily complicated calls here and there and non-intuitive thread starting.

        Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.