Skip to content

Commit

Permalink
local ENU WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
roice committed Nov 26, 2014
1 parent 0c7c1ce commit f4ad6d8
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 6 deletions.
13 changes: 10 additions & 3 deletions utils/solplot/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,19 @@ 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
# add fltk lib directory
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
Expand All @@ -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)
13 changes: 13 additions & 0 deletions utils/solplot/plot/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
38 changes: 36 additions & 2 deletions utils/solplot/plot/plot_octave.cxx
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
#include <octave/oct.h> // Octave math functions related
void solsss(void)
{}
#include <octave/octave.h>
#include <octave/parse.h>
#include <octave/toplev.h> /* do_octave_atexit */
#include <rtklib.h> // 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; j<sol->n; 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);
}
37 changes: 36 additions & 1 deletion utils/solplot/sol/ufrtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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; i<sol->n; 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;
}
2 changes: 2 additions & 0 deletions utils/solplot/ui/cb/SolPlotPanel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <FL/Fl_File_Chooser.H>
#include <FL/filename.H> // 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);
Expand Down Expand Up @@ -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);

}
}
Expand Down

0 comments on commit f4ad6d8

Please sign in to comment.