Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion apps/icp-log-viewer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <mrpt/3rdparty/tclap/CmdLine.h>
#include <mrpt/config.h>
#include <mrpt/config/CConfigFile.h>
#include <mrpt/core/Clock.h>
#include <mrpt/core/round.h>
#include <mrpt/opengl/CEllipsoid3D.h>
#include <mrpt/opengl/CGridPlaneXY.h>
Expand Down Expand Up @@ -470,7 +471,10 @@ void main_show_gui()
{
return;
}
m.save_to_file(outFile);
if (bool ok = m.save_to_file(outFile); !ok)
{
std::cerr << "Error saving file: " << outFile << "\n";
}
};

// tab 2: variables
Expand Down
17 changes: 14 additions & 3 deletions apps/kitti2mm/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ int main(int argc, char** argv)
try
{
// Parse arguments:
if (!cmd.parse(argc, argv)) return 1; // should exit.
if (!cmd.parse(argc, argv))
{
return 1; // should exit.
}

const auto& f = argInput.getValue();

Expand All @@ -62,11 +65,19 @@ int main(int argc, char** argv)
mp2p_icp::metric_map_t mm;
mm.layers["raw"] = std::move(obs->pointcloud);

if (argID.isSet()) mm.id = argID.getValue();
if (argLabel.isSet()) mm.label = argLabel.getValue();
if (argID.isSet())
{
mm.id = argID.getValue();
}
if (argLabel.isSet())
{
mm.label = argLabel.getValue();
}

if (!mm.save_to_file(argOutput.getValue()))
{
THROW_EXCEPTION_FMT("Error writing to target file '%s'", argOutput.getValue().c_str());
}
}
catch (const std::exception& e)
{
Expand Down
2 changes: 1 addition & 1 deletion apps/mm-filter/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ int main(int argc, char** argv)
}
catch (const std::exception& e)
{
std::cerr << e.what();
std::cerr << e.what() << std::endl;
return 1;
}
return 0;
Expand Down
8 changes: 6 additions & 2 deletions apps/mm-georef/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,11 @@ void run_mm_inject(Cli& cli)

std::cout << "[mm-georef] Saving updated map to: '" << filMap << "'..." << std::endl;

mm.save_to_file(filMap);
bool ok = mm.save_to_file(filMap);
if (!ok)
{
THROW_EXCEPTION_FMT("Error saving updated map to file: '%s'", filMap.c_str());
}
}

void run_mm_georef(Cli& cli)
Expand Down Expand Up @@ -196,7 +200,7 @@ int main(int argc, char** argv)
}
catch (const std::exception& e)
{
std::cerr << e.what();
std::cerr << e.what() << std::endl;
return 1;
}
return 0;
Expand Down
8 changes: 6 additions & 2 deletions apps/mm-info/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <mp2p_icp/metricmap.h>
#include <mrpt/3rdparty/tclap/CmdLine.h>
#include <mrpt/containers/yaml.h>
#include <mrpt/core/Clock.h>
#include <mrpt/system/filesystem.h>

// CLI flags:
Expand All @@ -40,11 +41,14 @@ void run_mm_info()
ASSERT_FILE_EXISTS_(argMapFile.getValue());

std::cout << "[mm-info] Reading input map from: '" << filInput << "'..." << std::endl;
const double mm_t0 = mrpt::Clock::nowDouble();

mp2p_icp::metric_map_t mm;
mm.load_from_file(filInput);

std::cout << "[mm-info] Done read map. Contents:\n" << mm.contents_summary() << std::endl;
const double mm_t1 = mrpt::Clock::nowDouble();
std::cout << "[mm-info] Done read map in " << (mm_t1 - mm_t0) << " sec. Contents:\n"
<< mm.contents_summary() << std::endl;
}

int main(int argc, char** argv)
Expand All @@ -61,7 +65,7 @@ int main(int argc, char** argv)
}
catch (const std::exception& e)
{
std::cerr << e.what();
std::cerr << e.what() << std::endl;
return 1;
}
return 0;
Expand Down
8 changes: 6 additions & 2 deletions apps/mm2txt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <mp2p_icp/metricmap.h>
#include <mrpt/3rdparty/tclap/CmdLine.h>
#include <mrpt/containers/yaml.h>
#include <mrpt/core/Clock.h>
#include <mrpt/maps/CGenericPointsMap.h>
#include <mrpt/system/filesystem.h>
#include <mrpt/system/os.h>
Expand Down Expand Up @@ -207,11 +208,14 @@ void run_mm2txt()
ASSERT_FILE_EXISTS_(argMapFile.getValue());

