Skip to content

Commit 1f23344

Browse files
authored
Fix RobotState::getRigidlyConnectedParentLinkModel() (moveit#2985)
Simplify function using getFrameInfo() to yield the link corresponding to the given frame. The order of frame resolution was wrong here: If a link frame containing a slash was given, the code was expecting an attached body with a subframe. As these didn't exist, the function falsely returned NULL.
1 parent 84ba98a commit 1f23344

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

moveit_core/robot_state/src/robot_state.cpp

+4-19
Original file line numberDiff line numberDiff line change
@@ -909,26 +909,11 @@ void RobotState::updateStateWithLinkAt(const LinkModel* link, const Eigen::Isome
909909

910910
const LinkModel* RobotState::getRigidlyConnectedParentLinkModel(const std::string& frame) const
911911
{
912+
bool found;
912913
const LinkModel* link{ nullptr };
913-
914-
size_t idx = 0;
915-
if ((idx = frame.find('/')) != std::string::npos)
916-
{ // resolve sub frame
917-
std::string object{ frame.substr(0, idx) };
918-
if (!hasAttachedBody(object))
919-
return nullptr;
920-
auto body{ getAttachedBody(object) };
921-
if (!body->hasSubframeTransform(frame))
922-
return nullptr;
923-
link = body->getAttachedLink();
924-
}
925-
else if (hasAttachedBody(frame))
926-
{
927-
link = getAttachedBody(frame)->getAttachedLink();
928-
}
929-
else if (getRobotModel()->hasLinkModel(frame))
930-
link = getLinkModel(frame);
931-
914+
getFrameInfo(frame, link, found);
915+
if (!found)
916+
RCLCPP_ERROR(getLogger(), "Unable to find link for frame '%s'", frame.c_str());
932917
return getRobotModel()->getRigidlyConnectedParentLinkModel(link);
933918
}
934919

0 commit comments

Comments
 (0)