Skip to content

Commit

Permalink
Fix RobotState::getRigidlyConnectedParentLinkModel() (#2985)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rhaschke authored Sep 4, 2024
1 parent 84ba98a commit 1f23344
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions moveit_core/robot_state/src/robot_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -909,26 +909,11 @@ void RobotState::updateStateWithLinkAt(const LinkModel* link, const Eigen::Isome

const LinkModel* RobotState::getRigidlyConnectedParentLinkModel(const std::string& frame) const
{
bool found;
const LinkModel* link{ nullptr };

size_t idx = 0;
if ((idx = frame.find('/')) != std::string::npos)
{ // resolve sub frame
std::string object{ frame.substr(0, idx) };
if (!hasAttachedBody(object))
return nullptr;
auto body{ getAttachedBody(object) };
if (!body->hasSubframeTransform(frame))
return nullptr;
link = body->getAttachedLink();
}
else if (hasAttachedBody(frame))
{
link = getAttachedBody(frame)->getAttachedLink();
}
else if (getRobotModel()->hasLinkModel(frame))
link = getLinkModel(frame);

getFrameInfo(frame, link, found);
if (!found)
RCLCPP_ERROR(getLogger(), "Unable to find link for frame '%s'", frame.c_str());
return getRobotModel()->getRigidlyConnectedParentLinkModel(link);
}

Expand Down

0 comments on commit 1f23344

Please sign in to comment.