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
7a228241
Commit
7a228241
authored
7 years ago
by
Joan Solà Ortega
Browse files
Options
Downloads
Patches
Plain Diff
New selectPackBefore() with test
parent
0b88c4e6
No related branches found
No related tags found
1 merge request
!157
Kfpackmanager
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/processor_base.cpp
+25
-0
25 additions, 0 deletions
src/processor_base.cpp
src/processor_base.h
+3
-1
3 additions, 1 deletion
src/processor_base.h
src/test/gtest_KF_pack_buffer.cpp
+62
-0
62 additions, 0 deletions
src/test/gtest_KF_pack_buffer.cpp
with
90 additions
and
1 deletion
src/processor_base.cpp
+
25
−
0
View file @
7a228241
...
@@ -137,6 +137,31 @@ KFPackPtr KFPackBuffer::selectPack(const TimeStamp& _time_stamp, const Scalar& _
...
@@ -137,6 +137,31 @@ KFPackPtr KFPackBuffer::selectPack(const TimeStamp& _time_stamp, const Scalar& _
return
nullptr
;
return
nullptr
;
}
}
KFPackPtr
KFPackBuffer
::
selectPackBefore
(
const
TimeStamp
&
_time_stamp
,
const
Scalar
&
_time_tolerance
)
{
if
(
container_
.
empty
())
return
nullptr
;
KFPackBuffer
::
Iterator
post
=
container_
.
upper_bound
(
_time_stamp
);
bool
prev_exists
=
(
post
!=
container_
.
begin
());
if
(
prev_exists
)
return
container_
.
begin
()
->
second
;
else
{
bool
post_exists
=
(
post
!=
container_
.
end
());
bool
post_ok
=
post_exists
&&
checkTimeTolerance
(
post
->
first
,
post
->
second
->
time_tolerance
,
_time_stamp
,
_time_tolerance
);
if
(
post_ok
)
return
post
->
second
;
}
return
nullptr
;
}
void
KFPackBuffer
::
print
(
void
)
void
KFPackBuffer
::
print
(
void
)
{
{
std
::
cout
<<
"[ "
;
std
::
cout
<<
"[ "
;
...
...
This diff is collapsed.
Click to expand it.
src/processor_base.h
+
3
−
1
View file @
7a228241
...
@@ -50,10 +50,12 @@ class KFPackBuffer
...
@@ -50,10 +50,12 @@ class KFPackBuffer
/**\brief Select a Pack from the buffer
/**\brief Select a Pack from the buffer
*
*
* Select from the buffer the closest pack (w.r.t. time stamp),
* Select from the buffer the closest pack (w.r.t. time stamp),
* respecting a defined time tolerance
* respecting a defined time tolerance
s
*/
*/
KFPackPtr
selectPack
(
const
TimeStamp
&
_time_stamp
,
const
Scalar
&
_time_tolerance
);
KFPackPtr
selectPack
(
const
TimeStamp
&
_time_stamp
,
const
Scalar
&
_time_tolerance
);
KFPackPtr
selectPackBefore
(
const
TimeStamp
&
_time_stamp
,
const
Scalar
&
_time_tolerance
);
/**\brief Buffer size
/**\brief Buffer size
*
*
*/
*/
...
...
This diff is collapsed.
Click to expand it.
src/test/gtest_KF_pack_buffer.cpp
+
62
−
0
View file @
7a228241
...
@@ -144,6 +144,68 @@ TEST_F(KFPackBufferTest, selectPack)
...
@@ -144,6 +144,68 @@ TEST_F(KFPackBufferTest, selectPack)
}
}
}
}
TEST_F
(
KFPackBufferTest
,
selectPackBefore
)
{
kfpackbuffer
.
clear
();
kfpackbuffer
.
add
(
f10
,
tt10
);
kfpackbuffer
.
add
(
f20
,
tt20
);
kfpackbuffer
.
add
(
f21
,
tt21
);
// input time stamps
std
::
vector
<
TimeStamp
>
q_ts
=
{
9.5
,
9.995
,
10.005
,
19.5
,
20.5
,
21.5
};
Scalar
tt
=
0.01
;
// Solution matrix
// q_ts | pack
//=================
// first time
//-----------------
// 9.5 nullptr
// 9.995 10
// 10,005 10
// 19.5 10
// 20.5 10
// 21.5 10
// second time
//-----------------
// 9.5 nullptr
// 9.995 null
// 10,005 null
// 19.5 null
// 20.5 20
// 21.5 20
// third time
//-----------------
// 9.5 nullptr
// 9.995 null
// 10,005 null
// 19.5 null
// 20.5 null
// 21.5 21
Eigen
::
MatrixXs
truth
(
3
,
6
),
res
(
3
,
6
);
truth
<<
0
,
10
,
10
,
10
,
10
,
10
,
0
,
0
,
0
,
0
,
20
,
20
,
0
,
0
,
0
,
0
,
0
,
21
;
res
.
setZero
();
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
KFPackPtr
packQ
;
int
j
=
0
;
for
(
auto
ts
:
q_ts
)
{
packQ
=
kfpackbuffer
.
selectPackBefore
(
ts
,
tt
);
if
(
packQ
)
res
(
i
,
j
)
=
packQ
->
key_frame
->
getTimeStamp
().
get
();
j
++
;
}
kfpackbuffer
.
removeUpTo
(
packQ
->
key_frame
->
getTimeStamp
());
}
ASSERT_MATRIX_APPROX
(
res
,
truth
,
1e-6
);
}
TEST_F
(
KFPackBufferTest
,
removeUpTo
)
TEST_F
(
KFPackBufferTest
,
removeUpTo
)
{
{
// Small time tolerance for all test asserts
// Small time tolerance for all test asserts
...
...
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