Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
wolf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile_robotics
wolf_projects
wolf_lib
wolf
Commits
c137c311
Commit
c137c311
authored
6 years ago
by
Joan Vallvé Navarro
Browse files
Options
Downloads
Patches
Plain Diff
gtest_yaml_conversions
parent
d9d59b5a
No related branches found
No related tags found
1 merge request
!278
Resolve "Revisit demos (formerly called examples) and update them"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/CMakeLists.txt
+4
-0
4 additions, 0 deletions
test/CMakeLists.txt
test/gtest_yaml_conversions.cpp
+29
-14
29 additions, 14 deletions
test/gtest_yaml_conversions.cpp
with
33 additions
and
14 deletions
test/CMakeLists.txt
+
4
−
0
View file @
c137c311
...
...
@@ -190,6 +190,10 @@ target_link_libraries(gtest_odom_2D ${PROJECT_NAME})
wolf_add_gtest
(
gtest_processor_odom_3D gtest_processor_odom_3D.cpp
)
target_link_libraries
(
gtest_processor_odom_3D
${
PROJECT_NAME
}
)
# yaml conversions
wolf_add_gtest
(
gtest_yaml_conversions gtest_yaml_conversions.cpp
)
target_link_libraries
(
gtest_yaml_conversions
${
PROJECT_NAME
}
)
# ------- Now Core classes Serialization ----------
add_subdirectory
(
serialization
)
...
...
This diff is collapsed.
Click to expand it.
demos/demo
_yaml_conversions.cpp
→
test/gtest
_yaml_conversions.cpp
+
29
−
14
View file @
c137c311
...
...
@@ -5,19 +5,23 @@
* \author: jsola
*/
#include
"core/common/wolf.h"
#include
"core/utils/utils_gtest.h"
#include
"core/yaml/yaml_conversion.h"
#include
<yaml-cpp/yaml.h>
#include
<eigen3/Eigen/Dense>
#include
<iostream>
//#include <fstream>
int
main
()
{
using
namespace
Eigen
;
using
namespace
wolf
;
using
namespace
Eigen
;
TEST
(
MapYaml
,
save_2D
)
{
MatrixXs
M23
(
2
,
3
);
MatrixXs
M33
(
3
,
3
);
M23
<<
1
,
2
,
3
,
4
,
5
,
6
;
M33
<<
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
;
std
::
cout
<<
"
\n
Trying different yaml specs for matrix..."
<<
std
::
endl
;
...
...
@@ -29,26 +33,37 @@ int main()
mat_23
=
YAML
::
Load
(
"[1, 2, 3, 4, 5, 6]"
);
// insensitive to spacing
mat_33
=
YAML
::
Load
(
"[1, 2, 3, 4, 5, 6, 7, 8, 9]"
);
// insensitive to spacing
MatrixX
d
Mx
=
mat_sized_23
.
as
<
MatrixX
d
>
();
MatrixX
s
Mx
=
mat_sized_23
.
as
<
MatrixX
s
>
();
std
::
cout
<<
"Dyn-Dyn [[2,3] ,[1, 2, 3, 4, 5, 6] ] =
\n
"
<<
Mx
<<
std
::
endl
;
ASSERT_MATRIX_APPROX
(
Mx
,
M23
,
1e-12
);
Matrix
<
double
,
2
,
Dynamic
>
M2D
=
mat_sized_23
.
as
<
Matrix
<
double
,
2
,
Dynamic
>>
();
Matrix
<
Scalar
,
2
,
Dynamic
>
M2D
=
mat_sized_23
.
as
<
Matrix
<
Scalar
,
2
,
Dynamic
>>
();
std
::
cout
<<
"2-Dyn [[2,3] ,[1, 2, 3, 4, 5, 6] ] =
\n
"
<<
M2D
<<
std
::
endl
;
ASSERT_MATRIX_APPROX
(
M2D
,
M23
,
1e-12
);
Matrix
<
double
,
Dynamic
,
3
>
MD3
=
mat_sized_23
.
as
<
Matrix
<
double
,
Dynamic
,
3
>>
();
Matrix
<
Scalar
,
Dynamic
,
3
>
MD3
=
mat_sized_23
.
as
<
Matrix
<
Scalar
,
Dynamic
,
3
>>
();
std
::
cout
<<
"Dyn-3 [[2,3] ,[1, 2, 3, 4, 5, 6] ] =
\n
"
<<
MD3
<<
std
::
endl
;
ASSERT_MATRIX_APPROX
(
MD3
,
M23
,
1e-12
);
Matrix3
d
M3
=
mat_sized_33
.
as
<
Matrix3
d
>
();
Matrix3
s
M3
=
mat_sized_33
.
as
<
Matrix3
s
>
();
std
::
cout
<<
"3-3 [[3,3] ,[1, 2, 3, 4, 5, 6, 7, 8, 9] ] =
\n
"
<<
M3
<<
std
::
endl
;
ASSERT_MATRIX_APPROX
(
M3
,
M33
,
1e-12
);
M2D
=
mat_23
.
as
<
Matrix
<
double
,
2
,
Dynamic
>>
();
M2D
=
mat_23
.
as
<
Matrix
<
Scalar
,
2
,
Dynamic
>>
();
std
::
cout
<<
"2-Dyn [1, 2, 3, 4, 5, 6] =
\n
"
<<
M2D
<<
std
::
endl
;
ASSERT_MATRIX_APPROX
(
M2D
,
M23
,
1e-12
);
MD3
=
mat_23
.
as
<
Matrix
<
double
,
Dynamic
,
3
>>
();
MD3
=
mat_23
.
as
<
Matrix
<
Scalar
,
Dynamic
,
3
>>
();
std
::
cout
<<
"Dyn-3 [1, 2, 3, 4, 5, 6] =
\n
"
<<
MD3
<<
std
::
endl
;
ASSERT_MATRIX_APPROX
(
MD3
,
M23
,
1e-12
);
M3
=
mat_33
.
as
<
Matrix3
d
>
();
M3
=
mat_33
.
as
<
Matrix3
s
>
();
std
::
cout
<<
"3-3 [1, 2, 3, 4, 5, 6, 7, 8, 9] =
\n
"
<<
M3
<<
std
::
endl
;
ASSERT_MATRIX_APPROX
(
M3
,
M33
,
1e-12
);
}
return
0
;
int
main
(
int
argc
,
char
**
argv
)
{
testing
::
InitGoogleTest
(
&
argc
,
argv
);
return
RUN_ALL_TESTS
();
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment