apps
sm-cli
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
17
int
commandJoin
()
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())
22
return
printCommandsJoin
(
true
);
23
24
// Take second unlabeled argument:
25
mrpt::maps::CSimpleMap outSM;
26
27
for
(
size_t
i = 1; i < lstCmds.size(); i++)
28
{
29
const
std::string
file = lstCmds.at(i);
30
mrpt::maps::CSimpleMap sm =
read_input_sm_from_cli
(file);
31
32
for
(
size_t
k = 0; k < sm.size(); k++)
33
{
34
const
auto
kf = sm.get(k);
35
outSM.insert(kf);
36
}
37
}
38
39
const
auto
outFil =
cli
->arg_output.getValue();
40
41
std::cout <<
"Writing merged simplemap with "
<< outSM.size()
42
<<
" keyframes to '"
<< outFil <<
"'"
<< std::endl;
43
44
outSM.saveToFile(outFil);
45
46
return
0;
47
}
48
49
int
printCommandsJoin
(
bool
showErrorMsg)
50
{
51
if
(showErrorMsg)
52
{
53
setConsoleErrorColor
();
54
std::cerr <<
"Error: missing or unknown subcommand.\n"
;
55
setConsoleNormalColor
();
56
}
57
58
fprintf(
59
stderr,
60
R
"XXX(Usage:
61
62
sm-cli join <filename_1> [<filename_2> ...] --output <MERGED.simplemap>
63
64
)XXX");
65
66
return
showErrorMsg ? 1 : 0;
67
}
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:119
sm-cli.h
setConsoleNormalColor
void setConsoleNormalColor()
Definition:
sm-cli-main.cpp:49
printCommandsJoin
static int printCommandsJoin(bool showErrorMsg)
Definition:
sm-cli-join.cpp:49
setConsoleErrorColor
void setConsoleErrorColor()
Definition:
sm-cli-main.cpp:43
commandJoin
int commandJoin()
Definition:
sm-cli-join.cpp:17
mp2p_icp
Author(s):
autogenerated on Wed Oct 23 2024 02:45:41