From 40c17028c5661412b1c487f7483f7a899eed2e62 Mon Sep 17 00:00:00 2001 From: jcasals <jcasals@iri.upc.edu> Date: Wed, 4 Mar 2020 12:13:48 +0100 Subject: [PATCH] CMake refactor --- CMakeLists.txt | 77 ++++++- include/gnss_utils/gnss_utils.h | 12 +- src/CMakeLists.txt | 71 ------ src/gnss_utils.cpp | 216 +++++++++---------- {src/test => test}/CMakeLists.txt | 0 {src/test => test}/gtest/CMakeLists.txt | 0 {src/test => test}/gtest/utils_gtest.h | 0 {src/test => test}/gtest_example.cpp | 0 {src/test => test}/gtest_transformations.cpp | 0 9 files changed, 187 insertions(+), 189 deletions(-) delete mode 100644 src/CMakeLists.txt rename {src/test => test}/CMakeLists.txt (100%) rename {src/test => test}/gtest/CMakeLists.txt (100%) rename {src/test => test}/gtest/utils_gtest.h (100%) rename {src/test => test}/gtest_example.cpp (100%) rename {src/test => test}/gtest_transformations.cpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 89e9567..ce3a3ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,15 +43,84 @@ IF(NOT BUILD_TESTS) OPTION(BUILD_TESTS "Build Unit tests" ON) ENDIF(NOT BUILD_TESTS) -ADD_SUBDIRECTORY(src) - +# rtklib path +SET(RTKLIB_DIR deps/RTKLIB) +SET(RTKLIB_SRC_DIR ${RTKLIB_DIR}/src) + +# driver source files +SET(SOURCES + src/gnss_utils.cpp + src/observations.cpp + src/navigation.cpp + src/TDCP.cpp + src/utils.cpp) + +SET(RTKLIB_SRC + ${RTKLIB_SRC_DIR}/pntpos.c + ${RTKLIB_SRC_DIR}/rtkcmn.c + ${RTKLIB_SRC_DIR}/sbas.c + ${RTKLIB_SRC_DIR}/ephemeris.c + ${RTKLIB_SRC_DIR}/preceph.c + ${RTKLIB_SRC_DIR}/qzslex.c + ${RTKLIB_SRC_DIR}/rtcm.c + ${RTKLIB_SRC_DIR}/rtcm2.c + ${RTKLIB_SRC_DIR}/rtcm3.c + ${RTKLIB_SRC_DIR}/rtcm3e.c + ${RTKLIB_SRC_DIR}/ionex.c + ${RTKLIB_SRC_DIR}/rinex.c) + + +# application header files +SET(HEADERS + include/gnss_utils/gnss_utils.h + include/gnss_utils/utils.h + include/gnss_utils/observations.h + include/gnss_utils/navigation.h + include/gnss_utils/TDCP.h + ${RTKLIB_SRC_DIR}/rtklib.h) + +# Eigen ####### +FIND_PACKAGE(Eigen3 REQUIRED) + +# Boost ####### +set(Boost_USE_STATIC_LIBS OFF) +set(Boost_USE_MULTITHREADED OFF) +set(Boost_USE_STATIC_RUNTIME OFF) +FIND_PACKAGE(Boost REQUIRED) + +# Adding libraries' directories +link_directories(/usr/lib/x86_64-linux-gnu/) + +# Adding include directories +INCLUDE_DIRECTORIES(include/ ${EIGEN3_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${RTKLIB_SRC_DIR}) + +# create the shared library +ADD_LIBRARY(gnss_utils SHARED ${SOURCES} ${RTKLIB_SRC}) +TARGET_LINK_LIBRARIES(gnss_utils ${Boost_LIBRARIES}) + +# Installing +INSTALL(TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib/iri-algorithms + ARCHIVE DESTINATION lib/iri-algorithms) +INSTALL(FILES ${HEADERS} DESTINATION include/iri-algorithms/gnss_utils) +INSTALL(FILES ../Findgnss_utils.cmake DESTINATION ${CMAKE_ROOT}/Modules/) + + +# Examples +ADD_SUBDIRECTORY(src/examples) if(BUILD_TESTS) # Enables testing for this directory and below. # Note that ctest expects to find a test file in the build directory root. # Therefore, this command should be in the source directory root. #include(CTest) # according to http://public.kitware.com/pipermail/cmake/2012-June/050853.html - enable_testing() MESSAGE("Building tests.") + enable_testing() +endif() + +# Testing +if(BUILD_TESTS) + add_subdirectory(test) endif() FIND_PACKAGE(Doxygen) @@ -94,4 +163,4 @@ ELSE(UNIX) COMMENT "uninstall only implemented in unix" TARGET uninstall ) -ENDIF(UNIX) \ No newline at end of file +ENDIF(UNIX) diff --git a/include/gnss_utils/gnss_utils.h b/include/gnss_utils/gnss_utils.h index e90e6cc..ec75472 100644 --- a/include/gnss_utils/gnss_utils.h +++ b/include/gnss_utils/gnss_utils.h @@ -43,13 +43,13 @@ namespace GNSSUtils Navigation & _navigation, const prcopt_t & _prcopt); - ComputePosOutput computePosOwn(const Observations & _observations, - Navigation & _navigation, - const prcopt_t & _prcopt); + // ComputePosOutput computePosOwn(const Observations & _observations, + // Navigation & _navigation, + // const prcopt_t & _prcopt); - int pntposOwn(const obsd_t *obs, int n, const nav_t *nav, - const prcopt_t *opt, sol_t *sol, double *azel, ssat_t *ssat, - char *msg); + // int pntposOwn(const obsd_t *obs, int n, const nav_t *nav, + // const prcopt_t *opt, sol_t *sol, double *azel, ssat_t *ssat, + // char *msg); int estposOwn(const obsd_t *obs, int n, const double *rs, const double *dts, const double *vare, const int *svh, const nav_t *nav, diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index 50ebf67..0000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1,71 +0,0 @@ -# rtklib path -SET(RTKLIB_DIR ../deps/RTKLIB) -SET(RTKLIB_SRC_DIR ${RTKLIB_DIR}/src) - -# driver source files -SET(SOURCES - gnss_utils.cpp - observations.cpp - navigation.cpp - TDCP.cpp - utils.cpp) - -SET(RTKLIB_SRC - ${RTKLIB_SRC_DIR}/pntpos.c - ${RTKLIB_SRC_DIR}/rtkcmn.c - ${RTKLIB_SRC_DIR}/sbas.c - ${RTKLIB_SRC_DIR}/ephemeris.c - ${RTKLIB_SRC_DIR}/preceph.c - ${RTKLIB_SRC_DIR}/qzslex.c - ${RTKLIB_SRC_DIR}/rtcm.c - ${RTKLIB_SRC_DIR}/rtcm2.c - ${RTKLIB_SRC_DIR}/rtcm3.c - ${RTKLIB_SRC_DIR}/rtcm3e.c - ${RTKLIB_SRC_DIR}/ionex.c - ${RTKLIB_SRC_DIR}/rinex.c) - - -# application header files -SET(HEADERS - ../include/gnss_utils/gnss_utils.h - ../include/gnss_utils/utils.h - ../include/gnss_utils/observations.h - ../include/gnss_utils/navigation.h - ../include/gnss_utils/TDCP.h - ${RTKLIB_SRC_DIR}/rtklib.h) - -# Eigen ####### -FIND_PACKAGE(Eigen3 REQUIRED) - -# Boost ####### -set(Boost_USE_STATIC_LIBS OFF) -set(Boost_USE_MULTITHREADED OFF) -set(Boost_USE_STATIC_RUNTIME OFF) -FIND_PACKAGE(Boost REQUIRED) - -# Adding libraries' directories -link_directories(/usr/lib/x86_64-linux-gnu/) - -# Adding include directories -INCLUDE_DIRECTORIES(../include/ ${EIGEN3_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${RTKLIB_SRC_DIR}) - -# create the shared library -ADD_LIBRARY(gnss_utils SHARED ${SOURCES} ${RTKLIB_SRC}) -TARGET_LINK_LIBRARIES(gnss_utils ${Boost_LIBRARIES}) - -# Installing -INSTALL(TARGETS ${PROJECT_NAME} - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib/iri-algorithms - ARCHIVE DESTINATION lib/iri-algorithms) -INSTALL(FILES ${HEADERS} DESTINATION include/iri-algorithms/gnss_utils) -INSTALL(FILES ../Findgnss_utils.cmake DESTINATION ${CMAKE_ROOT}/Modules/) - -# Testing -if(BUILD_TESTS) - MESSAGE("Building tests.") - add_subdirectory(test) -endif() - -# Examples -ADD_SUBDIRECTORY(examples) \ No newline at end of file diff --git a/src/gnss_utils.cpp b/src/gnss_utils.cpp index e4336e5..38acebf 100644 --- a/src/gnss_utils.cpp +++ b/src/gnss_utils.cpp @@ -52,54 +52,54 @@ namespace GNSSUtils return output; } - ComputePosOutput computePosOwn(const GNSSUtils::Observations & _observations, - GNSSUtils::Navigation & _navigation, - const prcopt_t & _prcopt) - { - - // Remove duplicated satellites - uniqnav(&(_navigation.getNavigation())); - - // Define error msg - char msg[128] = ""; - - GNSSUtils::ComputePosOutput output; - sol_t sol; - sol = {{0}}; - - output.pos_stat = pntposOwn(_observations.data(), _observations.size(), - &(_navigation.getNavigation()), - &_prcopt, &sol, NULL, NULL, msg); - - if (output.pos_stat == 0) - { - std::cout << "Bad computing: " << msg << "\n"; - } - - output.time = sol.time.time; - output.sec = sol.time.sec; - output.pos = Eigen::Vector3d(sol.rr); - // std::cout << "Compute pos: " << output.pos.transpose() << "\n"; - output.vel = Eigen::Vector3d(&sol.rr[3]); - output.pos_covar << sol.qr[0], sol.qr[3], sol.qr[5], - sol.qr[3], sol.qr[1], sol.qr[4], - sol.qr[5], sol.qr[3], sol.qr[2]; - - // XXX: segmentation fault here. - // if (sol.dtr != NULL) - // { - // output.rcv_bias << sol.dtr[0], sol.dtr[1], sol.dtr[2], sol.dtr[3], sol.dtr[4], sol.dtr[5]; - // } - - output.type = sol.type; - output.stat = sol.stat; - output.ns = sol.ns; - output.age = sol.age; - output.ratio = sol.ratio; - output.lat_lon = ecefToLatLonAlt(output.pos); - - return output; - } + // ComputePosOutput computePosOwn(const GNSSUtils::Observations & _observations, + // GNSSUtils::Navigation & _navigation, + // const prcopt_t & _prcopt) + // { + + // // Remove duplicated satellites + // uniqnav(&(_navigation.getNavigation())); + + // // Define error msg + // char msg[128] = ""; + + // GNSSUtils::ComputePosOutput output; + // sol_t sol; + // sol = {{0}}; + + // output.pos_stat = pntposOwn(_observations.data(), _observations.size(), + // &(_navigation.getNavigation()), + // &_prcopt, &sol, NULL, NULL, msg); + + // if (output.pos_stat == 0) + // { + // std::cout << "Bad computing: " << msg << "\n"; + // } + + // output.time = sol.time.time; + // output.sec = sol.time.sec; + // output.pos = Eigen::Vector3d(sol.rr); + // // std::cout << "Compute pos: " << output.pos.transpose() << "\n"; + // output.vel = Eigen::Vector3d(&sol.rr[3]); + // output.pos_covar << sol.qr[0], sol.qr[3], sol.qr[5], + // sol.qr[3], sol.qr[1], sol.qr[4], + // sol.qr[5], sol.qr[3], sol.qr[2]; + + // // XXX: segmentation fault here. + // // if (sol.dtr != NULL) + // // { + // // output.rcv_bias << sol.dtr[0], sol.dtr[1], sol.dtr[2], sol.dtr[3], sol.dtr[4], sol.dtr[5]; + // // } + + // output.type = sol.type; + // output.stat = sol.stat; + // output.ns = sol.ns; + // output.age = sol.age; + // output.ratio = sol.ratio; + // output.lat_lon = ecefToLatLonAlt(output.pos); + + // return output; + // } /* single-point positioning COPIED FROM RTKLIB ------------------------------ * compute receiver position, velocity, clock bias by single-point positioning @@ -117,66 +117,66 @@ namespace GNSSUtils * receiver bias are negligible (only involving glonass-gps time offset * and receiver bias) *-----------------------------------------------------------------------------*/ - int pntposOwn(const obsd_t *obs, int n, const nav_t *nav, - const prcopt_t *opt, sol_t *sol, double *azel, ssat_t *ssat, - char *msg) - { - prcopt_t opt_=*opt; - double *rs,*dts,*var,*azel_,*resp; - int i,stat,vsat[MAXOBS]={0},svh[MAXOBS]; - - sol->stat=SOLQ_NONE; - - if (n<=0) {strcpy(msg,"no observation data"); return 0;} - - trace(3,"pntpos : tobs=%s n=%d\n",time_str(obs[0].time,3),n); - - sol->time=obs[0].time; msg[0]='\0'; - - rs=mat(6,n); dts=mat(2,n); var=mat(1,n); azel_=zeros(2,n); resp=mat(1,n); - - if (opt_.mode!=PMODE_SINGLE) { /* for precise positioning */ - #if 0 - opt_.sateph =EPHOPT_BRDC; - #endif - opt_.ionoopt=IONOOPT_BRDC; - opt_.tropopt=TROPOPT_SAAS; - } - /* satellite positons, velocities and clocks */ - satposs(sol->time,obs,n,nav,opt_.sateph,rs,dts,var,svh); - - /* estimate receiver position with pseudorange */ - stat=estposOwn(obs,n,rs,dts,var,svh,nav,&opt_,sol,azel_,vsat,resp,msg); - - /* raim fde */ - if (!stat&&n>=6&&opt->posopt[4]) { - stat=raim_fde(obs,n,rs,dts,var,svh,nav,&opt_,sol,azel_,vsat,resp,msg); - } - /* estimate receiver velocity with doppler */ - //if (stat) estvel(obs,n,rs,dts,nav,&opt_,sol,azel_,vsat); - - if (azel) { - for (i=0;i<n*2;i++) azel[i]=azel_[i]; - } - if (ssat) { - for (i=0;i<MAXSAT;i++) { - ssat[i].vs=0; - ssat[i].azel[0]=ssat[i].azel[1]=0.0; - ssat[i].resp[0]=ssat[i].resc[0]=0.0; - ssat[i].snr[0]=0; - } - for (i=0;i<n;i++) { - ssat[obs[i].sat-1].azel[0]=azel_[ i*2]; - ssat[obs[i].sat-1].azel[1]=azel_[1+i*2]; - ssat[obs[i].sat-1].snr[0]=obs[i].SNR[0]; - if (!vsat[i]) continue; - ssat[obs[i].sat-1].vs=1; - ssat[obs[i].sat-1].resp[0]=resp[i]; - } - } - free(rs); free(dts); free(var); free(azel_); free(resp); - return stat; - } + // int pntposOwn(const obsd_t *obs, int n, const nav_t *nav, + // const prcopt_t *opt, sol_t *sol, double *azel, ssat_t *ssat, + // char *msg) + // { + // prcopt_t opt_=*opt; + // double *rs,*dts,*var,*azel_,*resp; + // int i,stat,vsat[MAXOBS]={0},svh[MAXOBS]; + + // sol->stat=SOLQ_NONE; + + // if (n<=0) {strcpy(msg,"no observation data"); return 0;} + + // trace(3,"pntpos : tobs=%s n=%d\n",time_str(obs[0].time,3),n); + + // sol->time=obs[0].time; msg[0]='\0'; + + // rs=mat(6,n); dts=mat(2,n); var=mat(1,n); azel_=zeros(2,n); resp=mat(1,n); + + // if (opt_.mode!=PMODE_SINGLE) { /* for precise positioning */ + // #if 0 + // opt_.sateph =EPHOPT_BRDC; + // #endif + // opt_.ionoopt=IONOOPT_BRDC; + // opt_.tropopt=TROPOPT_SAAS; + // } + // /* satellite positons, velocities and clocks */ + // satposs(sol->time,obs,n,nav,opt_.sateph,rs,dts,var,svh); + + // /* estimate receiver position with pseudorange */ + // stat=estposOwn(obs,n,rs,dts,var,svh,nav,&opt_,sol,azel_,vsat,resp,msg); + + // /* raim fde */ + // if (!stat&&n>=6&&opt->posopt[4]) { + // stat=raim_fde(obs,n,rs,dts,var,svh,nav,&opt_,sol,azel_,vsat,resp,msg); + // } + // /* estimate receiver velocity with doppler */ + // //if (stat) estvel(obs,n,rs,dts,nav,&opt_,sol,azel_,vsat); + + // if (azel) { + // for (i=0;i<n*2;i++) azel[i]=azel_[i]; + // } + // if (ssat) { + // for (i=0;i<MAXSAT;i++) { + // ssat[i].vs=0; + // ssat[i].azel[0]=ssat[i].azel[1]=0.0; + // ssat[i].resp[0]=ssat[i].resc[0]=0.0; + // ssat[i].snr[0]=0; + // } + // for (i=0;i<n;i++) { + // ssat[obs[i].sat-1].azel[0]=azel_[ i*2]; + // ssat[obs[i].sat-1].azel[1]=azel_[1+i*2]; + // ssat[obs[i].sat-1].snr[0]=obs[i].SNR[0]; + // if (!vsat[i]) continue; + // ssat[obs[i].sat-1].vs=1; + // ssat[obs[i].sat-1].resp[0]=resp[i]; + // } + // } + // free(rs); free(dts); free(var); free(azel_); free(resp); + // return stat; + // } int estposOwn(const obsd_t *obs, int n, const double *rs, const double *dts, const double *vare, const int *svh, const nav_t *nav, diff --git a/src/test/CMakeLists.txt b/test/CMakeLists.txt similarity index 100% rename from src/test/CMakeLists.txt rename to test/CMakeLists.txt diff --git a/src/test/gtest/CMakeLists.txt b/test/gtest/CMakeLists.txt similarity index 100% rename from src/test/gtest/CMakeLists.txt rename to test/gtest/CMakeLists.txt diff --git a/src/test/gtest/utils_gtest.h b/test/gtest/utils_gtest.h similarity index 100% rename from src/test/gtest/utils_gtest.h rename to test/gtest/utils_gtest.h diff --git a/src/test/gtest_example.cpp b/test/gtest_example.cpp similarity index 100% rename from src/test/gtest_example.cpp rename to test/gtest_example.cpp diff --git a/src/test/gtest_transformations.cpp b/test/gtest_transformations.cpp similarity index 100% rename from src/test/gtest_transformations.cpp rename to test/gtest_transformations.cpp -- GitLab