Skip to content

Commit

Permalink
Changed searchPositionIK to return the closest solution to the seed i…
Browse files Browse the repository at this point in the history
…n the full joint range in the no freem paramater case.
  • Loading branch information
hartmanndennis committed Aug 31, 2017
1 parent 6fb18f6 commit 3376006
Showing 1 changed file with 22 additions and 0 deletions.
Expand Up @@ -820,6 +820,28 @@ bool IKFastKinematicsPlugin::searchPositionIK(const geometry_msgs::Pose& ik_pose
return false;
}

// rotate joints by +/-360° where it is possible and useful
for (std::size_t i = 0; i < solutions.size(); i++)
{
for (std::size_t j = 0; j < num_joints_; ++j)
{
if (joint_has_limits_vector_[j])
{
double signed_distance = solutions[i][j] - ik_seed_state[j];
while (signed_distance > M_PI && solutions[i][j] - 2 * M_PI > (joint_min_vector_[j] - LIMIT_TOLERANCE))
{
signed_distance -= 2 * M_PI;
solutions[i][j] -= 2 * M_PI;
}
while (signed_distance < -M_PI && solutions[i][j] + 2 * M_PI < (joint_max_vector_[j] + LIMIT_TOLERANCE))
{
signed_distance += 2 * M_PI;
solutions[i][j] += 2 * M_PI;
}
}
}
}

// sort solutions by their distance to the seed
std::vector<LimitObeyingSol> solutions_obey_limits;
for (std::size_t i = 0; i < solutions.size(); ++i)
Expand Down

0 comments on commit 3376006

Please sign in to comment.