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
11d0e8fe
Commit
11d0e8fe
authored
3 years ago
by
Rainer Kartmann
Browse files
Options
Downloads
Patches
Plain Diff
Update usage of forEach in reader
parent
4269f509
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!188
ArMem Updates
,
!185
Clean up interfaces and unneeded code in memory core classes
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/RobotAPI/libraries/armem_objects/client/articulated_object/Reader.cpp
+29
-66
29 additions, 66 deletions
...raries/armem_objects/client/articulated_object/Reader.cpp
with
29 additions
and
66 deletions
source/RobotAPI/libraries/armem_objects/client/articulated_object/Reader.cpp
+
29
−
66
View file @
11d0e8fe
...
@@ -242,32 +242,19 @@ namespace armarx::armem::articulated_object
...
@@ -242,32 +242,19 @@ namespace armarx::armem::articulated_object
.
getCoreSegment
(
properties
.
coreInstanceSegmentName
);
.
getCoreSegment
(
properties
.
coreInstanceSegmentName
);
// clang-format on
// clang-format on
for
(
const
auto
&
[
_
,
providerSegment
]
:
coreSegment
.
providerSegments
())
std
::
optional
<
wm
::
EntityInstance
>
instance
;
coreSegment
.
forEachInstance
([
&
instance
](
const
wm
::
EntityInstance
&
i
)
{
{
instance
=
i
;
const
auto
entities
=
simox
::
alg
::
get_values
(
providerSegment
.
entities
());
});
if
(
instance
.
has_value
())
if
(
entities
.
empty
())
{
{
return
robot
::
convertRobotState
(
instance
.
value
());
ARMARX_WARNING
<<
"No entity found"
;
}
continue
;
else
}
{
return
std
::
nullopt
;
const
auto
entitySnapshots
=
simox
::
alg
::
get_values
(
entities
.
front
().
history
());
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
;
}
}
...
@@ -275,67 +262,43 @@ namespace armarx::armem::articulated_object
...
@@ -275,67 +262,43 @@ namespace armarx::armem::articulated_object
Reader
::
getRobotDescription
(
const
armarx
::
armem
::
wm
::
Memory
&
memory
)
const
Reader
::
getRobotDescription
(
const
armarx
::
armem
::
wm
::
Memory
&
memory
)
const
{
{
// clang-format off
// clang-format off
const
armem
::
wm
::
CoreSegment
&
coreSegment
=
memory
const
armem
::
wm
::
CoreSegment
&
coreSegment
=
memory
.
getCoreSegment
(
properties
.
coreClassSegmentName
);
.
getCoreSegment
(
properties
.
coreClassSegmentName
);
// clang-format on
// clang-format on
for
(
const
auto
&
[
_
,
providerSegment
]
:
coreSegment
.
providerSegments
())
std
::
optional
<
wm
::
EntityInstance
>
instance
;
coreSegment
.
forEachInstance
([
&
instance
](
const
wm
::
EntityInstance
&
i
)
{
{
const
auto
entities
=
simox
::
alg
::
get_values
(
providerSegment
.
entities
());
instance
=
i
;
});
if
(
entities
.
empty
())
if
(
instance
.
has_value
())
{
{
ARMARX_WARNING
<<
"No entity found"
;
return
convertRobotDescription
(
instance
.
value
());
continue
;
}
}
else
{
const
auto
entitySnapshots
=
simox
::
alg
::
get_values
(
entities
.
front
().
history
());
return
std
::
nullopt
;
if
(
entitySnapshots
.
empty
())
{
ARMARX_WARNING
<<
"No entity snapshots found"
;
continue
;
}
if
(
entitySnapshots
.
front
().
hasInstance
(
0
))
{
const
armem
::
wm
::
EntityInstance
&
instance
=
entitySnapshots
.
front
().
getInstance
(
0
);
return
convertRobotDescription
(
instance
);
}
}
}
return
std
::
nullopt
;
}
}
std
::
vector
<
robot
::
RobotDescription
>
std
::
vector
<
robot
::
RobotDescription
>
Reader
::
getRobotDescriptions
(
const
armarx
::
armem
::
wm
::
Memory
&
memory
)
const
Reader
::
getRobotDescriptions
(
const
armarx
::
armem
::
wm
::
Memory
&
memory
)
const
{
{
std
::
vector
<
robot
::
RobotDescription
>
descriptions
;
const
armem
::
wm
::
CoreSegment
&
coreSegment
=
const
armem
::
wm
::
CoreSegment
&
coreSegment
=
memory
.
getCoreSegment
(
properties
.
coreClassSegmentName
);
memory
.
getCoreSegment
(
properties
.
coreClassSegmentName
);
for
(
const
auto
&
[
providerName
,
providerSegment
]
:
coreSegment
.
providerSegments
())
std
::
vector
<
robot
::
RobotDescription
>
descriptions
;
coreSegment
.
forEachEntity
([
&
descriptions
](
const
wm
::
Entity
&
entity
)
{
{
for
(
const
auto
&
[
name
,
entity
]
:
providerSegment
.
entities
())
if
(
not
entity
.
empty
())
{
{
if
(
entity
.
empty
())
const
auto
robotDescription
=
convertRobotDescription
(
entity
.
getFirstSnapshot
().
getInstance
(
0
));
{
ARMARX_WARNING
<<
"No entity found"
;
continue
;
}
const
auto
entitySnapshots
=
simox
::
alg
::
get_values
(
entity
.
history
());
const
armem
::
wm
::
EntityInstance
&
instance
=
entitySnapshots
.
front
().
getInstance
(
0
);
const
auto
robotDescription
=
convertRobotDescription
(
instance
);
if
(
robotDescription
)
if
(
robotDescription
)
{
{
descriptions
.
push_back
(
*
robotDescription
);
descriptions
.
push_back
(
*
robotDescription
);
}
}
}
}
}
}
);
return
descriptions
;
return
descriptions
;
}
}
...
...
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