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
299261e3
Commit
299261e3
authored
2 years ago
by
Joan Vallvé Navarro
Browse files
Options
Downloads
Patches
Plain Diff
finished gtest for processor landmark external
parent
d27119da
No related branches found
No related tags found
1 merge request
!462
Resolve "Subscriber&processor for landmark external detections"
Pipeline
#13920
canceled
2 years ago
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/gtest_processor_tracker_feature_landmark_external.cpp
+71
-58
71 additions, 58 deletions
test/gtest_processor_tracker_feature_landmark_external.cpp
with
71 additions
and
58 deletions
test/gtest_processor_tracker_feature_landmark_external.cpp
+
71
−
58
View file @
299261e3
...
@@ -57,8 +57,9 @@ class ProcessorTrackerFeatureLandmarkExternalTest : public testing::Test
...
@@ -57,8 +57,9 @@ class ProcessorTrackerFeatureLandmarkExternalTest : public testing::Test
ProcessorMotionPtr
processor_motion
;
ProcessorMotionPtr
processor_motion
;
std
::
vector
<
LandmarkBasePtr
>
landmarks
;
std
::
vector
<
LandmarkBasePtr
>
landmarks
;
// Groundtruth poses
// Groundtruth states
VectorXd
p_robot
,
o_robot
,
p_sensor
,
o_sensor
;
VectorComposite
state_robot
,
state_sensor
;
std
::
vector
<
VectorComposite
>
state_landmarks
;
virtual
void
SetUp
()
{};
virtual
void
SetUp
()
{};
void
initProblem
(
int
_dim
,
void
initProblem
(
int
_dim
,
...
@@ -77,6 +78,7 @@ class ProcessorTrackerFeatureLandmarkExternalTest : public testing::Test
...
@@ -77,6 +78,7 @@ class ProcessorTrackerFeatureLandmarkExternalTest : public testing::Test
int
track_length
,
int
track_length
,
double
time_span
,
double
time_span
,
bool
add_landmarks
);
bool
add_landmarks
);
void
assertVectorComposite
(
const
VectorComposite
&
v1
,
const
VectorComposite
&
v2
)
const
;
};
};
void
ProcessorTrackerFeatureLandmarkExternalTest
::
initProblem
(
int
_dim
,
void
ProcessorTrackerFeatureLandmarkExternalTest
::
initProblem
(
int
_dim
,
...
@@ -179,13 +181,12 @@ void ProcessorTrackerFeatureLandmarkExternalTest::initProblem(int _dim,
...
@@ -179,13 +181,12 @@ void ProcessorTrackerFeatureLandmarkExternalTest::initProblem(int _dim,
nullptr
));
nullptr
));
lmk
->
setId
(
i
);
lmk
->
setId
(
i
);
landmarks
.
push_back
(
lmk
);
landmarks
.
push_back
(
lmk
);
state_landmarks
.
push_back
(
lmk
->
getState
());
}
}
// Store groundtruth poses
// Store groundtruth poses
p_robot
=
F0
->
getP
()
->
getState
();
state_robot
=
F0
->
getState
(
"PO"
);
o_robot
=
F0
->
getO
()
->
getState
();
state_sensor
=
sensor
->
getState
(
"PO"
);
p_sensor
=
sensor
->
getP
()
->
getState
();
o_sensor
=
sensor
->
getO
()
->
getState
();
}
}
void
ProcessorTrackerFeatureLandmarkExternalTest
::
randomStep
()
void
ProcessorTrackerFeatureLandmarkExternalTest
::
randomStep
()
...
@@ -210,38 +211,31 @@ void ProcessorTrackerFeatureLandmarkExternalTest::randomStep()
...
@@ -210,38 +211,31 @@ void ProcessorTrackerFeatureLandmarkExternalTest::randomStep()
cap_odom
->
process
();
cap_odom
->
process
();
// update groundtruth pose with random movement
// update groundtruth pose with random movement
auto
state
=
processor_motion
->
getState
(
"PO"
);
state_robot
=
processor_motion
->
getState
(
"PO"
);
p_robot
=
state
.
vector
(
"P"
);
o_robot
=
state
.
vector
(
"O"
);
}
}
CaptureLandmarksExternalPtr
ProcessorTrackerFeatureLandmarkExternalTest
::
computeCaptureLandmarks
()
const
CaptureLandmarksExternalPtr
ProcessorTrackerFeatureLandmarkExternalTest
::
computeCaptureLandmarks
()
const
{
{
// Detections
// Detections
auto
cap
=
std
::
make_shared
<
CaptureLandmarksExternal
>
(
t
,
sensor
);
auto
cap
=
std
::
make_shared
<
CaptureLandmarksExternal
>
(
t
,
sensor
);
VectorXd
p_lmk
,
o_lmk
;
for
(
auto
i
=
0
;
i
<
landmarks
.
size
();
i
++
)
for
(
auto
i
=
0
;
i
<
landmarks
.
size
();
i
++
)
{
{
p_lmk
=
landmarks
.
at
(
i
)
->
getP
()
->
getState
();
if
(
orientation
)
o_lmk
=
landmarks
.
at
(
i
)
->
getO
()
->
getState
();
// compute detection
// compute detection
VectorXd
meas
(
orientation
?
(
dim
==
2
?
3
:
7
)
:
(
dim
==
2
?
2
:
3
));
VectorXd
meas
(
orientation
?
(
dim
==
2
?
3
:
7
)
:
(
dim
==
2
?
2
:
3
));
if
(
dim
==
2
)
if
(
dim
==
2
)
{
{
meas
.
head
(
2
)
=
Rotation2Dd
(
-
o
_sensor
(
0
))
*
(
Rotation2Dd
(
-
o
_robot
(
0
))
*
(
p_lmk
-
p_robot
)
-
p_sensor
);
meas
.
head
(
2
)
=
Rotation2Dd
(
-
state
_sensor
.
at
(
'O'
)
(
0
))
*
(
Rotation2Dd
(
-
state
_robot
.
at
(
'O'
)(
0
))
*
(
state_landmarks
.
at
(
i
).
at
(
'P'
)
-
state_robot
.
at
(
'P'
))
-
state_sensor
.
at
(
'P'
)
);
if
(
orientation
)
if
(
orientation
)
meas
(
2
)
=
o_lmk
(
0
)
-
o
_robot
(
0
)
-
o
_sensor
(
0
);
meas
(
2
)
=
state_landmarks
.
at
(
i
).
at
(
'O'
)
(
0
)
-
state
_robot
.
at
(
'O'
)
(
0
)
-
state
_sensor
.
at
(
'O'
)
(
0
);
}
}
else
else
{
{
auto
q_sensor
=
Quaterniond
(
Vector4d
(
o
_sensor
));
auto
q_sensor
=
Quaterniond
(
Vector4d
(
state
_sensor
.
at
(
'O'
)
));
auto
q_robot
=
Quaterniond
(
Vector4d
(
o
_robot
));
auto
q_robot
=
Quaterniond
(
Vector4d
(
state
_robot
.
at
(
'O'
)
));
meas
.
head
(
3
)
=
q_sensor
.
conjugate
()
*
(
q_robot
.
conjugate
()
*
(
p_lmk
-
p_robot
)
-
p_sensor
);
meas
.
head
(
3
)
=
q_sensor
.
conjugate
()
*
(
q_robot
.
conjugate
()
*
(
state_landmarks
.
at
(
i
).
at
(
'P'
)
-
state_robot
.
at
(
'P'
))
-
state_sensor
.
at
(
'P'
)
);
if
(
orientation
)
if
(
orientation
)
meas
.
tail
(
4
)
=
(
q_sensor
.
conjugate
()
*
q_robot
.
conjugate
()
*
Quaterniond
(
Vector4d
(
o_lmk
))).
coeffs
();
meas
.
tail
(
4
)
=
(
q_sensor
.
conjugate
()
*
q_robot
.
conjugate
()
*
Quaterniond
(
Vector4d
(
state_landmarks
.
at
(
i
).
at
(
'O'
)
))).
coeffs
();
}
}
// cov
// cov
MatrixXd
cov
=
MatrixXd
::
Identity
(
meas
.
size
(),
meas
.
size
());
MatrixXd
cov
=
MatrixXd
::
Identity
(
meas
.
size
(),
meas
.
size
());
...
@@ -323,20 +317,8 @@ void ProcessorTrackerFeatureLandmarkExternalTest::testConfiguration(int dim,
...
@@ -323,20 +317,8 @@ void ProcessorTrackerFeatureLandmarkExternalTest::testConfiguration(int dim,
for
(
auto
lmk_map
:
landmarks_map
)
for
(
auto
lmk_map
:
landmarks_map
)
{
{
ASSERT_TRUE
(
lmk_map
->
id
()
<
landmarks
.
size
());
ASSERT_TRUE
(
lmk_map
->
id
()
<
landmarks
.
size
());
auto
lmk_gt
=
landmarks
.
at
(
lmk_map
->
id
());
ASSERT_EQ
(
lmk_map
->
id
(),
landmarks
.
at
(
lmk_map
->
id
())
->
id
());
ASSERT_EQ
(
lmk_map
->
id
(),
lmk_gt
->
id
());
assertVectorComposite
(
lmk_map
->
getState
(),
state_landmarks
.
at
(
lmk_map
->
id
()));
if
(
not
orientation
)
{
ASSERT_MATRIX_APPROX
(
lmk_map
->
getState
().
vector
(
"P"
),
lmk_gt
->
getState
().
vector
(
"P"
),
Constants
::
EPS
);
}
else
if
(
dim
==
2
)
{
ASSERT_POSE2d_APPROX
(
lmk_map
->
getState
().
vector
(
"PO"
),
lmk_gt
->
getState
().
vector
(
"PO"
),
Constants
::
EPS
);
}
else
if
(
dim
==
3
)
{
ASSERT_POSE3d_APPROX
(
lmk_map
->
getState
().
vector
(
"PO"
),
lmk_gt
->
getState
().
vector
(
"PO"
),
Constants
::
EPS
);
}
}
}
}
}
}
}
...
@@ -350,24 +332,55 @@ void ProcessorTrackerFeatureLandmarkExternalTest::testConfiguration(int dim,
...
@@ -350,24 +332,55 @@ void ProcessorTrackerFeatureLandmarkExternalTest::testConfiguration(int dim,
ASSERT_EQ
(
problem
->
getMap
()
->
getLandmarkList
().
empty
(),
not
add_landmarks
);
ASSERT_EQ
(
problem
->
getMap
()
->
getLandmarkList
().
empty
(),
not
add_landmarks
);
}
}
// step with random movement
t
+=
dt
;
randomStep
();
// solve
// solve
if
(
not
problem
->
getMap
()
->
getLandmarkList
().
empty
()
)
if
(
should_emplace_KF
)
{
{
// TODO store gt values
// perturb landmarks
for
(
auto
lmk
:
problem
->
getMap
()
->
getLandmarkList
())
lmk
->
perturb
();
// TODO perturb
// fix frame and extrinsics
sensor
->
fix
();
problem
->
getLastFrame
()
->
fix
();
// solve
// solve
//
auto report = solver->solve(SolverManager::ReportVerbosity::FULL);
auto
report
=
solver
->
solve
(
SolverManager
::
ReportVerbosity
::
FULL
);
//
WOLF_INFO(report);
WOLF_INFO
(
report
);
// TODO check values
// check values
//assertVectorComposite(sensor->getState("PO"), state_sensor);
//assertVectorComposite(problem->getState("PO"), state_robot);
for
(
auto
lmk_map
:
problem
->
getMap
()
->
getLandmarkList
())
{
assertVectorComposite
(
lmk_map
->
getState
(),
state_landmarks
.
at
(
lmk_map
->
id
()));
}
}
}
}
}
// step with random movement
void
ProcessorTrackerFeatureLandmarkExternalTest
::
assertVectorComposite
(
const
VectorComposite
&
v1
,
const
VectorComposite
&
v2
)
const
t
+=
dt
;
{
randomStep
();
if
(
v1
.
includesStructure
(
"PO"
)
and
v2
.
includesStructure
(
"PO"
))
{
if
(
dim
==
2
)
{
ASSERT_POSE2d_APPROX
(
v1
.
vector
(
"PO"
),
v2
.
vector
(
"PO"
),
Constants
::
EPS
);
}
else
{
ASSERT_POSE3d_APPROX
(
v1
.
vector
(
"PO"
),
v2
.
vector
(
"PO"
),
Constants
::
EPS
);
}
}
}
else
if
(
v1
.
includesStructure
(
"P"
)
and
v2
.
includesStructure
(
"P"
))
{
ASSERT_MATRIX_APPROX
(
v1
.
vector
(
"P"
),
v2
.
vector
(
"P"
),
Constants
::
EPS
);
}
else
throw
std
::
runtime_error
(
"wrong vector composite"
);
}
}
// / TESTS //////////////////////////////////////////
// / TESTS //////////////////////////////////////////
...
@@ -397,10 +410,10 @@ TEST_F(ProcessorTrackerFeatureLandmarkExternalTest, P_2d_no_lmks_quality)
...
@@ -397,10 +410,10 @@ TEST_F(ProcessorTrackerFeatureLandmarkExternalTest, P_2d_no_lmks_quality)
{
{
testConfiguration
(
2
,
//int dim
testConfiguration
(
2
,
//int dim
false
,
//bool orientation
false
,
//bool orientation
0.3
,
//double quality_th
0.3
,
//double quality_th
1e6
,
//double dist_th
1e6
,
//double dist_th
6
,
//int track_length
6
,
//int track_length
4.5
*
dt
,
//double time_span
4.5
*
dt
,
//double time_span
false
);
//bool add_landmarks
false
);
//bool add_landmarks
}
}
...
@@ -411,7 +424,7 @@ TEST_F(ProcessorTrackerFeatureLandmarkExternalTest, PO_2d_existing_lmks)
...
@@ -411,7 +424,7 @@ TEST_F(ProcessorTrackerFeatureLandmarkExternalTest, PO_2d_existing_lmks)
0
,
//double quality_th
0
,
//double quality_th
1e6
,
//double dist_th
1e6
,
//double dist_th
3
,
//int track_length
3
,
//int track_length
4.5
*
dt
,
//double time_span
4.5
*
dt
,
//double time_span
true
);
//bool add_landmarks
true
);
//bool add_landmarks
}
}
...
@@ -422,7 +435,7 @@ TEST_F(ProcessorTrackerFeatureLandmarkExternalTest, PO_2d_no_lmks)
...
@@ -422,7 +435,7 @@ TEST_F(ProcessorTrackerFeatureLandmarkExternalTest, PO_2d_no_lmks)
0
,
//double quality_th
0
,
//double quality_th
1e6
,
//double dist_th
1e6
,
//double dist_th
1
,
//int track_length
1
,
//int track_length
4.5
*
dt
,
//double time_span
4.5
*
dt
,
//double time_span
false
);
//bool add_landmarks
false
);
//bool add_landmarks
}
}
...
@@ -430,10 +443,10 @@ TEST_F(ProcessorTrackerFeatureLandmarkExternalTest, PO_2d_no_lmks_quality)
...
@@ -430,10 +443,10 @@ TEST_F(ProcessorTrackerFeatureLandmarkExternalTest, PO_2d_no_lmks_quality)
{
{
testConfiguration
(
2
,
//int dim
testConfiguration
(
2
,
//int dim
true
,
//bool orientation
true
,
//bool orientation
0.3
,
//double quality_th
0.3
,
//double quality_th
1e6
,
//double dist_th
1e6
,
//double dist_th
0
,
//int track_length
0
,
//int track_length
4.5
*
dt
,
//double time_span
4.5
*
dt
,
//double time_span
false
);
//bool add_landmarks
false
);
//bool add_landmarks
}
}
...
@@ -444,7 +457,7 @@ TEST_F(ProcessorTrackerFeatureLandmarkExternalTest, P_3d_existing_lmks)
...
@@ -444,7 +457,7 @@ TEST_F(ProcessorTrackerFeatureLandmarkExternalTest, P_3d_existing_lmks)
0
,
//double quality_th
0
,
//double quality_th
1e6
,
//double dist_th
1e6
,
//double dist_th
7
,
//int track_length
7
,
//int track_length
4.5
*
dt
,
//double time_span
4.5
*
dt
,
//double time_span
true
);
//bool add_landmarks
true
);
//bool add_landmarks
}
}
...
@@ -454,8 +467,8 @@ TEST_F(ProcessorTrackerFeatureLandmarkExternalTest, P_3d_no_lmks)
...
@@ -454,8 +467,8 @@ TEST_F(ProcessorTrackerFeatureLandmarkExternalTest, P_3d_no_lmks)
false
,
//bool orientation
false
,
//bool orientation
0
,
//double quality_th
0
,
//double quality_th
1e6
,
//double dist_th
1e6
,
//double dist_th
53
,
//int track_length
53
,
//int track_length
4.5
*
dt
,
//double time_span
4.5
*
dt
,
//double time_span
false
);
//bool add_landmarks
false
);
//bool add_landmarks
}
}
...
@@ -463,10 +476,10 @@ TEST_F(ProcessorTrackerFeatureLandmarkExternalTest, P_3d_no_lmks_quality)
...
@@ -463,10 +476,10 @@ TEST_F(ProcessorTrackerFeatureLandmarkExternalTest, P_3d_no_lmks_quality)
{
{
testConfiguration
(
3
,
//int dim
testConfiguration
(
3
,
//int dim
false
,
//bool orientation
false
,
//bool orientation
0.3
,
//double quality_th
0.3
,
//double quality_th
1e6
,
//double dist_th
1e6
,
//double dist_th
2
,
//int track_length
2
,
//int track_length
4.5
*
dt
,
//double time_span
4.5
*
dt
,
//double time_span
false
);
//bool add_landmarks
false
);
//bool add_landmarks
}
}
...
@@ -477,7 +490,7 @@ TEST_F(ProcessorTrackerFeatureLandmarkExternalTest, PO_3d_existing_lmks)
...
@@ -477,7 +490,7 @@ TEST_F(ProcessorTrackerFeatureLandmarkExternalTest, PO_3d_existing_lmks)
0
,
//double quality_th
0
,
//double quality_th
1e6
,
//double dist_th
1e6
,
//double dist_th
1
,
//int track_length
1
,
//int track_length
4.5
*
dt
,
//double time_span
4.5
*
dt
,
//double time_span
true
);
//bool add_landmarks
true
);
//bool add_landmarks
}
}
...
@@ -488,7 +501,7 @@ TEST_F(ProcessorTrackerFeatureLandmarkExternalTest, PO_3d_no_lmks)
...
@@ -488,7 +501,7 @@ TEST_F(ProcessorTrackerFeatureLandmarkExternalTest, PO_3d_no_lmks)
0
,
//double quality_th
0
,
//double quality_th
1e6
,
//double dist_th
1e6
,
//double dist_th
4
,
//int track_length
4
,
//int track_length
4.5
*
dt
,
//double time_span
4.5
*
dt
,
//double time_span
false
);
//bool add_landmarks
false
);
//bool add_landmarks
}
}
...
@@ -496,10 +509,10 @@ TEST_F(ProcessorTrackerFeatureLandmarkExternalTest, PO_3d_no_lmks_quality)
...
@@ -496,10 +509,10 @@ TEST_F(ProcessorTrackerFeatureLandmarkExternalTest, PO_3d_no_lmks_quality)
{
{
testConfiguration
(
3
,
//int dim
testConfiguration
(
3
,
//int dim
true
,
//bool orientation
true
,
//bool orientation
0.2
,
//double quality_th
0.2
,
//double quality_th
1e6
,
//double dist_th
1e6
,
//double dist_th
5
,
//int track_length
5
,
//int track_length
4.5
*
dt
,
//double time_span
4.5
*
dt
,
//double time_span
false
);
//bool add_landmarks
false
);
//bool add_landmarks
}
}
...
...
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