Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RobotState::getRigidlyConnectedParentLinkModel() (backport #2985) #2993

Merged
merged 3 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 5 additions & 20 deletions moveit_core/robot_state/src/robot_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -801,26 +801,11 @@ void RobotState::updateStateWithLinkAt(const LinkModel* link, const Eigen::Isome

const LinkModel* RobotState::getRigidlyConnectedParentLinkModel(const std::string& frame) const
{
const moveit::core::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);

bool found;
const LinkModel* link{ nullptr };
getFrameInfo(frame, link, found);
if (!found)
RCLCPP_ERROR(LOGGER, "Unable to find link for frame '%s'", frame.c_str());
return getRobotModel()->getRigidlyConnectedParentLinkModel(link);
}

Expand Down
1 change: 1 addition & 0 deletions moveit_core/robot_state/test/robot_state_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,7 @@ TEST_F(OneRobot, rigidlyConnectedParent)
EXPECT_EQ(robot_model_->getRigidlyConnectedParentLinkModel(link_b), link_a);

moveit::core::RobotState state(robot_model_);
state.updateLinkTransforms();

EXPECT_EQ(state.getRigidlyConnectedParentLinkModel("link_b"), link_a);

Expand Down
Loading