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
5e2874a5
Commit
5e2874a5
authored
4 years ago
by
Joan Solà Ortega
Browse files
Options
Downloads
Patches
Plain Diff
Fix asserts in CaptureBase::move()
parent
7ec4574e
No related branches found
No related tags found
1 merge request
!403
Resolve "Merge Aux/KeyFrames into Estimated Frames"
Pipeline
#6214
passed
4 years ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/capture/capture_base.cpp
+4
-4
4 additions, 4 deletions
src/capture/capture_base.cpp
test/gtest_capture_base.cpp
+65
-0
65 additions, 0 deletions
test/gtest_capture_base.cpp
with
69 additions
and
4 deletions
src/capture/capture_base.cpp
+
4
−
4
View file @
5e2874a5
...
...
@@ -177,11 +177,11 @@ void CaptureBase::unfix()
void
CaptureBase
::
move
(
FrameBasePtr
_frm_ptr
)
{
WOLF_WARN_COND
(
this
->
getFrame
()
==
nullptr
,
"moving a capture not linked to any frame"
);
WOLF_WARN_COND
(
_frm_ptr
==
nullptr
,
"moving a capture to a null FrameBasePtr"
);
WOLF_WARN_COND
(
this
->
getFrame
()
==
nullptr
,
"moving a capture not linked to any frame. Consider just linking it with link() instead of move()!"
);
assert
((
this
->
getFrame
()
==
nullptr
||
this
->
getFrame
()
->
getProblem
())
&&
"Forbidden: moving a capture already linked to a KF"
);
assert
((
_frm_ptr
==
nullptr
||
!
_frm_ptr
->
getProblem
())
&&
"Forbidden: moving a capture to a non-estimated frame"
);
assert
((
this
->
getFrame
()
==
nullptr
||
not
this
->
getFrame
()
->
getProblem
())
&&
"Forbidden: moving a capture already linked to a KF"
);
assert
((
_frm_ptr
!=
nullptr
)
&&
"Forbidden: moving a capture to a null frame"
);
assert
((
_frm_ptr
!=
nullptr
&&
_frm_ptr
->
getProblem
())
&&
"Forbidden: moving a capture to a non-estimated frame"
);
// Unlink
if
(
this
->
getFrame
())
...
...
This diff is collapsed.
Click to expand it.
test/gtest_capture_base.cpp
+
65
−
0
View file @
5e2874a5
...
...
@@ -100,6 +100,71 @@ TEST(CaptureBase, process)
ASSERT_TRUE
(
C
->
process
());
// This should not fail (although it does nothing)
}
TEST
(
CaptureBase
,
move_from_F_to_KF
)
{
ProblemPtr
problem
=
Problem
::
create
(
"PO"
,
2
);
auto
KF
=
problem
->
emplaceFrame
(
0.0
);
// dummy F object
auto
KC
=
CaptureBase
::
emplace
<
CaptureBase
>
(
KF
,
"Dummy"
,
0.0
);
auto
F
=
std
::
make_shared
<
FrameBase
>
(
0.0
,
nullptr
);
// dummy F object
auto
C
=
CaptureBase
::
emplace
<
CaptureBase
>
(
F
,
"Dummy"
,
0.0
);
ASSERT_EQ
(
KF
->
getCaptureList
().
size
(),
1
);
ASSERT_EQ
(
F
->
getCaptureList
().
size
(),
1
);
C
->
move
(
KF
);
ASSERT_EQ
(
KF
->
getCaptureList
().
size
(),
2
);
ASSERT_EQ
(
F
->
getCaptureList
().
size
(),
0
);
}
TEST
(
CaptureBase
,
move_from_F_to_null
)
{
ProblemPtr
problem
=
Problem
::
create
(
"PO"
,
2
);
FrameBasePtr
F0
=
nullptr
;
auto
F
=
std
::
make_shared
<
FrameBase
>
(
0.0
,
nullptr
);
// dummy F object
auto
C
=
CaptureBase
::
emplace
<
CaptureBase
>
(
F
,
"Dummy"
,
0.0
);
ASSERT_EQ
(
F
->
getCaptureList
().
size
(),
1
);
ASSERT_DEATH
(
C
->
move
(
F0
),
""
);
}
TEST
(
CaptureBase
,
move_from_null_to_KF
)
{
ProblemPtr
problem
=
Problem
::
create
(
"PO"
,
2
);
auto
KF
=
problem
->
emplaceFrame
(
0.0
);
// dummy F object
auto
KC
=
CaptureBase
::
emplace
<
CaptureBase
>
(
KF
,
"Dummy"
,
0.0
);
auto
C
=
std
::
make_shared
<
CaptureBase
>
(
"Dummy"
,
0.0
);
ASSERT_EQ
(
KF
->
getCaptureList
().
size
(),
1
);
C
->
move
(
KF
);
ASSERT_EQ
(
KF
->
getCaptureList
().
size
(),
2
);
}
TEST
(
CaptureBase
,
move_from_null_to_F
)
{
ProblemPtr
problem
=
Problem
::
create
(
"PO"
,
2
);
auto
F
=
std
::
make_shared
<
FrameBase
>
(
0.0
,
nullptr
);
// dummy F object
auto
C
=
std
::
make_shared
<
CaptureBase
>
(
"Dummy"
,
0.0
);
ASSERT_DEATH
(
C
->
move
(
F
),
""
);
}
int
main
(
int
argc
,
char
**
argv
)
{
testing
::
InitGoogleTest
(
&
argc
,
argv
);
...
...
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