Skip to content

Commit

Permalink
rtabmap-info: added --dump ini option
Browse files Browse the repository at this point in the history
  • Loading branch information
matlabbe committed Sep 8, 2023
1 parent fa4a2eb commit 01c2e70
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions tools/Info/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include <stdio.h>
#include <string.h>
#include <string.h>
#include <stdlib.h>
#include <signal.h>

Expand Down Expand Up @@ -59,6 +59,7 @@ void showUsage()
" Options:\n"
" --diff Show only modified parameters.\n"
" --diff \"other_map.db\" Compare parameters with other database.\n"
" --dump \"config.ini\" Dump parameters in ini file.\n"
"\n");
exit(1);
}
Expand All @@ -81,19 +82,33 @@ int main(int argc, char * argv[])
}

std::string otherDatabasePath;
std::string dumpFilePath;
bool diff = false;
for(int i=1; i<argc-1; ++i)
{
if(strcmp(argv[i], "--diff") == 0)
{
++i;
if(i<argc-1)
if(i<argc-1 && argv[i][0] != '-')
{
otherDatabasePath = uReplaceChar(argv[i], '~', UDirectory::homeDir());
printf("Comparing with other database \"%s\"...\n", otherDatabasePath.c_str());
}
diff = true;
}
if(strcmp(argv[i], "--dump") == 0)
{
++i;
if(i<argc-1)
{
dumpFilePath = uReplaceChar(argv[i], '~', UDirectory::homeDir());
}
else
{
printf("--dump should have an output file path\n");
showUsage();
}
}
}

std::string databasePath = uReplaceChar(argv[argc-1], '~', UDirectory::homeDir());
Expand All @@ -112,6 +127,12 @@ int main(int argc, char * argv[])
}

ParametersMap parameters = driver->getLastParameters();
if(!dumpFilePath.empty())
{
Parameters::writeINI(dumpFilePath, parameters);
printf("%ld parameters exported to \"%s\".\n", parameters.size(), dumpFilePath.c_str());
return 0;
}
ParametersMap defaultParameters = Parameters::getDefaultParameters();
ParametersMap removedParameters = Parameters::getBackwardCompatibilityMap();
std::string otherDatabasePathName;
Expand Down

0 comments on commit 01c2e70

Please sign in to comment.