apps/kitti2mm/main.cpp
Go to the documentation of this file.
1 /* -------------------------------------------------------------------------
2  * A repertory of multi primitive-to-primitive (MP2P) ICP algorithms in C++
3  * Copyright (C) 2018-2021 Jose Luis Blanco, University of Almeria
4  * See LICENSE for license information.
5  * ------------------------------------------------------------------------- */
6 
14 #include <mp2p_icp/metricmap.h>
15 #include <mrpt/3rdparty/tclap/CmdLine.h>
16 #include <mrpt/maps/CSimplePointsMap.h>
17 #include <mrpt/obs/CObservationPointCloud.h>
18 #include <mrpt/system/filesystem.h>
19 
20 // CLI flags:
21 static TCLAP::CmdLine cmd("kitti2mm");
22 
23 static TCLAP::ValueArg<std::string> argInput(
24  "i", "input", "KITTI .bin pointcloud file.", true, "kitti-00.bin",
25  "kitti-00.bin", cmd);
26 
27 static TCLAP::ValueArg<std::string> argOutput(
28  "o", "output", "Output file to write to.", true, "out.mm", "out.mm", cmd);
29 
30 static TCLAP::ValueArg<std::string> argLayer(
31  "l", "layer", "Target layer name (Default: \"raw\").", false, "raw", "raw",
32  cmd);
33 
34 static TCLAP::ValueArg<uint64_t> argID(
35  "", "id", "Metric map numeric ID (Default: none).", false, 0, "[ID]", cmd);
36 
37 static TCLAP::ValueArg<std::string> argLabel(
38  "", "label", "Metric map label string (Default: none).", false, "label",
39  "[label]", cmd);
40 
41 int main(int argc, char** argv)
42 {
43  try
44  {
45  // Parse arguments:
46  if (!cmd.parse(argc, argv)) return 1; // should exit.
47 
48  const auto& f = argInput.getValue();
49 
50  auto obs = mrpt::obs::CObservationPointCloud::Create();
51  obs->setAsExternalStorage(
52  f, mrpt::obs::CObservationPointCloud::ExternalStorageFormat::
53  KittiBinFile);
54  obs->load(); // force loading now from disk
55  ASSERTMSG_(
56  obs->pointcloud,
57  mrpt::format("Error loading kitti scan file: '%s'", f.c_str()));
58 
59  // Save as mm file:
61  mm.layers["raw"] = std::move(obs->pointcloud);
62 
63  if (argID.isSet()) mm.id = argID.getValue();
64  if (argLabel.isSet()) mm.label = argLabel.getValue();
65 
66  if (!mm.save_to_file(argOutput.getValue()))
67  THROW_EXCEPTION_FMT(
68  "Error writing to target file '%s'",
69  argOutput.getValue().c_str());
70  }
71  catch (const std::exception& e)
72  {
73  std::cerr << mrpt::exception_to_str(e);
74  return 1;
75  }
76  return 0;
77 }
argLayer
static TCLAP::ValueArg< std::string > argLayer("l", "layer", "Target layer name (Default: \"raw\").", false, "raw", "raw", cmd)
kitti-run-seq.f
string f
Definition: kitti-run-seq.py:12
mp2p_icp::metric_map_t::save_to_file
bool save_to_file(const std::string &fileName) const
Definition: metricmap.cpp:421
argInput
static TCLAP::ValueArg< std::string > argInput("i", "input", "KITTI .bin pointcloud file.", true, "kitti-00.bin", "kitti-00.bin", cmd)
mp2p_icp::metric_map_t::label
std::optional< std::string > label
Definition: metricmap.h:95
cmd
static TCLAP::CmdLine cmd("kitti2mm")
argOutput
static TCLAP::ValueArg< std::string > argOutput("o", "output", "Output file to write to.", true, "out.mm", "out.mm", cmd)
argID
static TCLAP::ValueArg< uint64_t > argID("", "id", "Metric map numeric ID (Default: none).", false, 0, "[ID]", cmd)
main
int main(int argc, char **argv)
Definition: apps/kitti2mm/main.cpp:41
metricmap.h
Generic representation of pointcloud(s) and/or extracted features.
mp2p_icp::metric_map_t
Generic container of pointcloud(s), extracted features and other maps.
Definition: metricmap.h:47
mp2p_icp::metric_map_t::id
std::optional< uint64_t > id
Definition: metricmap.h:87
argLabel
static TCLAP::ValueArg< std::string > argLabel("", "label", "Metric map label string (Default: none).", false, "label", "[label]", cmd)
mp2p_icp::metric_map_t::layers
std::map< layer_name_t, mrpt::maps::CMetricMap::Ptr > layers
Definition: metricmap.h:74


mrpt_local_obstacles
Author(s): Jose-Luis Blanco-Claraco
autogenerated on Mon Aug 14 2023 02:09:03