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
Package registry
Container Registry
Model registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Leander Singer
RobotAPI
Commits
89940f64
Commit
89940f64
authored
2 years ago
by
armar6-demo
Browse files
Options
Downloads
Patches
Plain Diff
local changes on A-6 demo account
parent
67f644f7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/RobotAPI/libraries/armem_robot_state/common/localization/TransformHelper.cpp
+41
-13
41 additions, 13 deletions
...armem_robot_state/common/localization/TransformHelper.cpp
with
41 additions
and
13 deletions
source/RobotAPI/libraries/armem_robot_state/common/localization/TransformHelper.cpp
+
41
−
13
View file @
89940f64
...
...
@@ -49,10 +49,20 @@ namespace armarx::armem::common::robot_state::localization
localizationCoreSegment
,
tfChain
,
query
.
header
.
agent
,
query
.
header
.
timestamp
);
const
armem
::
Time
sanitizedTimestamp
=
_obtainTimestamp
(
localizationCoreSegment
,
query
.
header
.
timestamp
);
if
(
sanitizedTimestamp
.
isInvalid
())
{
ARMARX_WARNING
<<
deactivateSpam
(
1
)
<<
"No timestamp available."
;
return
{.
transform
=
{.
header
=
query
.
header
},
.
status
=
TransformResult
::
Status
::
ErrorFrameNotAvailable
,
.
errorMessage
=
"Error in TF loookup: '"
+
query
.
header
.
parentFrame
+
" -> "
+
query
.
header
.
frame
+
"'. No memory data in time range."
};
}
auto
header
=
query
.
header
;
// ARMARX_INFO << header.timestamp << "vs" << sanitizedTimestamp;
header
.
timestamp
=
sanitizedTimestamp
;
if
(
transforms
.
empty
())
...
...
@@ -181,24 +191,42 @@ namespace armarx::armem::common::robot_state::localization
armarx
::
core
::
time
::
DateTime
TransformHelper
::
_obtainTimestamp
(
const
armem
::
base
::
CoreSegmentBase
<
Args
...
>&
localizationCoreSegment
,
const
armem
::
Time
&
timestamp
)
{
// first we check which the newest timestamp is
int64_t
timeSinceEpochUs
=
0
;
std
::
optional
<
int64_t
>
timeSinceEpochUs
=
std
::
nullopt
;
localizationCoreSegment
.
forEachEntity
([
&
timeSinceEpochUs
,
&
timestamp
](
const
auto
&
entity
){
localizationCoreSegment
.
forEachEntity
([
&
timeSinceEpochUs
,
&
timestamp
](
const
auto
&
entity
)
{
auto
snapshot
=
entity
.
findLatestSnapshotBeforeOrAt
(
timestamp
);
const
armem
::
wm
::
EntityInstance
&
item
=
snapshot
->
getInstance
(
0
);
const
auto
tf
=
_convertEntityToTransform
(
item
);
const
auto
&
dataTs
=
tf
.
header
.
timestamp
;
timeSinceEpochUs
=
std
::
max
(
timeSinceEpochUs
,
dataTs
.
toMicroSecondsSinceEpoch
());
if
(
snapshot
)
{
// This caused a segfault when the snapshot does not exist.
const
armem
::
wm
::
EntityInstance
&
item
=
snapshot
->
getInstance
(
0
);
const
auto
tf
=
_convertEntityToTransform
(
item
);
const
auto
&
dataTs
=
tf
.
header
.
timestamp
;
if
(
timeSinceEpochUs
.
has_value
())
{
timeSinceEpochUs
=
std
::
max
(
timeSinceEpochUs
.
value
(),
dataTs
.
toMicroSecondsSinceEpoch
());
}
else
{
timeSinceEpochUs
=
dataTs
.
toMicroSecondsSinceEpoch
();
}
}
});
// then we ensure that the timestamp is not more recent than the query timestamp
timeSinceEpochUs
=
std
::
min
(
timeSinceEpochUs
,
timestamp
.
toMicroSecondsSinceEpoch
());
if
(
timeSinceEpochUs
.
has_value
())
{
// then we ensure that the timestamp is not more recent than the query timestamp
timeSinceEpochUs
=
std
::
min
(
timeSinceEpochUs
.
value
(),
timestamp
.
toMicroSecondsSinceEpoch
());
return
armarx
::
core
::
time
::
DateTime
(
armarx
::
core
::
time
::
Duration
::
MicroSeconds
(
timeSinceEpochUs
));
return
armarx
::
core
::
time
::
DateTime
(
armarx
::
core
::
time
::
Duration
::
MicroSeconds
(
timeSinceEpochUs
.
value
()));
}
else
{
return
DateTime
::
Invalid
();
}
}
...
...
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