Skip to content
This repository has been archived by the owner on Nov 13, 2017. It is now read-only.

Commit

Permalink
fix #6
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioan Sucan committed Nov 7, 2012
1 parent b15541e commit e6d59d2
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions kinematic_model/src/kinematic_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ void kinematic_model::KinematicModel::buildGroupInfo(const boost::shared_ptr<con
// if it is, mark it as such
it->second->is_end_effector_ = true;

// check to see if there is one unique group that contains the parent link of this end effector.
// check to see if there are groups that contain the parent link of this end effector.
// record this information if found
std::vector<JointModelGroup*> possible_parent_groups;
for (std::map<std::string, JointModelGroup*>::const_iterator jt = joint_model_group_map_.begin() ; jt != joint_model_group_map_.end(); ++jt)
Expand All @@ -274,10 +274,16 @@ void kinematic_model::KinematicModel::buildGroupInfo(const boost::shared_ptr<con
if (jt->second->hasLinkModel(eefs[k].parent_link_))
possible_parent_groups.push_back(jt->second);
}
if (possible_parent_groups.size() == 1)
if (!possible_parent_groups.empty())
{
possible_parent_groups[0]->attached_end_effector_group_name_ = it->first;
it->second->end_effector_parent_.first = possible_parent_groups[0]->getName();
// if there are multiple options for the group that contains this end-effector,
// we pick the group with fewest joints.
std::size_t best = 0;
for (std::size_t g = 1 ; g < possible_parent_groups.size() ; ++g)
if (possible_parent_groups[g]->getJointModels().size() < possible_parent_groups[best]->getJointModels().size())
best = g;
possible_parent_groups[best]->attached_end_effector_group_name_ = it->first;
it->second->end_effector_parent_.first = possible_parent_groups[best]->getName();
it->second->end_effector_parent_.second = eefs[k].parent_link_;
}
break;
Expand Down

0 comments on commit e6d59d2

Please sign in to comment.