apps
sm-cli
sm-cli-cut.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
printCommandsCut
(
bool
showErrorMsg);
16
17
int
commandCut
()
18
{
19
const
auto
& lstCmds =
cli
->argCmd.getValue();
20
if
(
cli
->argHelp.isSet())
return
printCommandsCut
(
false
);
21
if
(lstCmds.size() != 2 || !
cli
->arg_from.isSet() || !
cli
->arg_to.isSet() ||
22
!
cli
->arg_output.isSet())
23
return
printCommandsCut
(
true
);
24
25
// Take second unlabeled argument:
26
const
std::string
file = lstCmds.at(1);
27
28
const
mrpt::maps::CSimpleMap sm =
read_input_sm_from_cli
(file);
29
30
const
auto
idxFirst =
cli
->arg_from.getValue();
31
const
auto
idxLast =
cli
->arg_to.getValue();
32
33
ASSERT_LT_(idxFirst, sm.size());
34
ASSERT_LT_(idxLast, sm.size());
35
36
mrpt::maps::CSimpleMap outSM;
37
38
for
(
size_t
i = idxFirst; i <= idxLast; i++)
//
39
outSM.insert(sm.get(i));
40
41
const
auto
outFil =
cli
->arg_output.getValue();
42
43
std::cout <<
"Writing cut simplemap with "
<< outSM.size()
44
<<
" keyframes to '"
<< outFil <<
"'"
<< std::endl;
45
46
outSM.saveToFile(outFil);
47
48
return
0;
49
}
50
51
int
printCommandsCut
(
bool
showErrorMsg)
52
{
53
if
(showErrorMsg)
54
{
55
setConsoleErrorColor
();
56
std::cerr <<
"Error: missing or unknown subcommand.\n"
;
57
setConsoleNormalColor
();
58
}
59
60
fprintf(
61
stderr,
62
R
"XXX(Usage:
63
64
sm-cli cut <filename> --from <FIRST_KF_INDEX> --to <LAST_KF_INDEX> --output <OUTPUT.simplemap>
65
66
)XXX");
67
68
return
showErrorMsg ? 1 : 0;
69
}
cli
std::unique_ptr< cli_flags > cli
Definition:
sm-cli-main.cpp:29
commandCut
int commandCut()
Definition:
sm-cli-cut.cpp:17
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
setConsoleErrorColor
void setConsoleErrorColor()
Definition:
sm-cli-main.cpp:43
printCommandsCut
static int printCommandsCut(bool showErrorMsg)
Definition:
sm-cli-cut.cpp:51
mp2p_icp
Author(s):
autogenerated on Wed Oct 23 2024 02:45:41