std::cout << "[mm-info] Reading input map from: '" << filInput << "'..." << std::endl;
const double mm_t0 = mrpt::Clock::nowDouble();

mp2p_icp::metric_map_t mm;
mm.load_from_file(filInput);

std::cout << "[mm-info] Done read map. Contents:\n" << mm.contents_summary() << std::endl;
const double mm_t1 = mrpt::Clock::nowDouble();
std::cout << "[mm-info] Done read map in " << (mm_t1 - mm_t0) << " sec. Contents:\n"
<< mm.contents_summary() << "\n";

std::vector<std::string> layers;
if (argLayers.isSet())
Expand Down Expand Up @@ -413,7 +417,7 @@ int main(int argc, char** argv)
}
catch (const std::exception& e)
{
std::cerr << e.what();
std::cerr << e.what() << std::endl;
return 1;
}
return 0;
Expand Down
19 changes: 16 additions & 3 deletions apps/rawlog-filter/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,21 @@
#include <mp2p_icp_filters/Generator.h>
#include <mrpt/3rdparty/tclap/CmdLine.h>
#include <mrpt/containers/yaml.h>
#include <mrpt/io/CFileGZOutputStream.h>
#include <mrpt/core/Clock.h>
#include <mrpt/io/lazy_load_path.h>
#include <mrpt/obs/CObservationPointCloud.h>
#include <mrpt/obs/CRawlog.h>
#include <mrpt/obs/CSensoryFrame.h>
#include <mrpt/serialization/CArchive.h>
#include <mrpt/system/filesystem.h>
#include <mrpt/system/progress.h>
#include <mrpt/version.h>

#if MRPT_VERSION >= 0x020f07
#include <mrpt/io/CCompressedOutputStream.h>
#else
#include <mrpt/io/CFileGZOutputStream.h>
#endif

// CLI flags:
struct Cli
Expand Down Expand Up @@ -174,8 +181,14 @@ void run_mm_filter(Cli& cli)
const auto filOut = cli.argOutput.getValue();
std::cout << "[rawlog-filter] Creating output rawlog file: '" << filOut << "'..." << std::endl;

#if MRPT_VERSION >= 0x020f07
mrpt::io::CCompressedOutputStream fo(
filOut, mrpt::io::OpenMode::TRUNCATE, {mrpt::io::CompressionType::Zstd});
#else
mrpt::io::CFileGZOutputStream fo(filOut);
auto outArch = mrpt::serialization::archiveFrom(fo);
#endif

auto outArch = mrpt::serialization::archiveFrom(fo);

if (cli.arg_lazy_load_base_dir.isSet())
{
Expand Down Expand Up @@ -260,7 +273,7 @@ int main(int argc, char** argv)
}
catch (const std::exception& e)
{
std::cerr << e.what();
std::cerr << e.what() << std::endl;
return 1;
}
return 0;
Expand Down
40 changes: 38 additions & 2 deletions apps/sm2mm/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@
#include <mp2p_icp_filters/sm2mm.h>
#include <mrpt/3rdparty/tclap/CmdLine.h>
#include <mrpt/containers/yaml.h>
#include <mrpt/core/Clock.h>
#include <mrpt/io/lazy_load_path.h>
#include <mrpt/system/COutputLogger.h>
#include <mrpt/system/filesystem.h>
#include <mrpt/version.h>

#if MRPT_VERSION >= 0x020f07
#include <mrpt/io/compression_options.h>
#endif

// CLI flags:
struct CLI
Expand Down Expand Up @@ -66,6 +72,19 @@ struct CLI
"v", "verbosity", "Verbosity level: ERROR|WARN|INFO|DEBUG (Default: INFO)", false, "",
"INFO", cmd};

#if MRPT_VERSION >= 0x020f07
TCLAP::ValueArg<std::string> arg_compression_method{
"",
"compression-method",
"Compression method to use in the output metric map .mm file. "
"Options: CompressionType::None|CompressionType::Gzip|CompressionType::Zstd. (Default: "
"CompressionType::Zstd)",
false,
"CompressionType::Zstd",
"METHOD",
cmd};
#endif
Comment thread
jlblancoc marked this conversation as resolved.

