MRPT
2.0.1
test.cpp
Go to the documentation of this file.
1
/* +------------------------------------------------------------------------+
2
| Mobile Robot Programming Toolkit (MRPT) |
3
| https://www.mrpt.org/ |
4
| |
5
| Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6
| See: https://www.mrpt.org/Authors - All rights reserved. |
7
| Released under BSD License. See: https://www.mrpt.org/License |
8
+------------------------------------------------------------------------+ */
9
10
#include <
mrpt/core/exceptions.h
>
11
#include <
mrpt/system/TParameters.h
>
12
#include <iostream>
13
14
using namespace
std
;
15
using namespace
mrpt::system
;
16
17
void
MyCoolFunction
(
const
TParametersDouble
&
params
)
18
{
19
cout <<
"'threshold' is "
<<
params
[
"threshold"
] << endl;
20
cout <<
"Is 'altitude' set? "
<<
params
.has(
"altitude"
) << endl;
21
cout <<
"Is 'level' set? "
<<
params
.has(
"level"
) << endl;
22
cout <<
"Level is : "
<<
params
.getWithDefaultVal(
"level"
, 666.0) << endl;
23
cout <<
"Dump of all params:\n"
<<
params
.getAsString() << endl;
24
cout << endl;
25
}
26
27
// ------------------------------------------------------
28
// TestParameters
29
// ------------------------------------------------------
30
void
TestParameters
()
31
{
32
{
33
// Call #1
34
cout <<
"CALL #1 ================================\n"
;
35
TParametersDouble
p;
36
p[
"threshold"
] = 3.05;
37
p[
"altitude"
] = 100;
38
39
MyCoolFunction
(p);
40
}
41
42
{
43
// Call #2
44
cout <<
"CALL #2 ================================\n"
;
45
// clang-format off
46
TParametersDouble
p(
47
{
48
{
"threshold"
, 3.05},
49
{
"altitude"
, 100.0},
50
{
"level"
, -1.0}
51
}
52
);
53
// clang-format on
54
55
MyCoolFunction
(p);
56
}
57
}
58
59
int
main
()
60
{
61
try
62
{
63
TestParameters
();
64
return
0;
65
}
66
catch
(
const
std::exception& e)
67
{
68
std::cerr <<
"MRPT error: "
<<
mrpt::exception_to_str
(e) << std::endl;
69
return
-1;
70
}
71
}
MyCoolFunction
void MyCoolFunction(const TParametersDouble ¶ms)
Definition:
vision_stereo_rectify/test.cpp:17
TestParameters
void TestParameters()
Definition:
vision_stereo_rectify/test.cpp:30
mrpt::system
Definition:
backtrace.h:14
params
mrpt::vision::TStereoCalibParams params
Definition:
chessboard_stereo_camera_calib_unittest.cpp:24
std
STL namespace.
main
int main()
Definition:
vision_stereo_rectify/test.cpp:78
exceptions.h
TParameters.h
mrpt::exception_to_str
std::string exception_to_str(const std::exception &e)
Builds a nice textual representation of a nested exception, which if generated using MRPT macros (THR...
Definition:
exceptions.cpp:59
mrpt::system::TParameters< double >
Page generated by
Doxygen 1.8.14
for MRPT 2.0.1 Git: 0fef1a6d7 Fri Apr 3 23:00:21 2020 +0200 at vie abr 3 23:20:28 CEST 2020