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
fcb8e784
Commit
fcb8e784
authored
3 years ago
by
Fabian Reister
Browse files
Options
Downloads
Patches
Plain Diff
articulated object reader: fixing memory queries
parent
812f59a3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!157
armem/dev => master
,
!153
Armem/dev fixes
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/RobotAPI/libraries/armem_objects/client/articulated_object/Reader.cpp
+77
-66
77 additions, 66 deletions
...raries/armem_objects/client/articulated_object/Reader.cpp
with
77 additions
and
66 deletions
source/RobotAPI/libraries/armem_objects/client/articulated_object/Reader.cpp
+
77
−
66
View file @
fcb8e784
...
@@ -6,14 +6,13 @@
...
@@ -6,14 +6,13 @@
#include
"ArmarXCore/core/logging/Logging.h"
#include
"ArmarXCore/core/logging/Logging.h"
#include
<ArmarXCore/core/PackagePath.h>
#include
<ArmarXCore/core/PackagePath.h>
#include
"RobotAPI/libraries/armem/core/Time.h"
#include
"RobotAPI/libraries/armem/client/query/Builder.h"
#include
"RobotAPI/libraries/armem/client/query/Builder.h"
#include
"RobotAPI/libraries/armem/core/Time.h"
#include
"RobotAPI/libraries/armem/core/workingmemory/CoreSegment.h"
#include
"RobotAPI/libraries/armem/core/workingmemory/CoreSegment.h"
#include
"RobotAPI/libraries/armem_robot/robot_conversions.h"
#include
"RobotAPI/libraries/armem_robot/aron_conversions.h"
#include
"RobotAPI/libraries/armem_robot/aron_conversions.h"
#include
"RobotAPI/libraries/armem_robot/robot_conversions.h"
#include
<RobotAPI/libraries/armem_robot/aron/Robot.aron.generated.h>
#include
<RobotAPI/libraries/armem_robot/aron/Robot.aron.generated.h>
namespace
fs
=
::
std
::
filesystem
;
namespace
fs
=
::
std
::
filesystem
;
namespace
armarx
::
armem
::
articulated_object
namespace
armarx
::
armem
::
articulated_object
...
@@ -38,7 +37,6 @@ namespace armarx::armem::articulated_object
...
@@ -38,7 +37,6 @@ namespace armarx::armem::articulated_object
def
->
optional
(
properties
.
providerName
,
prefix
+
"ProviderName"
);
def
->
optional
(
properties
.
providerName
,
prefix
+
"ProviderName"
);
}
}
void
Reader
::
connect
()
void
Reader
::
connect
()
{
{
// Wait for the memory to become available and add it as dependency.
// Wait for the memory to become available and add it as dependency.
...
@@ -55,7 +53,7 @@ namespace armarx::armem::articulated_object
...
@@ -55,7 +53,7 @@ namespace armarx::armem::articulated_object
memoryReader
.
setReadingMemory
(
result
.
proxy
);
memoryReader
.
setReadingMemory
(
result
.
proxy
);
armem
::
MemoryID
id
=
armem
::
MemoryID
();
armem
::
MemoryID
id
=
armem
::
MemoryID
();
id
.
memoryName
=
properties
.
memoryName
;
id
.
memoryName
=
properties
.
memoryName
;
id
.
coreSegmentName
=
properties
.
coreClassSegmentName
;
id
.
coreSegmentName
=
properties
.
coreClassSegmentName
;
// listen to all provider segments!
// listen to all provider segments!
...
@@ -72,7 +70,8 @@ namespace armarx::armem::articulated_object
...
@@ -72,7 +70,8 @@ namespace armarx::armem::articulated_object
// TODO(fabian.reister): implement
// TODO(fabian.reister): implement
}
}
void
Reader
::
updateKnownObjects
(
const
armem
::
MemoryID
&
subscriptionID
,
const
std
::
vector
<
armem
::
MemoryID
>&
snapshotIDs
)
void
Reader
::
updateKnownObjects
(
const
armem
::
MemoryID
&
subscriptionID
,
const
std
::
vector
<
armem
::
MemoryID
>&
snapshotIDs
)
{
{
ARMARX_INFO
<<
"New objects available!"
;
ARMARX_INFO
<<
"New objects available!"
;
...
@@ -89,15 +88,14 @@ namespace armarx::armem::articulated_object
...
@@ -89,15 +88,14 @@ namespace armarx::armem::articulated_object
// const armem::client::QueryResult qResult = memoryReader.query(qb.buildQueryInput());
// const armem::client::QueryResult qResult = memoryReader.query(qb.buildQueryInput());
// std::for_each(snapshotIDs.begin(), snapshotIDs.end(), [&](const auto & snapshotID)
// std::for_each(snapshotIDs.begin(), snapshotIDs.end(), [&](const auto & snapshotID)
// {
// {
// updateKnownObject(snapshotID);
// updateKnownObject(snapshotID);
// });
// });
}
}
std
::
optional
<
ArticulatedObject
>
Reader
::
get
(
const
std
::
string
&
name
,
std
::
optional
<
ArticulatedObject
>
Reader
::
get
(
const
std
::
string
&
name
,
const
armem
::
Time
&
timestamp
)
const
armem
::
Time
&
timestamp
)
{
{
const
auto
description
=
queryDescription
(
name
,
timestamp
);
const
auto
description
=
queryDescription
(
name
,
timestamp
);
...
@@ -110,17 +108,13 @@ namespace armarx::armem::articulated_object
...
@@ -110,17 +108,13 @@ namespace armarx::armem::articulated_object
return
get
(
*
description
,
timestamp
);
return
get
(
*
description
,
timestamp
);
}
}
ArticulatedObject
Reader
::
get
(
const
ArticulatedObjectDescription
&
description
,
ArticulatedObject
Reader
::
get
(
const
ArticulatedObjectDescription
&
description
,
const
armem
::
Time
&
timestamp
)
const
armem
::
Time
&
timestamp
)
{
{
ArticulatedObject
obj
ArticulatedObject
obj
{.
description
=
description
,
{
.
instance
=
""
,
// TODO(fabian.reister):
.
description
=
description
,
.
config
=
{},
// will be populated by synchronize
.
instance
=
""
,
// TODO(fabian.reister):
.
timestamp
=
timestamp
};
.
config
=
{},
// will be populated by synchronize
.
timestamp
=
timestamp
};
synchronize
(
obj
,
timestamp
);
synchronize
(
obj
,
timestamp
);
...
@@ -165,7 +159,8 @@ namespace armarx::armem::articulated_object
...
@@ -165,7 +159,8 @@ namespace armarx::armem::articulated_object
return
getRobotDescriptions
(
qResult
.
memory
);
return
getRobotDescriptions
(
qResult
.
memory
);
}
}
std
::
optional
<
robot
::
RobotDescription
>
Reader
::
queryDescription
(
const
std
::
string
&
name
,
const
armem
::
Time
&
timestamp
)
std
::
optional
<
robot
::
RobotDescription
>
Reader
::
queryDescription
(
const
std
::
string
&
name
,
const
armem
::
Time
&
timestamp
)
{
{
// Query all entities from provider.
// Query all entities from provider.
armem
::
client
::
query
::
Builder
qb
;
armem
::
client
::
query
::
Builder
qb
;
...
@@ -174,8 +169,8 @@ namespace armarx::armem::articulated_object
...
@@ -174,8 +169,8 @@ namespace armarx::armem::articulated_object
qb
qb
.
coreSegments
().
withName
(
properties
.
coreClassSegmentName
)
.
coreSegments
().
withName
(
properties
.
coreClassSegmentName
)
.
providerSegments
().
all
()
// TODO(fabian.reister): think about this: which authority is trustworthy?
.
providerSegments
().
all
()
// TODO(fabian.reister): think about this: which authority is trustworthy?
.
entities
().
withName
(
name
)
.
entities
().
all
()
//
withName(name)
.
snapshots
().
at
Time
(
timestamp
);
.
snapshots
().
l
at
est
(
);
// clang-format on
// clang-format on
const
armem
::
client
::
QueryResult
qResult
=
memoryReader
.
query
(
qb
.
buildQueryInput
());
const
armem
::
client
::
QueryResult
qResult
=
memoryReader
.
query
(
qb
.
buildQueryInput
());
...
@@ -184,13 +179,15 @@ namespace armarx::armem::articulated_object
...
@@ -184,13 +179,15 @@ namespace armarx::armem::articulated_object
if
(
not
qResult
.
success
)
/* c++20 [[unlikely]] */
if
(
not
qResult
.
success
)
/* c++20 [[unlikely]] */
{
{
ARMARX_WARNING
<<
qResult
.
errorMessage
;
return
std
::
nullopt
;
return
std
::
nullopt
;
}
}
return
getRobotDescription
(
qResult
.
memory
);
return
getRobotDescription
(
qResult
.
memory
);
}
}
std
::
optional
<
robot
::
RobotState
>
Reader
::
queryState
(
const
robot
::
RobotDescription
&
description
,
const
armem
::
Time
&
timestamp
)
std
::
optional
<
robot
::
RobotState
>
Reader
::
queryState
(
const
robot
::
RobotDescription
&
description
,
const
armem
::
Time
&
timestamp
)
{
{
// TODO(fabian.reister): how to deal with multiple providers?
// TODO(fabian.reister): how to deal with multiple providers?
...
@@ -200,9 +197,9 @@ namespace armarx::armem::articulated_object
...
@@ -200,9 +197,9 @@ namespace armarx::armem::articulated_object
// clang-format off
// clang-format off
qb
qb
.
coreSegments
().
withName
(
properties
.
coreInstanceSegmentName
)
.
coreSegments
().
withName
(
properties
.
coreInstanceSegmentName
)
.
providerSegments
().
withName
(
properties
.
providerName
)
// agent
.
providerSegments
().
all
()
//
withName(properties.providerName) // agent
.
entities
().
withName
(
description
.
name
)
.
entities
().
withName
(
description
.
name
)
.
snapshots
().
at
Time
(
timestamp
);
.
snapshots
().
l
at
est
(
);
// clang-format on
// clang-format on
const
armem
::
client
::
QueryResult
qResult
=
memoryReader
.
query
(
qb
.
buildQueryInput
());
const
armem
::
client
::
QueryResult
qResult
=
memoryReader
.
query
(
qb
.
buildQueryInput
());
...
@@ -217,76 +214,91 @@ namespace armarx::armem::articulated_object
...
@@ -217,76 +214,91 @@ namespace armarx::armem::articulated_object
return
getRobotState
(
qResult
.
memory
);
return
getRobotState
(
qResult
.
memory
);
}
}
std
::
optional
<
robot
::
RobotState
>
std
::
optional
<
robot
::
RobotState
>
Reader
::
getRobotState
(
const
armarx
::
armem
::
wm
::
Memory
&
memory
)
const
Reader
::
getRobotState
(
const
armarx
::
armem
::
wm
::
Memory
&
memory
)
const
{
{
// clang-format off
// clang-format off
const
armem
::
wm
::
ProviderSegment
&
providerSegment
=
memory
const
armem
::
wm
::
CoreSegment
&
coreSegment
=
memory
.
getCoreSegment
(
properties
.
coreInstanceSegmentName
)
.
getCoreSegment
(
properties
.
coreInstanceSegmentName
);
.
getProviderSegment
(
properties
.
providerName
);
// clang-format on
// clang-format on
const
auto
entities
=
simox
::
alg
::
get_values
(
providerSegment
.
entities
());
if
(
entities
.
empty
())
for
(
const
auto
&
[
_
,
providerSegment
]
:
coreSegment
.
providerSegments
())
{
{
ARMARX_WARNING
<<
"No entity found"
;
return
std
::
nullopt
;
}
const
auto
entit
ySnapshot
s
=
simox
::
alg
::
get_values
(
entities
.
front
().
history
());
const
auto
entit
ie
s
=
simox
::
alg
::
get_values
(
providerSegment
.
entities
());
if
(
entit
ySnapshot
s
.
empty
())
if
(
entit
ie
s
.
empty
())
{
{
ARMARX_WARNING
<<
"No entity
snapshots
found"
;
ARMARX_WARNING
<<
"No entity found"
;
return
std
::
nullopt
;
continue
;
}
}
// TODO(fabian.reister): check if 0 available
const
auto
entitySnapshots
=
simox
::
alg
::
get_values
(
entities
.
front
().
history
());
const
armem
::
wm
::
EntityInstance
&
instance
=
entitySnapshots
.
front
().
getInstance
(
0
);
return
robot
::
convertRobotState
(
instance
);
if
(
entitySnapshots
.
empty
())
}
{
ARMARX_WARNING
<<
"No entity snapshots found"
;
continue
;
}
// TODO(fabian.reister): check if 0 available
const
armem
::
wm
::
EntityInstance
&
instance
=
entitySnapshots
.
front
().
getInstance
(
0
);
return
robot
::
convertRobotState
(
instance
);
}
return
std
::
nullopt
;
}
std
::
optional
<
robot
::
RobotDescription
>
Reader
::
getRobotDescription
(
const
armarx
::
armem
::
wm
::
Memory
&
memory
)
const
std
::
optional
<
robot
::
RobotDescription
>
Reader
::
getRobotDescription
(
const
armarx
::
armem
::
wm
::
Memory
&
memory
)
const
{
{
// clang-format off
// clang-format off
const
armem
::
wm
::
Provider
Segment
&
provider
Segment
=
memory
const
armem
::
wm
::
Core
Segment
&
core
Segment
=
memory
.
getCoreSegment
(
properties
.
coreClassSegmentName
)
.
getCoreSegment
(
properties
.
coreClassSegmentName
)
;
.
getProviderSegment
(
properties
.
providerName
);
// TODO(fabian.reister): all
//
.getProviderSegment(properties.providerName); // TODO(fabian.reister): all
// clang-format on
// clang-format on
const
auto
entities
=
simox
::
alg
::
get_values
(
providerSegment
.
entities
());
if
(
entities
.
empty
())
for
(
const
auto
&
[
_
,
providerSegment
]
:
coreSegment
.
providerSegments
())
{
{
ARMARX_WARNING
<<
"No entity found"
;
const
auto
entities
=
simox
::
alg
::
get_values
(
providerSegment
.
entities
());
return
std
::
nullopt
;
}
if
(
entities
.
empty
())
{
ARMARX_WARNING
<<
"No entity found"
;
continue
;
// return std::nullopt;
}
const
auto
entitySnapshots
=
simox
::
alg
::
get_values
(
entities
.
front
().
history
());
const
auto
entitySnapshots
=
simox
::
alg
::
get_values
(
entities
.
front
().
history
());
if
(
entitySnapshots
.
empty
())
if
(
entitySnapshots
.
empty
())
{
{
ARMARX_WARNING
<<
"No entity snapshots found"
;
ARMARX_WARNING
<<
"No entity snapshots found"
;
return
std
::
nullopt
;
continue
;
}
// return std::nullopt;
}
// TODO(fabian.reister): check if 0 available
const
armem
::
wm
::
EntityInstance
&
instance
=
entitySnapshots
.
front
().
getInstance
(
0
);
// TODO(fabian.reister): check if 0 available
return
robot
::
convertRobotDescription
(
instance
);
const
armem
::
wm
::
EntityInstance
&
instance
=
entitySnapshots
.
front
().
getInstance
(
0
);
}
return
robot
::
convertRobotDescription
(
instance
)
;
return
std
::
nullopt
;
}
}
std
::
vector
<
robot
::
RobotDescription
>
Reader
::
getRobotDescriptions
(
const
armarx
::
armem
::
wm
::
Memory
&
memory
)
const
std
::
vector
<
robot
::
RobotDescription
>
Reader
::
getRobotDescriptions
(
const
armarx
::
armem
::
wm
::
Memory
&
memory
)
const
{
{
std
::
vector
<
robot
::
RobotDescription
>
descriptions
;
std
::
vector
<
robot
::
RobotDescription
>
descriptions
;
const
armem
::
wm
::
CoreSegment
&
coreSegment
=
memory
.
getCoreSegment
(
properties
.
coreClassSegmentName
);
const
armem
::
wm
::
CoreSegment
&
coreSegment
=
memory
.
getCoreSegment
(
properties
.
coreClassSegmentName
);
for
(
const
auto
&
[
providerName
,
providerSegment
]
:
coreSegment
.
providerSegments
())
for
(
const
auto
&
[
providerName
,
providerSegment
]
:
coreSegment
.
providerSegments
())
{
{
for
(
const
auto
&
[
name
,
entity
]
:
providerSegment
.
entities
())
for
(
const
auto
&
[
name
,
entity
]
:
providerSegment
.
entities
())
{
{
if
(
entity
.
empty
())
if
(
entity
.
empty
())
{
{
...
@@ -309,5 +321,4 @@ namespace armarx::armem::articulated_object
...
@@ -309,5 +321,4 @@ namespace armarx::armem::articulated_object
return
descriptions
;
return
descriptions
;
}
}
}
// namespace armarx::armem::articulated_object
}
// namespace armarx::armem::articulated_object
\ No newline at end of file
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