SGL-UT / GPSTk

ATTENTION: This repository has been moved and is for archival purposes only. GPSTk toolkit has been renamed to GNSSTK and has been split into two new separate repositories. GNSSTK now only contains libraries while the other repository GNSSTK-APPS contains only applications. The rename and split into libraries and applications started with version v12.0.0 on September 2021. GPSTk --> GNSSTK at https://gitlab.com/sgl-ut/gnsstk --> GNSSTK-APPS at https://gitlab.com/sgl-ut/gnsstk-apps
Other
339 stars 182 forks source link

Missing data types for Python #68

Open nicsalv opened 4 years ago

nicsalv commented 4 years ago

Hi everyone, I am trying to use the Python bindings of the GPS Toolkit, in particular the PRSolution class. I followed the swig/examples/example4.py in order to read my RINEX files and to compute the position solutions, and everything was fine. Now, I would like to use the PRSolution.PreparePRSolution method so as to obtain the corrected pseudoranges without computing the position solution. However, I can not call this method because the argument types do not match.

In particular, the call is

raimSolver.PreparePRSolution(time, satVector, syss, rangeVector, ephStore, SVP)

and the error that raises is

TypeError: in method 'PRSolution_PreparePRSolution', argument 4 of type 'std::vector< gpstk::SatID::SatelliteSystem,std::allocator< gpstk::SatID::SatelliteSystem > > &' 

I know from the PYTHON.md file that the enumerations have been removed in the Python bindings, so I do not know how I could define the syss variable. After several trials, I tried

syss = [gpstk.SatID.systemGPS, gpstk.SatID.systemGlonass]

without success.

Then, I tried to use the PRSolution2 class; it has a similar method called PrepareAutonomousSolution that does not need the previous argument. I made the call

gpstk.PRSolution2_PrepareAutonomousSolution(time, satVector, rangeVector, ephStore, SVP)

and unfortunately another error raised

TypeError: Wrong number or type of arguments for overloaded function 'PRSolution2_PrepareAutonomousSolution'.
  Possible C/C++ prototypes are:
    gpstk::PRSolution2::PrepareAutonomousSolution(gpstk::CommonTime const &,std::vector< gpstk::SatID,std::allocator< gpstk::SatID > > &,std::vector< double,std::allocator< double > > const &,gpstk::XvtStore< gpstk::SatID > const &,Matrix< double > &,std::ostream *)
    gpstk::PRSolution2::PrepareAutonomousSolution(gpstk::CommonTime const &,std::vector< gpstk::SatID,std::allocator< gpstk::SatID > > &,std::vector< double,std::allocator< double > > const &,gpstk::XvtStore< gpstk::SatID > const &,Matrix< double > &)

I definitely think that the problem concerns the variable SVP, since the other ones have been previously used for the computation of the position solution. Always from the PYTHON.md file, I know that the Matrix class is not wrapped so I do not know how to pass this argument. I tried with a list, a numpy array and even with the gpstk.seqToVector without success. Furthermore, I do not know how the GPS Toolkit could return the filled SVP matrix since it is passed as argument. I saw that functions modifying parameters passed by reference are opportunely modified but this method still requires the matrix as an argument.

Looking at the source code of PRSolution, I came across the RAIMComputeSimple method, that is used in order to avoid using "data types not exposed in swig". Therefore, I wonder if there actually exist a way to make things work.

What am I doing wrong? Is there a way to call those functions in Python? These are the only pieces of code where I found something that corrects the measured pseudoranges. If there are other way to do this, please let me know.

Thank you for your time, and for this great library.

UT-dave commented 3 years ago

There were a number of SWIG issues, many of which have been resolved recently. We plan to push a major update to the GPSTk later this summer, which solves numerous of these problems.