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
c78693b4
Commit
c78693b4
authored
2 years ago
by
Rainer Kartmann
Browse files
Options
Downloads
Patches
Plain Diff
Minor changes to prediction code
parent
15cf4d5c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!242
Add Prediction Interface and linear position prediction model to Object Memory
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/RobotAPI/libraries/armem_objects/server/instance/Segment.cpp
+25
-24
25 additions, 24 deletions
...otAPI/libraries/armem_objects/server/instance/Segment.cpp
with
25 additions
and
24 deletions
source/RobotAPI/libraries/armem_objects/server/instance/Segment.cpp
+
25
−
24
View file @
c78693b4
...
...
@@ -581,60 +581,61 @@ namespace armarx::armem::server::obj::instance
objpose
::
ObjectPosePredictionResult
result
;
result
.
success
=
false
;
ObjectID
objID
=
armarx
::
fromIce
<
ObjectID
>
(
request
.
objectID
);
auto
*
entity
=
findObjectEntity
(
objID
);
const
ObjectID
objID
=
armarx
::
fromIce
<
ObjectID
>
(
request
.
objectID
);
const
double
predictionTime
=
static_cast
<
double
>
(
armarx
::
fromIce
<
Time
>
(
request
.
timestamp
).
toMicroSecondsSinceEpoch
());
const
Duration
lookbackDuration
=
Duration
::
SecondsDouble
(
p
.
linearPredictionLookbackSeconds
);
const
wm
::
Entity
*
entity
=
findObjectEntity
(
objID
);
if
(
!
entity
)
{
std
::
stringstream
sstream
;
sstream
<<
"Could not find object with ID "
<<
objID
;
sstream
<<
"Could not find object with ID "
<<
objID
<<
"."
;
result
.
errorMessage
=
sstream
.
str
();
return
result
;
}
// Used as a template for the returned pose prediction
auto
objectPoseTemplate
=
getLatestObjectPose
(
*
entity
);
std
::
vector
<
double
>
timestamps
;
std
::
vector
<
double
>
timestampsSec
;
std
::
vector
<
Eigen
::
Vector3d
>
positions
;
entity
->
forEachSnapshotInTimeRange
(
Time
::
Now
()
-
Time
(
Duration
::
SecondsDouble
(
p
.
linearPredictionLookbackSeconds
)),
Time
(
0
),
[
&
timestamps
,
&
positions
](
const
wm
::
EntitySnapshot
&
snapshot
)
Time
::
Now
()
-
lookbackDuration
,
Time
::
Invalid
(),
[
&
timestampsSec
,
&
positions
](
const
wm
::
EntitySnapshot
&
snapshot
)
{
snapshot
.
forEachInstance
(
[
&
snapshot
,
&
positions
,
&
timestamps
](
const
wm
::
EntityInstance
&
instance
)
[
&
snapshot
,
&
positions
,
&
timestamps
Sec
](
const
wm
::
EntityInstance
&
instance
)
{
arondto
::
ObjectInstance
dto
;
ObjectPose
pose
;
dto
.
fromAron
(
instance
.
data
());
ObjectPose
pose
;
fromAron
(
dto
,
pose
);
timestamps
.
push_back
(
static_cast
<
double
>
(
snapshot
.
time
().
toMicroSecondsSinceEpoch
()));
timestampsSec
.
push_back
(
snapshot
.
time
().
toDurationSinceEpoch
().
toSecondsDouble
());
positions
.
push_back
(
simox
::
math
::
position
(
pose
.
objectPoseGlobal
).
cast
<
double
>
());
});
});
ARMARX_CHECK_EQUAL
(
timestampsSec
.
size
(),
positions
.
size
());
ARMARX_CHECK_EQUAL
(
timestamps
.
size
(),
positions
.
size
());
if
(
timestamps
.
empty
())
if
(
timestampsSec
.
empty
())
{
std
::
stringstream
sstream
;
sstream
<<
"No snapshots of the object "
<<
objID
<<
" were found in the last "
<<
p
.
linearPredictionLookbackSeconds
<<
" seconds."
<<
" Cannot make a prediction."
;
<<
lookbackDuration
<<
". Cannot make a prediction."
;
result
.
errorMessage
=
sstream
.
str
();
return
result
;
}
double
predictionTime
=
static_cast
<
double
>
(
armarx
::
fromIce
<
Time
>
(
request
.
timestamp
).
toMicroSecondsSinceEpoch
());
const
Eigen
::
Vector3d
prediction
=
makeLinearPrediction
(
timestampsSec
,
positions
,
predictionTime
);
// ToDo: Remove.
ARMARX_IMPORTANT
<<
"Prediction: "
<<
prediction
.
transpose
();
Eigen
::
Vector3d
prediction
=
makeLinearPrediction
(
timestamps
,
positions
,
predictionTime
);
// Used as a template for the returned pose prediction.
ObjectPose
objectPoseTemplate
=
getLatestObjectPose
(
*
entity
);
ARMARX_IMPORTANT
<<
"Prediction: "
<<
prediction
.
x
()
<<
", "
<<
prediction
.
y
()
<<
", "
<<
prediction
.
z
();
// Reuse the rotation from the latest pose.
// This is a pretty generous assumption, but the linear model doesn't cover rotations,
// so it's our best guess.
...
...
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