Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RobotAPI
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
Container Registry
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software
ArmarX
RobotAPI
Commits
95eb3ffe
Commit
95eb3ffe
authored
3 years ago
by
Fabian Reister
Browse files
Options
Downloads
Patches
Plain Diff
warning and exceptions; new queries
parent
fc97c2d6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!157
armem/dev => master
,
!147
new queries for snapshots: TimeApprox and BeforeTime
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
source/RobotAPI/interface/armem/query.ice
+17
-1
17 additions, 1 deletion
source/RobotAPI/interface/armem/query.ice
source/RobotAPI/libraries/armem/server/query_proc/base/EntityQueryProcessorBase.h
+41
-8
41 additions, 8 deletions
...s/armem/server/query_proc/base/EntityQueryProcessorBase.h
with
58 additions
and
9 deletions
source/RobotAPI/interface/armem/query.ice
+
17
−
1
View file @
95eb3ffe
...
...
@@ -75,15 +75,31 @@ module armarx
};
/**
* @brief Get the last snapshot before the timestamp.
* @brief Get the last snapshot before
or at
the timestamp.
*
* This query is kind of similar to latest() but with a reference timestamp.
*
*/
class
BeforeOrAtTime
extends
EntityQuery
{
long
timestamp
;
}
/**
* @brief Get the last snapshot before the timestamp or a sequence of
* n last elements before the timestamp depending on #maxEntries
*
* Depending on #maxEntries, the behavior is as follows:
* - #maxEntries == 1 => last element before timestamp
* - #maxEntries > 1 => n last elements before timestamp
* - #maxEntries < 0 => all elements before timestamp
*/
class
BeforeTime
extends
EntityQuery
{
long
timestamp
;
long
maxEntries
=
1
;
}
}
...
...
This diff is collapsed.
Click to expand it.
source/RobotAPI/libraries/armem/server/query_proc/base/EntityQueryProcessorBase.h
+
41
−
8
View file @
95eb3ffe
...
...
@@ -2,6 +2,7 @@
#include
<RobotAPI/interface/armem/query.h>
#include
"ArmarXCore/core/exceptions/LocalException.h"
#include
"BaseQueryProcessorBase.h"
#include
<ArmarXCore/core/logging/Logging.h>
...
...
@@ -52,6 +53,10 @@ namespace armarx::armem::base::query_proc
{
process
(
result
,
*
q
,
entity
);
}
else
if
(
auto
q
=
dynamic_cast
<
const
armem
::
query
::
data
::
entity
::
BeforeOrAtTime
*>
(
&
query
))
{
process
(
result
,
*
q
,
entity
);
}
else
if
(
auto
q
=
dynamic_cast
<
const
armem
::
query
::
data
::
entity
::
BeforeTime
*>
(
&
query
))
{
process
(
result
,
*
q
,
entity
);
...
...
@@ -160,20 +165,50 @@ namespace armarx::armem::base::query_proc
}
}
void
process
(
_EntityT
&
result
,
const
armem
::
query
::
data
::
entity
::
BeforeOrAtTime
&
query
,
const
_EntityT
&
entity
)
const
{
const
auto
referenceTimestamp
=
fromIce
<
Time
>
(
query
.
timestamp
);
ARMARX_CHECK
(
referenceTimestamp
.
toMicroSeconds
()
>=
0
)
<<
"Reference timestamp is negative!"
;
const
auto
it
=
entity
.
history
().
lower_bound
(
referenceTimestamp
);
if
(
it
!=
entity
.
history
().
end
())
{
addResultSnapshot
(
result
,
it
);
}
}
void
process
(
_EntityT
&
result
,
const
armem
::
query
::
data
::
entity
::
BeforeTime
&
query
,
const
_EntityT
&
entity
)
const
{
const
auto
referenceTimestamp
=
fromIce
<
Time
>
(
query
.
timestamp
);
ARMARX_CHECK
(
referenceTimestamp
.
toMicroSeconds
()
>=
0
)
<<
"Reference timestamp is negative!"
;
const
auto
maxEntries
=
fromIce
<
int64
>
(
query
.
maxEntries
);
const
auto
refIt
=
entity
.
history
().
lower_bound
(
referenceTimestamp
);
if
(
ref
erenceTimestamp
.
toMicroSeco
nd
s
()
<
0
)
if
(
ref
It
==
entity
.
history
().
e
nd
())
{
return
;
// TODO throw or warn?
ARMARX_WARNING
<<
"No valid entities found."
;
return
;
}
const
auto
it
=
entity
.
history
().
lower_bound
(
referenceTimestamp
);
const
auto
nEntriesBefore
=
std
::
distance
(
entity
.
history
().
begin
(),
refIt
);
if
(
it
!=
entity
.
history
().
end
())
if
(
nEntriesBefore
<
maxEntries
)
{
// TODO maybe warn that not enough elements exist, but the user will notice anyways
;
}
const
int
nEntries
=
std
::
min
(
nEntriesBefore
,
maxEntries
);
auto
it
=
refIt
;
for
(
int64
i
=
0
;
i
<
nEntries
;
i
++
,
--
it
)
{
addResultSnapshot
(
result
,
it
);
}
...
...
@@ -184,6 +219,8 @@ namespace armarx::armem::base::query_proc
const
_EntityT
&
entity
)
const
{
const
auto
referenceTimestamp
=
fromIce
<
Time
>
(
query
.
timestamp
);
ARMARX_CHECK
(
referenceTimestamp
.
toMicroSeconds
()
>=
0
)
<<
"Reference timestamp is negative!"
;
const
auto
referenceTimestampMicroSeconds
=
referenceTimestamp
.
toMicroSeconds
();
const
auto
epsDuration
=
fromIce
<
Time
>
(
query
.
eps
).
toMicroSeconds
();
...
...
@@ -198,10 +235,6 @@ namespace armarx::armem::base::query_proc
return
std
::
abs
(
t
.
toMicroSeconds
()
-
referenceTimestampMicroSeconds
)
<=
epsDuration
;
};
if
(
referenceTimestamp
.
toMicroSeconds
()
<
0
)
{
return
;
// TODO throw or warn?
}
const
auto
beforeOrAt
=
entity
.
history
().
lower_bound
(
referenceTimestamp
);
const
auto
after
=
entity
.
history
().
upper_bound
(
referenceTimestamp
);
...
...
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