Statistics: added x,y,z map corrections. Report: added options --stats to show available statistics to plot in a database

This commit is contained in:
matlabbe
2020-04-30 15:48:47 -04:00
parent 803c99cee2
commit 40804d9120
3 changed files with 43 additions and 2 deletions

View File

@@ -74,6 +74,9 @@ class RTABMAP_EXP Statistics
RTABMAP_STATS(Loop, Visual_inliers_mean_dist,m); RTABMAP_STATS(Loop, Visual_inliers_mean_dist,m);
RTABMAP_STATS(Loop, Visual_inliers_distribution,); RTABMAP_STATS(Loop, Visual_inliers_distribution,);
RTABMAP_STATS(Loop, Map_correction_norm, m); RTABMAP_STATS(Loop, Map_correction_norm, m);
RTABMAP_STATS(Loop, Map_correction_x, m);
RTABMAP_STATS(Loop, Map_correction_y, m);
RTABMAP_STATS(Loop, Map_correction_z, m);
RTABMAP_STATS(Loop, Map_correction_roll, deg); RTABMAP_STATS(Loop, Map_correction_roll, deg);
RTABMAP_STATS(Loop, Map_correction_pitch, deg); RTABMAP_STATS(Loop, Map_correction_pitch, deg);
RTABMAP_STATS(Loop, Map_correction_yaw, deg); RTABMAP_STATS(Loop, Map_correction_yaw, deg);

View File

@@ -3115,8 +3115,11 @@ bool Rtabmap::process(
// Map correction (/map -> /odom) // Map correction (/map -> /odom)
statistics_.addStatistic(Statistics::kLoopMap_correction_norm(), _mapCorrection.getNorm()); statistics_.addStatistic(Statistics::kLoopMap_correction_norm(), _mapCorrection.getNorm());
float roll,pitch,yaw; float x,y,z,roll,pitch,yaw;
_mapCorrection.getEulerAngles(roll, pitch, yaw); _mapCorrection.getTranslationAndEulerAngles(x, y, z, roll, pitch, yaw);
statistics_.addStatistic(Statistics::kLoopMap_correction_x(), x);
statistics_.addStatistic(Statistics::kLoopMap_correction_y(), y);
statistics_.addStatistic(Statistics::kLoopMap_correction_z(), z);
statistics_.addStatistic(Statistics::kLoopMap_correction_roll(), roll*180/M_PI); statistics_.addStatistic(Statistics::kLoopMap_correction_roll(), roll*180/M_PI);
statistics_.addStatistic(Statistics::kLoopMap_correction_pitch(), pitch*180/M_PI); statistics_.addStatistic(Statistics::kLoopMap_correction_pitch(), pitch*180/M_PI);
statistics_.addStatistic(Statistics::kLoopMap_correction_yaw(), yaw*180/M_PI); statistics_.addStatistic(Statistics::kLoopMap_correction_yaw(), yaw*180/M_PI);

View File

@@ -51,6 +51,7 @@ void showUsage()
"rtabmap-report [\"Statistic/Id\"] [options] path\n" "rtabmap-report [\"Statistic/Id\"] [options] path\n"
#else #else
"rtabmap-report [options] path\n" "rtabmap-report [options] path\n"
"[Not built with Qt, statistics cannot be plotted]\n"
#endif #endif
" path Directory containing rtabmap databases or path of a database.\n" " path Directory containing rtabmap databases or path of a database.\n"
" Options:" " Options:"
@@ -62,6 +63,9 @@ void showUsage()
" and compute error based on the scaled path.\n" " and compute error based on the scaled path.\n"
" --poses Export poses to [path]_poses.txt, ground truth to [path]_gt.txt\n" " --poses Export poses to [path]_poses.txt, ground truth to [path]_gt.txt\n"
" and valid ground truth indices to [path]_indices.txt \n" " and valid ground truth indices to [path]_indices.txt \n"
#ifdef WITH_QT
" --stats Show available statistics to plot (if path is a file). \n"
#endif
" --report Export all statistics values in report.txt \n\n"); " --report Export all statistics values in report.txt \n\n");
exit(1); exit(1);
} }
@@ -86,6 +90,7 @@ int main(int argc, char * argv[])
bool outputRelativeError = false; bool outputRelativeError = false;
bool outputReport = false; bool outputReport = false;
bool outputLoopAccuracy = false; bool outputLoopAccuracy = false;
bool showAvailableStats = false;
#ifdef WITH_QT #ifdef WITH_QT
std::map<std::string, UPlot*> figures; std::map<std::string, UPlot*> figures;
#endif #endif
@@ -119,6 +124,10 @@ int main(int argc, char * argv[])
{ {
outputReport = true; outputReport = true;
} }
else if(strcmp(argv[i],"--stats") == 0)
{
showAvailableStats = true;
}
else else
{ {
#ifdef WITH_QT #ifdef WITH_QT
@@ -222,6 +231,32 @@ int main(int argc, char * argv[])
float maxOdomRAM = -1; float maxOdomRAM = -1;
float maxMapRAM = -1; float maxMapRAM = -1;
#ifdef WITH_QT #ifdef WITH_QT
if(currentPathIsDatabase && showAvailableStats)
{
std::map<std::string, int> availableStats;
for(std::set<int>::iterator iter=ids.begin(); iter!=ids.end(); ++iter)
{
for(std::map<std::string, float>::iterator jter=stats.at(*iter).first.begin(); jter!=stats.at(*iter).first.end(); ++jter)
{
if(availableStats.find(jter->first) != availableStats.end())
{
++availableStats.at(jter->first);
}
else
{
availableStats.insert(std::make_pair(jter->first, 1));
}
}
}
printf("Showing available statistics in \"%s\":\n", filePath.c_str());
for(std::map<std::string, int>::iterator iter=availableStats.begin(); iter!=availableStats.end(); ++iter)
{
printf("%s (%d)\n", iter->first.c_str(), iter->second);
}
printf("\n");
exit(1);
}
std::map<std::string, UPlotCurve*> curves; std::map<std::string, UPlotCurve*> curves;
std::map<std::string, double> firstStamps; std::map<std::string, double> firstStamps;
for(std::map<std::string, UPlot*>::iterator iter=figures.begin(); iter!=figures.end(); ++iter) for(std::map<std::string, UPlot*>::iterator iter=figures.begin(); iter!=figures.end(); ++iter)