TCLAP::ValueArg<std::string> arg_lazy_load_base_dir{
"",
"externals-dir",
Expand Down Expand Up @@ -117,10 +136,14 @@ void run_sm_to_mm(CLI& cli)
mrpt::maps::CSimpleMap sm;

std::cout << "[sm2mm] Reading simplemap from: '" << filSM << "'..." << std::endl;
const double sm_t0 = mrpt::Clock::nowDouble();

sm.loadFromFile(filSM);

std::cout << "[sm2mm] Done read simplemap with " << sm.size() << " keyframes." << std::endl;
const double sm_t1 = mrpt::Clock::nowDouble();
std::cout << "[sm2mm] Done read simplemap with " << sm.size() << " keyframes in "
<< (sm_t1 - sm_t0) << " sec.\n";

ASSERT_(!sm.empty());

// Load pipeline from YAML file:
Expand Down Expand Up @@ -194,7 +217,20 @@ void run_sm_to_mm(CLI& cli)
const auto filOut = cli.argOutput.getValue();
std::cout << "[sm2mm] Writing metric map to: '" << filOut << "'..." << std::endl;

#if MRPT_VERSION >= 0x020f07
mrpt::io::CompressionOptions compOpts{mrpt::io::CompressionType::Zstd, 3 /*default level*/};
if (cli.arg_compression_method.isSet())
{
using ct = mrpt::typemeta::TEnumType<mrpt::io::CompressionType>;
compOpts.type = ct::name2value(cli.arg_compression_method.getValue());
}
#endif

#if MRPT_VERSION >= 0x020f07
if (!mm.save_to_file(filOut, compOpts))
#else
if (!mm.save_to_file(filOut))
#endif
{
THROW_EXCEPTION_FMT("Error writing to target file '%s'", filOut.c_str());
}
Expand All @@ -216,7 +252,7 @@ int main(int argc, char** argv)
}
catch (const std::exception& e)
{
std::cerr << e.what();
std::cerr << e.what() << std::endl;
return 1;
}
return 0;
Expand Down
11 changes: 8 additions & 3 deletions docs/source/app_sm2mm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ CLI Reference

sm2mm [--decimate-max <N>] [--decimate-nth <N>] [--to-index <0>]
[--from-index <0>] [--profiler] [--no-progress-bar]
[--externals-dir <<ExternalsDirectory>>] [-v <INFO>] [-p
<pipeline.yaml>] [-l <foobar.so>] -o <out.mm> -i <map.simplemap>
[--] [--version] [-h]
[--externals-dir <<ExternalsDirectory>>] [--compression-method
<METHOD>] [-v <INFO>] [-p <pipeline.yaml>] [-l <foobar.so>] -o
<out.mm> -i <map.simplemap> [--] [--version] [-h]


Where:
Expand Down Expand Up @@ -65,6 +65,11 @@ CLI Reference
Lazy-load base directory for datasets with externally-stored
observations

--compression-method <METHOD>
Compression method to use in the output metric map .mm file. Options:
CompressionType::None|CompressionType::Gzip|CompressionType::Zstd.
(Default: CompressionType::Zstd)

-v <INFO>, --verbosity <INFO>
Verbosity level: ERROR|WARN|INFO|DEBUG (Default: INFO)

Expand Down
14 changes: 11 additions & 3 deletions mp2p_icp/include/mp2p_icp/LogRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
#include <mp2p_icp/Results.h>
#include <mp2p_icp/metricmap.h>
#include <mrpt/serialization/CSerializable.h>
#if MRPT_VERSION >= 0x020f07
#include <mrpt/io/compression_options.h>
#endif

#include <optional>

Expand All @@ -40,8 +43,7 @@ class LogRecord : public mrpt::serialization::CSerializable
DEFINE_SERIALIZABLE(LogRecord, mp2p_icp)

public:
LogRecord() = default;
~LogRecord() = default;
LogRecord() = default;

/** @name Data fields
* @{ */
Expand Down Expand Up @@ -79,7 +81,13 @@ class LogRecord : public mrpt::serialization::CSerializable
* using on-the-fly GZIP compression.
* \return true on success.
*/
bool save_to_file(const std::string& fileName) const;
#if MRPT_VERSION >= 0x020f07
[[nodiscard]] bool save_to_file(
const std::string& fileName,
const mrpt::io::CompressionOptions& co = {mrpt::io::CompressionType::Zstd}) const;
#else
[[nodiscard]] bool save_to_file(const std::string& fileName) const;
#endif

/** Loads the record object from a file. See \save_to_file()
* \return true on success.
Expand Down
Loading