sm-cli-join.cpp
Go to the documentation of this file.
1 /*+-------------------------------------------------------------------------+
2  | MultiVehicle simulator (libmvsim) |
3  | |
4  | Copyright (C) 2014-2023 Jose Luis Blanco Claraco |
5  | Copyright (C) 2017 Borys Tymchenko (Odessa Polytechnic University) |
6  | Distributed under 3-clause BSD License |
7  | See COPYING |
8  +-------------------------------------------------------------------------+ */
9 
10 #include <mrpt/core/exceptions.h>
11 #include <mrpt/maps/CSimpleMap.h>
12 
13 #include "sm-cli.h"
14 
15 static int printCommandsJoin(bool showErrorMsg);
16 
18 {
19  const auto& lstCmds = cli->argCmd.getValue();
20  if (cli->argHelp.isSet()) return printCommandsJoin(false);
21  if (lstCmds.size() < 2 || !cli->arg_output.isSet()) return printCommandsJoin(true);
22 
23  // Take second unlabeled argument:
24  mrpt::maps::CSimpleMap outSM;
25 
26  for (size_t i = 1; i < lstCmds.size(); i++)
27  {
28  const std::string file = lstCmds.at(i);
29  mrpt::maps::CSimpleMap sm = read_input_sm_from_cli(file);
30 
31  for (size_t k = 0; k < sm.size(); k++)
32  {
33  const auto kf = sm.get(k);
34  outSM.insert(kf);
35  }
36  }
37 
38  const auto outFil = cli->arg_output.getValue();
39 
40  std::cout << "Writing merged simplemap with " << outSM.size() << " keyframes to '" << outFil
41  << "'" << std::endl;
42 
43  outSM.saveToFile(outFil);
44 
45  return 0;
46 }
47 
48 int printCommandsJoin(bool showErrorMsg)
49 {
50  if (showErrorMsg)
51  {
53  std::cerr << "Error: missing or unknown subcommand.\n";
55  }
56 
57  fprintf(
58  stderr,
59  R"XXX(Usage:
60 
61  sm-cli join <filename_1> [<filename_2> ...] --output <MERGED.simplemap>
62 
63 )XXX");
64 
65  return showErrorMsg ? 1 : 0;
66 }
cli
std::unique_ptr< cli_flags > cli
Definition: sm-cli-main.cpp:29
testing::internal::string
::std::string string
Definition: gtest.h:1979
read_input_sm_from_cli
mrpt::maps::CSimpleMap read_input_sm_from_cli(const std::string &inFile)
Definition: sm-cli-main.cpp:113
sm-cli.h
setConsoleNormalColor
void setConsoleNormalColor()
Definition: sm-cli-main.cpp:48
printCommandsJoin
static int printCommandsJoin(bool showErrorMsg)
Definition: sm-cli-join.cpp:48
setConsoleErrorColor
void setConsoleErrorColor()
Definition: sm-cli-main.cpp:43
commandJoin
int commandJoin()
Definition: sm-cli-join.cpp:17


mp2p_icp
Author(s):
autogenerated on Mon May 26 2025 02:45:50