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
27c808ac
Commit
27c808ac
authored
1 year ago
by
Christoph Pohl
Browse files
Options
Downloads
Patches
Plain Diff
Fix KnownGrasp loading
parent
e8c59247
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_grasping/server/KnownGraspProviderSegment.cpp
+43
-67
43 additions, 67 deletions
...aries/armem_grasping/server/KnownGraspProviderSegment.cpp
with
43 additions
and
67 deletions
source/RobotAPI/libraries/armem_grasping/server/KnownGraspProviderSegment.cpp
+
43
−
67
View file @
27c808ac
#include
"KnownGraspProviderSegment.h"
#include
<VirtualRobot/Grasping/GraspSet.h>
#include
<VirtualRobot/XML/ObjectIO.h>
#include
<RobotAPI/libraries/armem/server/MemoryToIceAdapter.h>
#include
<ArmarXCore/core/rapidxml/wrapper/RapidXmlReader.h>
...
...
@@ -26,83 +28,57 @@ namespace armarx::armem::grasping::segment
if
(
std
::
filesystem
::
is_regular_file
(
graspFilePath
))
{
auto
reader
=
RapidXmlReader
::
FromFile
(
graspFilePath
);
RapidXmlReaderNode
root
=
reader
->
getRoot
();
std
::
string
objectClassNameXML
=
root
.
attribute_value
(
"name"
);
ARMARX_CHECK_EQUAL
(
objectClassName
,
objectClassNameXML
);
ARMARX_INFO
<<
"loading "
<<
graspFilePath
;
try
{
auto
manipulationObject
=
VirtualRobot
::
ObjectIO
::
loadManipulationObject
(
graspFilePath
);
if
(
manipulationObject
==
nullptr
)
{
ARMARX_WARNING
<<
"Invalid file content: "
<<
graspFilePath
;
return
std
::
nullopt
;
}
arondto
::
KnownGraspInfo
ret
;
ret
.
correspondingObject
.
memoryName
=
"Object"
;
ret
.
correspondingObject
.
coreSegmentName
=
"Class"
;
ret
.
correspondingObject
.
providerSegmentName
=
"PriorKnowledgeData"
;
ret
.
correspondingObject
.
entityName
=
info
.
idStr
();
ret
.
xml
.
package
=
fileLocInfo
.
package
;
ret
.
xml
.
path
=
fileLocInfo
.
relativePath
;
arondto
::
KnownGraspInfo
ret
;
ret
.
correspondingObject
.
memoryName
=
"Object"
;
ret
.
correspondingObject
.
coreSegmentName
=
"Class"
;
ret
.
correspondingObject
.
providerSegmentName
=
"PriorKnowledgeData"
;
ret
.
correspondingObject
.
entityName
=
info
.
idStr
();
ret
.
xml
.
package
=
fileLocInfo
.
package
;
ret
.
xml
.
path
=
fileLocInfo
.
relativePath
;
for
(
const
auto
&
graspSetNode
:
root
.
nodes
())
{
if
(
graspSetNode
.
name
()
!=
"GraspSet"
)
for
(
const
VirtualRobot
::
GraspSetPtr
&
graspSet
:
manipulationObject
->
getAllGraspSets
())
{
continue
;
}
ARMARX_CHECK_NOT_NULL
(
graspSet
);
arondto
::
KnownGraspSet
retGraspSet
;
arondto
::
KnownGraspSet
retGraspSet
;
retGraspSet
.
name
=
graspSet
Node
.
attribute_value
(
"name"
);
retGraspSet
.
robot
=
graspSet
Node
.
attribute_value
(
"
RobotType
"
);
retGraspSet
.
endeffector
=
graspSet
Node
.
attribute_value
(
"
EndEffector
"
);
retGraspSet
.
name
=
graspSet
->
getName
(
);
retGraspSet
.
robot
=
graspSet
->
get
RobotType
(
);
retGraspSet
.
endeffector
=
graspSet
->
get
EndEffector
(
);
for
(
const
auto
&
graspNode
:
graspSetNode
.
nodes
())
{
if
(
graspNode
.
name
()
!=
"Grasp"
)
for
(
const
VirtualRobot
::
GraspPtr
&
grasp
:
graspSet
->
getGrasps
())
{
continue
;
}
ARMARX_CHECK_NOT_NULL
(
grasp
);
arondto
::
KnownGrasp
retGrasp
;
retGrasp
.
name
=
grasp
->
getName
();
retGrasp
.
quality
=
grasp
->
getQuality
();
retGrasp
.
creator
=
grasp
->
getCreationMethod
();
retGrasp
.
pose
=
grasp
->
getTransformation
();
arondto
::
KnownGrasp
retGrasp
;
retGrasp
.
name
=
graspNode
.
attribute_value
(
"name"
);
retGrasp
.
quality
=
std
::
stof
(
graspNode
.
attribute_value
(
"quality"
));
retGrasp
.
creator
=
graspNode
.
attribute_value
(
"Creation"
);
ARMARX_CHECK
(
graspNode
.
nodes
().
size
()
==
2
or
graspNode
.
nodes
().
size
()
==
1
);
RapidXmlReaderNode
transformNode
=
graspNode
.
nodes
()[
0
];
ARMARX_CHECK_EQUAL
(
transformNode
.
name
(),
"Transform"
);
ARMARX_CHECK_EQUAL
(
transformNode
.
nodes
().
size
(),
1
);
RapidXmlReaderNode
matrixNode
=
transformNode
.
nodes
()[
0
];
ARMARX_CHECK_EQUAL
(
matrixNode
.
nodes
().
size
(),
4
);
RapidXmlReaderNode
row0
=
matrixNode
.
nodes
()[
0
];
RapidXmlReaderNode
row1
=
matrixNode
.
nodes
()[
1
];
RapidXmlReaderNode
row2
=
matrixNode
.
nodes
()[
2
];
RapidXmlReaderNode
row3
=
matrixNode
.
nodes
()[
3
];
retGrasp
.
pose
(
0
,
0
)
=
std
::
stof
(
row0
.
attribute_value
(
"c1"
));
retGrasp
.
pose
(
0
,
1
)
=
std
::
stof
(
row0
.
attribute_value
(
"c2"
));
retGrasp
.
pose
(
0
,
2
)
=
std
::
stof
(
row0
.
attribute_value
(
"c3"
));
retGrasp
.
pose
(
0
,
3
)
=
std
::
stof
(
row0
.
attribute_value
(
"c4"
));
retGrasp
.
pose
(
1
,
0
)
=
std
::
stof
(
row1
.
attribute_value
(
"c1"
));
retGrasp
.
pose
(
1
,
1
)
=
std
::
stof
(
row1
.
attribute_value
(
"c2"
));
retGrasp
.
pose
(
1
,
2
)
=
std
::
stof
(
row1
.
attribute_value
(
"c3"
));
retGrasp
.
pose
(
1
,
3
)
=
std
::
stof
(
row1
.
attribute_value
(
"c4"
));
retGrasp
.
pose
(
2
,
0
)
=
std
::
stof
(
row2
.
attribute_value
(
"c1"
));
retGrasp
.
pose
(
2
,
1
)
=
std
::
stof
(
row2
.
attribute_value
(
"c2"
));
retGrasp
.
pose
(
2
,
2
)
=
std
::
stof
(
row2
.
attribute_value
(
"c3"
));
retGrasp
.
pose
(
2
,
3
)
=
std
::
stof
(
row2
.
attribute_value
(
"c4"
));
retGrasp
.
pose
(
3
,
0
)
=
std
::
stof
(
row3
.
attribute_value
(
"c1"
));
retGrasp
.
pose
(
3
,
1
)
=
std
::
stof
(
row3
.
attribute_value
(
"c2"
));
retGrasp
.
pose
(
3
,
2
)
=
std
::
stof
(
row3
.
attribute_value
(
"c3"
));
retGrasp
.
pose
(
3
,
3
)
=
std
::
stof
(
row3
.
attribute_value
(
"c4"
));
ARMARX_VERBOSE
<<
"Found grasp '"
<<
retGrasp
.
name
<<
"' in set '"
<<
retGraspSet
.
name
<<
"' for obj '"
<<
objectClassName
<<
"' with pose
\n
"
<<
retGrasp
.
pose
;
retGraspSet
.
grasps
.
push_back
(
retGrasp
);
ARMARX_VERBOSE
<<
"Found grasp '"
<<
retGrasp
.
name
<<
"' in set '"
<<
retGraspSet
.
name
<<
"' for obj '"
<<
objectClassName
<<
"' with pose
\n
"
<<
retGrasp
.
pose
;
retGraspSet
.
grasps
.
push_back
(
retGrasp
);
}
ret
.
graspSets
[
retGraspSet
.
name
]
=
retGraspSet
;
}
ret
.
graspSets
[
retGraspSet
.
name
]
=
retGraspSet
;
return
ret
;
}
catch
(...)
{
ARMARX_WARNING
<<
graspFilePath
<<
" is not a manipulation object!"
;
return
std
::
nullopt
;
}
return
ret
;
}
return
std
::
nullopt
;
}
...
...
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