Added forgotten code

This commit is contained in:
2019-05-01 10:45:53 +02:00
parent a7be6b8d62
commit b99d519aa7
8 changed files with 467 additions and 516 deletions

1
code/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
build/

View File

@@ -22,6 +22,7 @@ INCLUDE_DIRECTORIES(
../../
../../../
../../../../
D:/Source/Navegadors/
)
@@ -41,11 +42,22 @@ FILE(GLOB SOURCES
./*/*.cpp
./*/*/*.cpp
./*/*/*/*.cpp
../../Indoor/lib/tinyxml/tinyxml2.cpp
../../Indoor/lib/Recast/*.cpp
D:/Source/Navegadors/Indoor/lib/tinyxml/tinyxml2.cpp
D:/Source/Navegadors/Indoor/lib/Recast/*.cpp
)
if(${CMAKE_GENERATOR} MATCHES "Visual Studio")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D_USE_MATH_DEFINES")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi /Oi /GL /Ot /Ox /D_USE_MATH_DEFINES")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG")
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG /INCREMENTAL:NO")
set(CMAKE_CONFIGURATION_TYPES Release Debug)
else()
# system specific compiler flags
ADD_DEFINITIONS(
@@ -70,6 +82,7 @@ ADD_DEFINITIONS(
)
endif()
# allow OMP
find_package(OpenMP)
@@ -89,8 +102,8 @@ ADD_EXECUTABLE(
# needed external libraries
TARGET_LINK_LIBRARIES(
${PROJECT_NAME}
gtest
pthread
# gtest
# pthread
)
SET(CMAKE_C_COMPILER ${CMAKE_CXX_COMPILER})

View File

@@ -508,6 +508,18 @@ public:
gp.flush();
}
void saveSVG(const std::experimental::filesystem::path& filePath) {
std::ofstream stream;
stream.open(filePath);
stream << "set terminal svg size 2000,1500\n";
stream << "set output '" + filePath.filename().replace_extension("svg").string() + "'\n";
gp.draw(splot);
stream << gp.getBuffer();
stream.close();
}
void saveToFile(std::ofstream& stream){
gp.draw(splot);
stream << "set terminal x11 size 2000,1500\n";

View File

@@ -83,9 +83,9 @@ namespace Settings {
constexpr bool useMainThread = false; // perform filtering in the main thread
}
const std::string mapDir = "../map/";
const std::string dataDir = "../measurements/";
const std::string errorDir = dataDir + "results/";
const std::string mapDir = "D:/Source/Navegadors/maps/museum/";
const std::string dataDir = "D:/Source/Navegadors/NavData/2018_02_01_museum/measurements/data/";
const std::string errorDir = "D:/Forschung/2 Fusion 2018/Fusion2018/code/build/results";
/** describes one dataset (map, training, parameter-estimation, ...) */
struct DataSetup {
@@ -104,17 +104,17 @@ namespace Settings {
mapDir + "map42_ap_path0.xml",
{
dataDir + "museum/Nexus/Path0_4113.csv",
dataDir + "museum/Nexus/Path0_6563.csv",
dataDir + "museum/Pixel/Path0_1498.csv",
dataDir + "museum/Pixel/Path0_2529.csv",
dataDir + "museum/Pixel/Path0_7380.csv",
dataDir + "Nexus/Path0_4113.csv",
dataDir + "Nexus/Path0_6563.csv",
dataDir + "Pixel/Path0_1498.csv",
dataDir + "Pixel/Path0_2529.csv",
dataDir + "Pixel/Path0_7380.csv",
//dataDir + "museum/Samsung/Path0_4208.csv",
//dataDir + "museum/Samsung/Path0_6812.csv",
},
dataDir + "museum/Nexus/fingerprints/wifi_fp.dat",
dataDir + "museum/wifimodel.dat",
dataDir + "Nexus/fingerprints/wifi_fp.dat",
dataDir + "wifimodel.dat",
15
};
@@ -123,17 +123,17 @@ namespace Settings {
mapDir + "map42_ap_path1_hofzu.xml",
{
dataDir + "museum/Nexus/Path1_1548.csv",
dataDir + "museum/Nexus/Path1_9477.csv",
dataDir + "museum/Pixel/Path1_2468.csv",
dataDir + "museum/Pixel/Path1_5497.csv",
dataDir + "museum/Pixel/Path1_8787.csv",
dataDir + "museum/Samsung/Path1_5745.csv",
dataDir + "museum/Samsung/Path1_9130.csv"
dataDir + "Nexus/Path1_1548.csv",
dataDir + "Nexus/Path1_9477.csv",
dataDir + "Pixel/Path1_2468.csv",
dataDir + "Pixel/Path1_5497.csv",
dataDir + "Pixel/Path1_8787.csv",
dataDir + "Samsung/Path1_5745.csv",
dataDir + "Samsung/Path1_9130.csv"
},
dataDir + "museum/Nexus/fingerprints/wifi_fp.dat",
dataDir + "museum/wifimodel.dat",
dataDir + "Nexus/fingerprints/wifi_fp.dat",
dataDir + "wifimodel.dat",
32
};
@@ -142,18 +142,18 @@ namespace Settings {
mapDir + "map42_ap_path2.xml",
{
dataDir + "museum/Nexus/Path2_0374.csv",
dataDir + "museum/Nexus/Path2_4718.csv",
dataDir + "museum/Nexus/Path2_8766.csv",
dataDir + "museum/Pixel/Path2_4336.csv",
dataDir + "museum/Pixel/Path2_4341.csv",
dataDir + "museum/Pixel/Path2_9038.csv",
dataDir + "Nexus/Path2_0374.csv",
dataDir + "Nexus/Path2_4718.csv",
dataDir + "Nexus/Path2_8766.csv",
dataDir + "Pixel/Path2_4336.csv",
dataDir + "Pixel/Path2_4341.csv",
dataDir + "Pixel/Path2_9038.csv",
//dataDir + "museum/Samsung/Path2_3326.csv",
//dataDir + "museum/Samsung/Path2_5814.csv"
},
dataDir + "museum/Nexus/fingerprints/wifi_fp.dat",
dataDir + "museum/wifimodel.dat",
dataDir + "Nexus/fingerprints/wifi_fp.dat",
dataDir + "wifimodel.dat",
44
};
@@ -162,17 +162,17 @@ namespace Settings {
mapDir + "map42_ap_path3.xml",
{
dataDir + "museum/Nexus/Path3_4519.csv",
dataDir + "museum/Nexus/Path3_5929.csv",
dataDir + "museum/Pixel/Path3_6307.csv",
dataDir + "museum/Pixel/Path3_5451.csv",
dataDir + "museum/Pixel/Path3_9243.csv",
dataDir + "Nexus/Path3_4519.csv",
dataDir + "Nexus/Path3_5929.csv",
dataDir + "Pixel/Path3_6307.csv",
dataDir + "Pixel/Path3_5451.csv",
dataDir + "Pixel/Path3_9243.csv",
//dataDir + "museum/Samsung/Path3_7610.csv",
//dataDir + "museum/Samsung/Path3_7819.csv"
},
dataDir + "museum/Nexus/fingerprints/wifi_fp.dat",
dataDir + "museum/wifimodel.dat",
dataDir + "Nexus/fingerprints/wifi_fp.dat",
dataDir + "wifimodel.dat",
45
};

View File

@@ -6,8 +6,10 @@
#include "navMesh/meshPlotter.h"
#include "Plotty.h"
#include <chrono>
#include <memory>
#include <thread>
#include <experimental/filesystem>
#include <Indoor/floorplan/v2/FloorplanReader.h>
#include <Indoor/sensors/radio/model/WiFiModelLogDistCeiling.h>
@@ -24,7 +26,22 @@
#include <Indoor/smc/filtering/resampling/ParticleFilterResamplingSimpleImpoverishment.h>
#include <sys/stat.h>
#define ESTIMATE_ALGO 3
enum class Type {
UNKNOWN,
GROUND_INDOOR,
GROUND_OUTDOOR,
STAIR,
HANDRAIL,
DOOR,
WALL,
WINDOW,
OBJECT,
ERROR,
};
Stats::Statistics<float> run(Settings::DataSetup setup, int numFile, std::string folder) {
@@ -42,17 +59,27 @@ Stats::Statistics<float> run(Settings::DataSetup setup, int numFile, std::string
//error file
const long int t = static_cast<long int>(time(NULL));
const std::string evalDir = Settings::errorDir + folder;
struct stat statStruct;
stat(evalDir.c_str(), &statStruct);
if(!S_ISDIR(statStruct.st_mode)){
if(mkdir(evalDir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == -1){
Assert::doThrow("Eval folder couldn't be created!");
}
auto evalDir = std::experimental::filesystem::path(Settings::errorDir);
evalDir.append(folder);
if (!std::experimental::filesystem::exists(evalDir)) {
std::experimental::filesystem::create_directory(evalDir);
}
std::ofstream errorFile;
errorFile.open (evalDir + "/" + std::to_string(numFile) + "_" + std::to_string(t) + ".csv");
std::ofstream estimationFile;
std::string outputBasePath = evalDir.string() + "/";
#if ESTIMATE_ALGO == 1
outputBasePath += "KDE_";
#elif ESTIMATE_ALGO == 2
outputBasePath += "WAVG_";
#else
outputBasePath += "MAXP_";
#endif
outputBasePath += std::to_string(numFile) + "_" + std::to_string(t);
errorFile.open(outputBasePath + "error.csv");
estimationFile.open(outputBasePath + "est.csv");
// wifi
WiFiModelLogDistCeiling WiFiModel(map);
@@ -115,17 +142,22 @@ Stats::Statistics<float> run(Settings::DataSetup setup, int numFile, std::string
// particle-filter
const int numParticles = 5000;
//auto init = std::make_unique<MyPFInitFixed>(&mesh, srcPath1); // known position
auto init = std::make_unique<MyPFInitUniform>(&mesh); // uniform distribution
auto init = std::make_unique<MyPFInitFixed>(&mesh, srcPath1); // known position
//auto init = std::make_unique<MyPFInitUniform>(&mesh); // uniform distribution
auto eval = std::make_unique<MyPFEval>(WiFiModel);
auto trans = std::make_unique<MyPFTrans>(mesh);
//auto resample = std::make_unique<SMC::ParticleFilterResamplingSimple<MyState>>();
auto resample = std::make_unique<SMC::ParticleFilterResamplingSimpleImpoverishment<MyState, MyNavMeshTriangle>>();
#if ESTIMATE_ALGO == 1
auto estimate = std::make_unique<SMC::ParticleFilterEstimationBoxKDE<MyState>>(map, 0.2, Point2(1, 1));
//auto estimate = std::make_unique<SMC::ParticleFilterEstimationWeightedAverage<MyState>>();
//auto estimate = std::make_unique<SMC::ParticleFilterEstimationMax<MyState>>();
#elif ESTIMATE_ALGO == 2
auto estimate = std::make_unique<SMC::ParticleFilterEstimationWeightedAverage<MyState>>();
#else
auto estimate = std::make_unique<SMC::ParticleFilterEstimationMax<MyState>>();
#endif
// setup
MyFilter pf(numParticles, std::move(init));
@@ -207,21 +239,45 @@ Stats::Statistics<float> run(Settings::DataSetup setup, int numFile, std::string
plot.setCurEst(est.pos.pos);
plot.setGroundTruth(gtPos);
plot.addEstimationNode(est.pos.pos);
plot.plot();
//plot.plot();
// error calc
float err_m = gtPos.getDistance(est.pos.pos);
errorStats.add(err_m);
errorFile << ts.ms() << " " << err_m << "\n";
estimationFile << est.pos.pos.x << " " << est.pos.pos.y << " " << est.pos.pos.z << "\n";
//dbg.gp.setOutput("/tmp/123/" + std::to_string(i) + ".png");
//dbg.gp.setTerminal("pngcairo", K::GnuplotSize(60, 30));
if(ts.ms() == 13410 || ts.ms() == 20802){
std::ofstream plotFile;
plotFile.open(evalDir + "/" + std::to_string(numFile) + "_" + std::to_string(t) + "_plot_zwischendrin_" + std::to_string(ts.ms()) + ".gp");
plot.saveToFile(plotFile);
plotFile.close();
std::string filePath = evalDir.string() + "/";
#if ESTIMATE_ALGO == 1
filePath += "KDE_";
#elif ESTIMATE_ALGO == 2
filePath += "WAVG_";
#else
filePath += "MAXP_";
#endif
filePath += std::to_string(numFile) + "_" + std::to_string(t) + "_plot_zwischendrin_" + std::to_string(ts.ms()) + ".gp";
plot.saveSVG(filePath);
//plotFile.open(filePath + ".gp");
// plot.saveToFile(plotFile);
// plotFile.close();
}
//std::this_thread::sleep_for(std::chrono::milliseconds(500));
if (ts.ms() == 20802)
{
break;
}
}
}
@@ -241,6 +297,8 @@ Stats::Statistics<float> run(Settings::DataSetup setup, int numFile, std::string
errorFile << "75 Quantil: " << errorStats.getQuantile(0.75) << "\n";
errorFile.close();
estimationFile.close();
//save the .gp buffer into a file
// std::ofstream plotFile;
// plotFile.open(evalDir + "/" + std::to_string(numFile) + "_" + std::to_string(t) + "_plot" + ".gp");
@@ -248,7 +306,7 @@ Stats::Statistics<float> run(Settings::DataSetup setup, int numFile, std::string
// plotFile.close();
std::ofstream plotFile;
plotFile.open(evalDir + "/" + std::to_string(numFile) + "_" + std::to_string(t) + "_plot_" + std::to_string(obs.currentTime.ms()) + ".gp");
plotFile.open(evalDir.string() + "/" + std::to_string(numFile) + "_" + std::to_string(t) + "_plot_" + std::to_string(obs.currentTime.ms()) + ".gp");
plot.saveToFile(plotFile);
plotFile.close();
@@ -266,7 +324,7 @@ int main(int argc, char** argv) {
Stats::Statistics<float> statsQuantil;
Stats::Statistics<float> tmp;
Settings::DataSetup set = Settings::data.Path0;
Settings::DataSetup set = Settings::data.Path1;
std::string evaluationName = "museum/Path1_Bulli_2D_PlotsPaper";
for(int i = 0; i < 1; ++i){

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,6 @@
set terminal epslatex size 3.5,2.5
set output "perf.tex"
#set terminal windows
set logscale y 10
set logscale x 10
@@ -27,6 +28,7 @@ set ylabel "\\footnotesize{$t$ in seconds}" offset +2.7,0
plot \
"perf/R.csv" using (column(1)**2):(column(2)/1e9) with lines lc rgb "#CC0000" lw 2.0 title "\\footnotesize{BKDE}",\
"perf/Box.csv" using (column(1)**2):(column(2)/1e9) with lines lc rgb "#FCAF3E" lw 2.0 title "\\footnotesize{BoxKDE}",\
"perf/FastKDE.csv" using (column(1)**2):(column(2)) with lines lc rgb "#4E9A06" lw 2.0 title "\\footnotesize{FastKDE}",\
"perf/WeightedAverage.csv" using (column(1)**2):(column(2)/1e9) with lines lc rgb "#3465A4" lw 2.0 title "\\footnotesize{weighted average}"
#FCAF3E

View File

@@ -1,5 +1,9 @@
% GNUPLOT: LaTeX picture with Postscript
\begingroup
% Encoding inside the plot. In the header of your document, this encoding
% should to defined, e.g., by using
% \usepackage[cp1252,<other encodings>]{inputenc}
\inputencoding{cp1252}%
\makeatletter
\providecommand\color[2][]{%
\GenericError{(gnuplot) \space\space\space\@spaces}{%
@@ -82,29 +86,19 @@
\begin{picture}(5040.00,3600.00)%
\gplgaddtomacro\gplbacktext{%
\csname LTb\endcsname%%
\put(554,704){\makebox(0,0)[r]{\strut{}\footnotesize{$10^{-7}$}}}%
\put(554,983){\makebox(0,0)[r]{\strut{}\footnotesize{$10^{-6}$}}}%
\csname LTb\endcsname%%
\put(554,1013){\makebox(0,0)[r]{\strut{}\footnotesize{$10^{-6}$}}}%
\put(554,1540){\makebox(0,0)[r]{\strut{}\footnotesize{$10^{-4}$}}}%
\csname LTb\endcsname%%
\put(554,1323){\makebox(0,0)[r]{\strut{}\footnotesize{$10^{-5}$}}}%
\put(554,2097){\makebox(0,0)[r]{\strut{}\footnotesize{$10^{-2}$}}}%
\csname LTb\endcsname%%
\put(554,1632){\makebox(0,0)[r]{\strut{}\footnotesize{$10^{-4}$}}}%
\put(554,2654){\makebox(0,0)[r]{\strut{}\footnotesize{$10^{0}$}}}%
\csname LTb\endcsname%%
\put(554,1942){\makebox(0,0)[r]{\strut{}\footnotesize{$10^{-3}$}}}%
\csname LTb\endcsname%%
\put(554,2251){\makebox(0,0)[r]{\strut{}\footnotesize{$10^{-2}$}}}%
\csname LTb\endcsname%%
\put(554,2561){\makebox(0,0)[r]{\strut{}\footnotesize{$10^{-1}$}}}%
\csname LTb\endcsname%%
\put(554,2870){\makebox(0,0)[r]{\strut{}\footnotesize{$10^{0}$}}}%
\csname LTb\endcsname%%
\put(554,3180){\makebox(0,0)[r]{\strut{}\footnotesize{$10^{1}$}}}%
\csname LTb\endcsname%%
\put(554,3489){\makebox(0,0)[r]{\strut{}\footnotesize{$10^{2}$}}}%
\put(554,3211){\makebox(0,0)[r]{\strut{}\footnotesize{$10^{2}$}}}%
\csname LTb\endcsname%%
\put(686,484){\makebox(0,0){\strut{}\footnotesize{$10^{2}$}}}%
\csname LTb\endcsname%%
\put(1400,484){\makebox(0,0){\strut{}\footnotesize{$10^{3}$}}}%
\put(1401,484){\makebox(0,0){\strut{}\footnotesize{$10^{3}$}}}%
\csname LTb\endcsname%%
\put(2115,484){\makebox(0,0){\strut{}\footnotesize{$10^{4}$}}}%
\csname LTb\endcsname%%
@@ -121,9 +115,11 @@
\put(30,2096){\rotatebox{-270}{\makebox(0,0){\strut{}\footnotesize{$t$ in seconds}}}}%
\put(2829,154){\makebox(0,0){\strut{}\footnotesize{number of grid points $G$}}}%
\csname LTb\endcsname%%
\put(4415,1262){\makebox(0,0)[r]{\strut{}\footnotesize{BKDE}}}%
\put(4415,1460){\makebox(0,0)[r]{\strut{}\footnotesize{BKDE}}}%
\csname LTb\endcsname%%
\put(4415,1064){\makebox(0,0)[r]{\strut{}\footnotesize{BoxKDE}}}%
\put(4415,1262){\makebox(0,0)[r]{\strut{}\footnotesize{BoxKDE}}}%
\csname LTb\endcsname%%
\put(4415,1064){\makebox(0,0)[r]{\strut{}\footnotesize{FastKDE}}}%
\csname LTb\endcsname%%
\put(4415,866){\makebox(0,0)[r]{\strut{}\footnotesize{weighted average}}}%
}%