ros-industrial-consortium / descartes

ROS-Industrial Special Project: Cartesian Path Planner
Apache License 2.0
126 stars 92 forks source link

Added a Separate Check For Joint Limits #208

Closed Jmeyer1292 closed 6 years ago

Jmeyer1292 commented 6 years ago

For the sake of efficiency, I've broken out the check for joint limits. This let's you use the following code to search redundant joints without performing redundant collision checks:

See IKFastMoveitStateAdapter's getAllIK function:


 if (!solver->getPositionIK(poses, dummy_seed, joint_results, result, options))
  {
    return false;
  }

  const auto dof = getDOF();
  const auto index6 = dof - 1;
  const auto index4 = dof - 3;

  auto search_extras = [this, &joint_poses, index6, index4](std::vector<double>& sol)
  {
    bool collision_checked = false;

    const double joint6 = sol[index6];
    const double joint4 = sol[index4];

    for (int i = -1; i <= 1; ++i)
    {
      sol[index6] = joint6 + i * 2.0 * M_PI;
      for (int j = -1; j <= 1; ++j)
      {
        sol[index4] = joint4 + j * 2.0 * M_PI;
        if (isInLimits(sol))
        {
          if (!collision_checked)
          {
            if (isInCollision(sol)) return;
            else collision_checked = true;
          }
          joint_poses.push_back(sol);
        } // in limits
      }
    }
  };

  for (auto& sol : joint_results)
  {
    search_extras(sol);
}

I need to figure out how to nicely integrate this into IKFastStateAdapter. I don't always want to search every joint that could be searched (all of them on a UR for example). How do we let users configure this?

Please take a look @BrettHemes.