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
a9b3c7d5
Commit
a9b3c7d5
authored
3 years ago
by
Joan Vallvé Navarro
Browse files
Options
Downloads
Patches
Plain Diff
impleentation of SE2::between and gtest
parent
e99ecec1
No related branches found
No related tags found
1 merge request
!440
New tag
Pipeline
#8922
passed
3 years ago
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/core/math/SE2.h
+40
-0
40 additions, 0 deletions
include/core/math/SE2.h
test/CMakeLists.txt
+5
-0
5 additions, 0 deletions
test/CMakeLists.txt
test/gtest_SE2.cpp
+163
-0
163 additions, 0 deletions
test/gtest_SE2.cpp
with
208 additions
and
0 deletions
include/core/math/SE2.h
+
40
−
0
View file @
a9b3c7d5
...
@@ -408,7 +408,47 @@ inline VectorComposite plus(const VectorComposite& x, const VectorComposite& tau
...
@@ -408,7 +408,47 @@ inline VectorComposite plus(const VectorComposite& x, const VectorComposite& tau
return
res
;
return
res
;
}
}
template
<
typename
D1
,
typename
D2
,
typename
D3
>
inline
void
between
(
const
MatrixBase
<
D1
>&
p1
,
const
typename
D1
::
Scalar
&
o1
,
const
MatrixBase
<
D2
>&
p2
,
const
typename
D2
::
Scalar
&
o2
,
MatrixBase
<
D3
>&
p12
,
typename
D3
::
Scalar
&
o12
)
{
MatrixSizeCheck
<
2
,
1
>::
check
(
p1
);
MatrixSizeCheck
<
2
,
1
>::
check
(
p2
);
MatrixSizeCheck
<
2
,
1
>::
check
(
p12
);
p12
=
SO2
::
exp
(
-
o1
)
*
(
p2
-
p1
);
o12
=
o2
-
o1
;
}
template
<
typename
D1
,
typename
D2
,
typename
D3
>
inline
void
between
(
const
MatrixBase
<
D1
>&
d1
,
const
MatrixBase
<
D2
>&
d2
,
MatrixBase
<
D3
>&
d12
)
{
MatrixSizeCheck
<
3
,
1
>::
check
(
d1
);
MatrixSizeCheck
<
3
,
1
>::
check
(
d2
);
MatrixSizeCheck
<
3
,
1
>::
check
(
d12
);
typedef
typename
D1
::
Scalar
T
;
Map
<
const
Matrix
<
T
,
2
,
1
>
>
p1
(
&
d1
(
0
)
);
Map
<
const
Matrix
<
T
,
2
,
1
>
>
p2
(
&
d2
(
0
)
);
Map
<
Matrix
<
T
,
2
,
1
>
>
p12
(
&
d12
(
0
)
);
between
(
p1
,
d1
(
2
),
p2
,
d2
(
2
),
p12
,
d12
(
2
));
}
template
<
typename
D1
,
typename
D2
>
inline
Matrix
<
typename
D1
::
Scalar
,
3
,
1
>
between
(
const
MatrixBase
<
D1
>&
d1
,
const
MatrixBase
<
D2
>&
d2
)
{
MatrixSizeCheck
<
3
,
1
>::
check
(
d1
);
MatrixSizeCheck
<
3
,
1
>::
check
(
d2
);
Matrix
<
typename
D1
::
Scalar
,
3
,
1
>
d12
;
between
(
d1
,
d2
,
d12
);
return
d12
;
}
}
// namespace SE2
}
// namespace SE2
}
// namespacs wolf
}
// namespacs wolf
...
...
This diff is collapsed.
Click to expand it.
test/CMakeLists.txt
+
5
−
0
View file @
a9b3c7d5
...
@@ -126,11 +126,16 @@ target_link_libraries(gtest_processor_motion ${PLUGIN_NAME})
...
@@ -126,11 +126,16 @@ target_link_libraries(gtest_processor_motion ${PLUGIN_NAME})
# Rotation test
# Rotation test
wolf_add_gtest
(
gtest_rotation gtest_rotation.cpp
)
wolf_add_gtest
(
gtest_rotation gtest_rotation.cpp
)
target_link_libraries
(
gtest_rotation
${
PLUGIN_NAME
}
)
# SE3 test
# SE3 test
wolf_add_gtest
(
gtest_SE3 gtest_SE3.cpp
)
wolf_add_gtest
(
gtest_SE3 gtest_SE3.cpp
)
target_link_libraries
(
gtest_SE3
${
PLUGIN_NAME
}
)
target_link_libraries
(
gtest_SE3
${
PLUGIN_NAME
}
)
# SE3 test
wolf_add_gtest
(
gtest_SE2 gtest_SE2.cpp
)
target_link_libraries
(
gtest_SE2
${
PLUGIN_NAME
}
)
# SensorBase test
# SensorBase test
wolf_add_gtest
(
gtest_sensor_base gtest_sensor_base.cpp
)
wolf_add_gtest
(
gtest_sensor_base gtest_sensor_base.cpp
)
target_link_libraries
(
gtest_sensor_base
${
PLUGIN_NAME
}
)
target_link_libraries
(
gtest_sensor_base
${
PLUGIN_NAME
}
)
...
...
This diff is collapsed.
Click to expand it.
test/gtest_SE2.cpp
0 → 100644
+
163
−
0
View file @
a9b3c7d5
//--------LICENSE_START--------
//
// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informàtica Industrial, CSIC-UPC.
// Authors: Joan Solà Ortega (jsola@iri.upc.edu)
// All rights reserved.
//
// This file is part of WOLF
// WOLF is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
//--------LICENSE_END--------
#include
"core/math/SE2.h"
#include
"core/utils/utils_gtest.h"
using
namespace
Eigen
;
using
namespace
wolf
;
using
namespace
SE2
;
TEST
(
SE2
,
betweenBlocks
)
{
Vector2d
p1
,
p2
,
pd
;
double
o1
,
o2
,
od
;
// both origin: relative pose zero
p1
=
Vector2d
::
Zero
();
p2
=
p1
;
o1
=
0
;
o2
=
o1
;
between
(
p1
,
o1
,
p2
,
o2
,
pd
,
od
);
ASSERT_MATRIX_APPROX
(
pd
,
Eigen
::
Vector2d
::
Zero
(),
1e-8
);
ASSERT_NEAR
(
od
,
0
,
1e-8
);
// both same random pose: relative pose zero
for
(
auto
i
=
0
;
i
<
10
;
i
++
)
{
p1
=
Vector2d
::
Random
();
p2
=
p1
;
o1
=
Vector1d
::
Random
()(
0
)
*
M_PI
;
o2
=
o1
;
between
(
p1
,
o1
,
p2
,
o2
,
pd
,
od
);
ASSERT_MATRIX_APPROX
(
pd
,
Eigen
::
Vector2d
::
Zero
(),
1e-8
);
ASSERT_NEAR
(
od
,
0
,
1e-8
);
}
// random relative pose
for
(
auto
i
=
0
;
i
<
10
;
i
++
)
{
p1
=
Vector2d
::
Random
();
o1
=
Vector1d
::
Random
()(
0
)
*
M_PI
;
Vector2d
pd_gt
=
Vector2d
::
Random
();
double
od_gt
=
Vector1d
::
Random
()(
0
)
*
M_PI
;
p2
=
p1
+
Rotation2Dd
(
o1
)
*
pd_gt
;
o2
=
o1
+
od_gt
;
between
(
p1
,
o1
,
p2
,
o2
,
pd
,
od
);
ASSERT_MATRIX_APPROX
(
pd
,
pd_gt
,
1e-8
);
ASSERT_NEAR
(
od
,
od_gt
,
1e-8
);
}
}
TEST
(
SE2
,
betweenVectors
)
{
Vector3d
p1
,
p2
,
pd
;
// both origin: relative pose zero
p1
=
Vector3d
::
Zero
();
p2
=
p1
;
between
(
p1
,
p2
,
pd
);
ASSERT_MATRIX_APPROX
(
pd
,
Eigen
::
Vector3d
::
Zero
(),
1e-8
);
// both same random pose: relative pose zero
for
(
auto
i
=
0
;
i
<
10
;
i
++
)
{
p1
=
Vector3d
::
Random
();
p1
(
2
)
*=
M_PI
;
p2
=
p1
;
between
(
p1
,
p2
,
pd
);
ASSERT_MATRIX_APPROX
(
pd
,
Eigen
::
Vector3d
::
Zero
(),
1e-8
);
}
// random relative pose
for
(
auto
i
=
0
;
i
<
10
;
i
++
)
{
p1
=
Vector3d
::
Random
();
p1
(
2
)
*=
M_PI
;
Vector3d
pd_gt
=
Vector3d
::
Random
();
pd_gt
(
2
)
*=
M_PI
;
p2
.
head
<
2
>
()
=
p1
.
head
<
2
>
()
+
Rotation2Dd
(
p1
(
2
))
*
pd_gt
.
head
<
2
>
();
p2
(
2
)
=
p1
(
2
)
+
pd_gt
(
2
);
between
(
p1
,
p2
,
pd
);
ASSERT_MATRIX_APPROX
(
pd
,
pd_gt
,
1e-8
);
}
}
TEST
(
SE2
,
betweenVectorsReturn
)
{
Vector3d
p1
,
p2
,
pd
;
// both origin: relative pose zero
p1
=
Vector3d
::
Zero
();
p2
=
p1
;
pd
=
between
(
p1
,
p2
);
ASSERT_MATRIX_APPROX
(
pd
,
Eigen
::
Vector3d
::
Zero
(),
1e-8
);
// both same random pose: relative pose zero
for
(
auto
i
=
0
;
i
<
10
;
i
++
)
{
p1
=
Vector3d
::
Random
();
p1
(
2
)
*=
M_PI
;
p2
=
p1
;
pd
=
between
(
p1
,
p2
);
ASSERT_MATRIX_APPROX
(
pd
,
Eigen
::
Vector3d
::
Zero
(),
1e-8
);
}
// random relative pose
for
(
auto
i
=
0
;
i
<
10
;
i
++
)
{
p1
=
Vector3d
::
Random
();
p1
(
2
)
*=
M_PI
;
Vector3d
pd_gt
=
Vector3d
::
Random
();
pd_gt
(
2
)
*=
M_PI
;
p2
.
head
<
2
>
()
=
p1
.
head
<
2
>
()
+
Rotation2Dd
(
p1
(
2
))
*
pd_gt
.
head
<
2
>
();
p2
(
2
)
=
p1
(
2
)
+
pd_gt
(
2
);
pd
=
between
(
p1
,
p2
);
ASSERT_MATRIX_APPROX
(
pd
,
pd_gt
,
1e-8
);
}
}
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