diff --git a/utils/solplot/CMakeLists.txt b/utils/solplot/CMakeLists.txt index 1e228a6b..45441ab2 100644 --- a/utils/solplot/CMakeLists.txt +++ b/utils/solplot/CMakeLists.txt @@ -66,8 +66,10 @@ include(${FLTK_USE_FILE}) # add user interface and callback source dir to search for header files #include_directories(${PROJECT_SOURCE_DIR}/ui) include_directories(${PROJECT_SOURCE_DIR}/ui/cb) -# add rtk dir of this project to search for RTK related functions +# add sol dir of this project to search for RTK related functions include_directories(${PROJECT_SOURCE_DIR}/sol) +# add plot dir of this project to search for plot.h +include_directories(${PROJECT_SOURCE_DIR}/plot) #---- library files path settings ---- # add library dir into lib path @@ -75,6 +77,8 @@ include_directories(${PROJECT_SOURCE_DIR}/sol) link_directories(${PROJECT_SOURCE_DIR}/../../3rdparty/fltk-1.3.3/build/lib) # add rtklib lib directory link_directories(${PROJECT_SOURCE_DIR}/../../3rdparty/rtklib_2.4.2_p10/build) +# add octave lib directory +link_directories(/usr/lib/x86_64-linux-gnu) #---- start compiling ---- # convert GUI *.fl ui file to *.cxx and *.h files @@ -89,13 +93,16 @@ add_dependencies(${PRJ_NAME} plot) #---- start linking ---- # Note: the former line depends on the next line -# link plot library created above -target_link_libraries(${PRJ_NAME} plot) # link GUI library created above target_link_libraries(${PRJ_NAME} ${LIB_UI_NAME}) +# link plot library created above +target_link_libraries(${PRJ_NAME} plot) # link external FLTK library target_link_libraries(${PRJ_NAME} fltk) # link external OpenGL library #target_link_libraries(${PRJ_NAME} fltk_gl) # link external rtklib library target_link_libraries(${PRJ_NAME} rtk) +# link external octave library +target_link_libraries(${PRJ_NAME} octinterp) +target_link_libraries(${PRJ_NAME} octave) diff --git a/utils/solplot/plot/CMakeLists.txt b/utils/solplot/plot/CMakeLists.txt index 5a3cb86f..017ca6c7 100644 --- a/utils/solplot/plot/CMakeLists.txt +++ b/utils/solplot/plot/CMakeLists.txt @@ -1,4 +1,17 @@ +#==================================================== +# CMakeLists configuration file for plot lib of +# solplot project +# this file aims to build a lib calls plot to be +# further linked to the project +# +# Author: Roice(LUO Bing) +# Date: 2014-11-26 Create this file + +# include octave related include_directories(/usr/include/octave-3.8.2) include_directories(/usr/include/octave-3.8.2/octave) include_directories(/usr/include/hdf5/serial) +# include rtklib related, so as to search for rtklib.h +include_directories(${PROJECT_SOURCE_DIR}/../../3rdparty/rtklib_2.4.2_p10/src) + add_library(plot plot_octave.cxx) diff --git a/utils/solplot/plot/plot_octave.cxx b/utils/solplot/plot/plot_octave.cxx index 8e885b7d..1298fbfe 100644 --- a/utils/solplot/plot/plot_octave.cxx +++ b/utils/solplot/plot/plot_octave.cxx @@ -1,3 +1,37 @@ #include // Octave math functions related -void solsss(void) -{} +#include +#include +#include /* do_octave_atexit */ +#include // for solbuf_t structure definition + +void plotRTKtraj3d(solbuf_t *sol) +{ + int i,j; + + const char * argvv [] = {"" /* name of program, not relevant */, "--silent"}; + + octave_main(2, (char **) argvv, true /**/); + + octave_value_list funcArg; + + /* Create a matrix with 3 rows(xyz or enu) and sol->n colums + * sol->n is the number of solution */ + Matrix position(3, sol->n, double(0)); + + /* fetch position data and put them into matrix */ + for(i=0; i<3; i++) + { + for(j=0; jn; j++) + { + position(i, j) = double(sol->data[j].rr[i]); + } + } + + funcArg(0) = position; + + const octave_value_list result = feval("octplotRTKtraj3d", funcArg, 1); +#ifdef DEBUG + fprintf(stderr, "position(0,0) = %f", position(0, 0)); +#endif +// clean_up_and_exit(0); +} diff --git a/utils/solplot/sol/ufrtk.c b/utils/solplot/sol/ufrtk.c index d8b1f3ff..447e799f 100644 --- a/utils/solplot/sol/ufrtk.c +++ b/utils/solplot/sol/ufrtk.c @@ -9,5 +9,40 @@ int ReadSolutionFiles(char *files[], int nfile, solbuf_t *sol) { - return readsol(files, nfile, sol); + int i, j; + double origin_pos[3], origin_r[3], r[3]; + + if (!readsol(files, nfile, sol)) + { + fprintf(stderr, "Error: No solution!"); + } + + /* set the origin position to 39.10639N 117.17046E 20m*/ + origin_pos[0] = 39.10639; origin_pos[1] = 117.17046; origin_pos[3] = 20; + /* compute the ENU coordinate of this point, convert llh to ecef*/ + pos2ecef(origin_pos, origin_r); + for (j=0; j<3; j++) + r[j] = origin_r[j]; + ecef2enu(origin_pos, r, origin_r); + + + fprintf(stderr, "origin_r = %f, %f, %f\n", origin_r[0], origin_r[1], origin_r[2]); + + /* convert solution from ECEF to local ENU coordinate */ + for (i=0; in; i++) + { + for (j=0; j<3; j++) + { + /* fetch the ecef vector */ + r[j] = sol->data[i].rr[j]; + } + /* convert ecef to ENU */ + ecef2enu(origin_pos, r, &sol->data[i].rr[0]); + for(j=0; j<3; j++) + { + /* convert ENU to local ENU */ + sol->data[i].rr[j] = sol->data[i].rr[j] - origin_r[j]; + } + } + return 1; } diff --git a/utils/solplot/ui/cb/SolPlotPanel.cxx b/utils/solplot/ui/cb/SolPlotPanel.cxx index e0081682..1f211450 100644 --- a/utils/solplot/ui/cb/SolPlotPanel.cxx +++ b/utils/solplot/ui/cb/SolPlotPanel.cxx @@ -14,6 +14,7 @@ #include #include // fl_open_uri() #include "ufrtk.h" // RTK related functions of this project +#include "plot.h" // plot functions /* Functions... */ static void SolPlot_LoadFilePlot(char *files[], int nfile); @@ -100,6 +101,7 @@ static void SolPlot_LoadFilePlot(char *files[], int nfile) fprintf(stderr, "DEBUG: Decoded solution sol.data[%d]->rr[2] == %f\n", sol.n -1, sol.data[sol.n-1].rr[2]); #endif /* plot solutions with octave */ + plotRTKtraj3d(&sol); } }