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
Lennard Hofmann
RobotAPI
Commits
f3a2d97d
Commit
f3a2d97d
authored
3 years ago
by
Rainer Kartmann
Browse files
Options
Downloads
Patches
Plain Diff
Move code, fix style (don't start using another code style in an existing environment, dammit)
parent
f23d6473
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/RobotAPI/libraries/armem/server/MemoryToIceAdapter.cpp
+23
-19
23 additions, 19 deletions
...ce/RobotAPI/libraries/armem/server/MemoryToIceAdapter.cpp
with
23 additions
and
19 deletions
source/RobotAPI/libraries/armem/server/MemoryToIceAdapter.cpp
+
23
−
19
View file @
f3a2d97d
...
@@ -144,7 +144,7 @@ namespace armarx::armem::server
...
@@ -144,7 +144,7 @@ namespace armarx::armem::server
MemoryToIceAdapter
::
commit
(
const
armem
::
Commit
&
commit
)
MemoryToIceAdapter
::
commit
(
const
armem
::
Commit
&
commit
)
{
{
std
::
vector
<
data
::
MemoryID
>
updatedIDs
;
std
::
vector
<
data
::
MemoryID
>
updatedIDs
;
const
bool
publishUpdates
=
memoryListenerTopic
;
const
bool
publishUpdates
=
bool
(
memoryListenerTopic
)
;
CommitResult
commitResult
;
CommitResult
commitResult
;
for
(
const
EntityUpdate
&
update
:
commit
.
updates
)
for
(
const
EntityUpdate
&
update
:
commit
.
updates
)
...
@@ -152,6 +152,7 @@ namespace armarx::armem::server
...
@@ -152,6 +152,7 @@ namespace armarx::armem::server
EntityUpdateResult
&
result
=
commitResult
.
results
.
emplace_back
();
EntityUpdateResult
&
result
=
commitResult
.
results
.
emplace_back
();
try
try
{
{
// update() will lock core segment mutexes
auto
updateResult
=
workingMemory
->
update
(
update
);
auto
updateResult
=
workingMemory
->
update
(
update
);
result
.
success
=
true
;
result
.
success
=
true
;
...
@@ -202,29 +203,27 @@ namespace armarx::armem::server
...
@@ -202,29 +203,27 @@ namespace armarx::armem::server
{
{
ARMARX_CHECK_NOT_NULL
(
workingMemory
);
ARMARX_CHECK_NOT_NULL
(
workingMemory
);
armem
::
wm
::
query_proc
::
MemoryQueryProcessor
wm_processor
(
// Core segment processors will aquire the core segment locks.
input
.
withData
?
armem
::
DataMode
::
WithData
armem
::
wm
::
query_proc
::
MemoryQueryProcessor
wmProcessor
(
:
armem
::
DataMode
::
NoData
);
input
.
withData
?
armem
::
DataMode
::
WithData
:
armem
::
DataMode
::
NoData
);
wm
::
Memory
wmResult
=
wmProcessor
.
process
(
input
,
*
workingMemory
,
/* execute if: */
{
query
::
data
::
QueryTarget
::
WM
});
armem
::
query
::
data
::
Result
result
;
wm
::
Memory
wm_result
=
wm_processor
.
process
(
input
,
*
workingMemory
,
/* execute if: */
{
query
::
data
::
QueryTarget
::
WM
});
armem
::
ltm
::
query_proc
::
MemoryQueryProcessor
ltm_processor
;
ltm
::
Memory
ltm_result
=
ltm_processor
.
process
(
input
,
*
longtermMemory
,
/* execute if: */
{
query
::
data
::
QueryTarget
::
LTM
});
armem
::
ltm
::
query_proc
::
MemoryQueryProcessor
ltmProcessor
;
ltm
::
Memory
ltmResult
=
ltmProcessor
.
process
(
input
,
*
longtermMemory
,
/* execute if: */
{
query
::
data
::
QueryTarget
::
LTM
});
if
(
ltm_result
.
hasData
())
armem
::
query
::
data
::
Result
result
;
if
(
ltmResult
.
hasData
())
{
{
// ATTENTION: This code block moves data from LTM back into WM.
// ATTENTION: This code block moves data from LTM back into WM.
// However, since some segments are constrained, the WM might send data back to LTM.
// However, since some segments are constrained, the WM might send data back to LTM.
// This may also affect the data returned by the current query.
// This may also affect the data returned by the current query.
// However, this is expected behavior, since we copy the data in the processor (copyEmpty) we can safely return the copy and
// However, this is expected behavior, since we copy the data in the processor (copyEmpty) we can safely return the copy and
// remove the original memory reference from WM here.
// remove the original memory reference from WM here.
wm
::
Memory
ltm
_c
onverted
=
ltm
_r
esult
.
convert
();
wm
::
Memory
ltm
C
onverted
=
ltm
R
esult
.
convert
();
wm
_r
esult
.
append
(
ltm
_c
onverted
);
wm
R
esult
.
append
(
ltm
C
onverted
);
// query again to limit output size (TODO: Skip if querytype is all)
// query again to limit output size (TODO: Skip if querytype is all)
wm
::
Memory
merged_result
=
wm
_p
rocessor
.
process
(
input
,
wm
_r
esult
);
wm
::
Memory
merged_result
=
wm
P
rocessor
.
process
(
input
,
wm
R
esult
);
result
.
memory
=
toIce
<
data
::
MemoryPtr
>
(
merged_result
);
result
.
memory
=
toIce
<
data
::
MemoryPtr
>
(
merged_result
);
// also move results of ltm to wm
// also move results of ltm to wm
...
@@ -235,7 +234,7 @@ namespace armarx::armem::server
...
@@ -235,7 +234,7 @@ namespace armarx::armem::server
}
}
else
else
{
{
result
.
memory
=
toIce
<
data
::
MemoryPtr
>
(
wm
_r
esult
);
result
.
memory
=
toIce
<
data
::
MemoryPtr
>
(
wm
R
esult
);
}
}
result
.
success
=
true
;
result
.
success
=
true
;
...
@@ -247,6 +246,13 @@ namespace armarx::armem::server
...
@@ -247,6 +246,13 @@ namespace armarx::armem::server
return
result
;
return
result
;
}
}
client
::
QueryResult
MemoryToIceAdapter
::
query
(
const
client
::
QueryInput
&
input
)
{
return
client
::
QueryResult
::
fromIce
(
query
(
input
.
toIce
()));
}
// LTM LOADING FROM LTM
// LTM LOADING FROM LTM
query
::
data
::
Result
MemoryToIceAdapter
::
load
(
const
armem
::
query
::
data
::
Input
&
query
)
query
::
data
::
Result
MemoryToIceAdapter
::
load
(
const
armem
::
query
::
data
::
Input
&
query
)
{
{
...
@@ -257,6 +263,7 @@ namespace armarx::armem::server
...
@@ -257,6 +263,7 @@ namespace armarx::armem::server
return
output
;
return
output
;
}
}
// LTM STORING
// LTM STORING
data
::
StoreResult
MemoryToIceAdapter
::
store
(
const
armem
::
data
::
StoreInput
&
input
)
data
::
StoreResult
MemoryToIceAdapter
::
store
(
const
armem
::
data
::
StoreInput
&
input
)
{
{
...
@@ -284,9 +291,6 @@ namespace armarx::armem::server
...
@@ -284,9 +291,6 @@ namespace armarx::armem::server
return
output
;
return
output
;
}
}
client
::
QueryResult
MemoryToIceAdapter
::
query
(
const
client
::
QueryInput
&
input
)
{
return
client
::
QueryResult
::
fromIce
(
query
(
input
.
toIce
()));
}
}
}
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