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
d9101188
Commit
d9101188
authored
2 years ago
by
Fabian Reister
Browse files
Options
Downloads
Patches
Plain Diff
fix: RobotReader: try-catch blocks
parent
e588be0d
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_robot_state/client/common/RobotReader.cpp
+38
-22
38 additions, 22 deletions
...libraries/armem_robot_state/client/common/RobotReader.cpp
with
38 additions
and
22 deletions
source/RobotAPI/libraries/armem_robot_state/client/common/RobotReader.cpp
+
38
−
22
View file @
d9101188
...
@@ -210,25 +210,23 @@ namespace armarx::armem::robot_state
...
@@ -210,25 +210,23 @@ namespace armarx::armem::robot_state
const
armem
::
Time
&
timestamp
)
const
const
armem
::
Time
&
timestamp
)
const
{
{
common
::
robot_state
::
localization
::
TransformQuery
query
common
::
robot_state
::
localization
::
TransformQuery
query
{
{
.
header
=
{.
parentFrame
=
OdometryFrame
,
.
header
=
{
.
frame
=
"root"
,
.
parentFrame
=
OdometryFrame
,
.
agent
=
description
.
name
,
.
frame
=
"root"
,
.
timestamp
=
timestamp
}};
.
agent
=
description
.
name
,
.
timestamp
=
timestamp
}
};
try
{
try
{
const
auto
result
=
transformReader
.
lookupTransform
(
query
);
const
auto
result
=
transformReader
.
lookupTransform
(
query
);
if
(
not
result
)
if
(
not
result
)
{
{
return
std
::
nullopt
;
return
std
::
nullopt
;
}
}
return
result
.
transform
;
return
result
.
transform
;
}
}
catch
(...)
{
catch
(...)
{
ARMARX_WARNING
<<
GetHandledExceptionString
();
ARMARX_WARNING
<<
GetHandledExceptionString
();
return
std
::
nullopt
;
return
std
::
nullopt
;
}
}
...
@@ -254,17 +252,26 @@ namespace armarx::armem::robot_state
...
@@ -254,17 +252,26 @@ namespace armarx::armem::robot_state
.
snapshots
().
beforeOrAtTime
(
timestamp
);
.
snapshots
().
beforeOrAtTime
(
timestamp
);
// clang-format on
// clang-format on
const
armem
::
client
::
QueryResult
qResult
=
memoryReader
.
query
(
qb
.
buildQueryInput
());
try
{
const
armem
::
client
::
QueryResult
qResult
=
memoryReader
.
query
(
qb
.
buildQueryInput
());
ARMARX_DEBUG
<<
"Lookup result in reader: "
<<
qResult
;
ARMARX_DEBUG
<<
"Lookup result in reader: "
<<
qResult
;
if
(
not
qResult
.
success
)
/* c++20 [[unlikely]] */
if
(
not
qResult
.
success
)
/* c++20 [[unlikely]] */
{
ARMARX_WARNING
<<
qResult
.
errorMessage
;
return
std
::
nullopt
;
}
return
getRobotJointState
(
qResult
.
memory
,
description
.
name
);
}
catch
(...)
{
{
ARMARX_WARNING
<<
qResult
.
errorMessage
;
ARMARX_WARNING
<<
deactivateSpam
(
1
)
<<
"Failed to query joint state. Reason: "
<<
GetHandledExceptionString
();
return
std
::
nullopt
;
return
std
::
nullopt
;
}
}
return
getRobotJointState
(
qResult
.
memory
,
description
.
name
);
}
}
RobotReader
::
JointTrajectory
RobotReader
::
JointTrajectory
...
@@ -335,13 +342,22 @@ namespace armarx::armem::robot_state
...
@@ -335,13 +342,22 @@ namespace armarx::armem::robot_state
RobotReader
::
queryGlobalPose
(
const
robot
::
RobotDescription
&
description
,
RobotReader
::
queryGlobalPose
(
const
robot
::
RobotDescription
&
description
,
const
armem
::
Time
&
timestamp
)
const
const
armem
::
Time
&
timestamp
)
const
{
{
const
auto
result
=
transformReader
.
getGlobalPose
(
description
.
name
,
"root"
,
timestamp
);
try
if
(
not
result
)
{
{
const
auto
result
=
transformReader
.
getGlobalPose
(
description
.
name
,
"root"
,
timestamp
);
if
(
not
result
)
{
return
std
::
nullopt
;
}
return
result
.
transform
.
transform
;
}
catch
(...)
{
ARMARX_WARNING
<<
deactivateSpam
(
1
)
<<
"Failed to query global pose. Reason: "
<<
GetHandledExceptionString
();
return
std
::
nullopt
;
return
std
::
nullopt
;
}
}
return
result
.
transform
.
transform
;
}
}
std
::
optional
<
robot
::
RobotState
>
std
::
optional
<
robot
::
RobotState
>
...
...
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