14 #include <mrpt/3rdparty/tclap/CmdLine.h>
15 #include <mrpt/core/exceptions.h>
16 #include <mrpt/system/filesystem.h>
17 #include <mrpt/system/os.h>
20 #include <mrpt/maps/registerAllClasses.h>
21 #include <mrpt/obs/registerAllClasses.h>
29 std::unique_ptr<cli_flags>
cli;
45 mrpt::system::consoleColorAndStyle(
46 mrpt::system::ConsoleForegroundColor::RED);
51 mrpt::system::consoleColorAndStyle(
52 mrpt::system::ConsoleForegroundColor::DEFAULT);
55 int main(
int argc,
char** argv)
59 cli = std::make_unique<cli_flags>();
61 if (!
cli->cmd.parse(argc, argv))
67 if (
cli->argVersion.isSet())
75 if (
const auto& lst =
cli->argCmd.getValue(); !lst.empty())
83 if (!
cli->argHelp.isSet())
86 std::cerr <<
"Error: missing or unknown command.\n";
94 return (itCmd->second)();
96 catch (
const std::exception& e)
98 std::cerr <<
"ERROR: " << mrpt::exception_to_str(e);
108 R
"XXX(sm-cli v%s: CLI tool to manipulate and inspect 'simplemap's.
111 sm-cli cut Cut part of a .simplemap file into a new file.
112 sm-cli export-keyframes Export KF poses (opt: twist too) as TUM format.
113 sm-cli export-rawlog Export KFs as rawlog for inspection.
114 sm-cli info Analyze a .simplemap file.
115 sm-cli join Join two or more .simplemap files into one.
116 sm-cli level Makes a .simplemap file level (horizontal).
117 sm-cli tf Applies a SE(3) transform by the left to a map.
118 sm-cli trim Extracts part of a .simplemap inside a given box.
119 sm-cli --version Shows program version.
120 sm-cli --help Shows this information.
122 Or use `sm-cli <COMMAND> --help` for further options
130 std::cout <<
"sm-cli v" << MP2P_ICP_VERSION << std::endl;
136 ASSERT_FILE_EXISTS_(inFile);
138 const auto sizeBytes = mrpt::system::getFileSize(inFile);
140 std::cout <<
"Loading: '" << inFile <<
"' of "
141 << mrpt::system::unitsFormat(sizeBytes) <<
"B..." << std::endl;
145 mrpt::maps::registerAllClasses_mrpt_maps();
146 mrpt::obs::registerAllClasses_mrpt_obs();
148 mrpt::maps::CSimpleMap sm;
150 bool loadOk = sm.loadFromFile(inFile);