Go to the documentation of this file.
28 #include <console_bridge/console.h>
38 using Eigen::MatrixXd;
39 using Eigen::VectorXd;
42 const std::vector<std::pair<std::string, std::string>>& chains,
44 std::string solver_name)
45 : kdl_config_(kdl_config), solver_name_(std::move(solver_name))
48 throw std::runtime_error(
"The scene graph has an invalid root.");
51 throw std::runtime_error(
"Failed to parse KDL data from Scene Graph");
67 const std::string& base_link,
68 const std::string& tip_link,
70 std::string solver_name)
71 :
KDLInvKinChainNR_JL(scene_graph, { std::make_pair(base_link, tip_link) }, kdl_config, std::move(solver_name))
99 const Eigen::Ref<const Eigen::VectorXd>& seed,
102 assert(std::abs(1.0 - pose.matrix().determinant()) < 1e-6);
103 KDL::JntArray kdl_seed;
104 KDL::JntArray kdl_solution;
106 kdl_solution.resize(
static_cast<unsigned>(seed.size()));
107 Eigen::VectorXd solution(seed.size());
115 std::lock_guard<std::mutex> guard(
mutex_);
116 status =
ik_solver_->CartToJnt(kdl_seed, kdl_pose, kdl_solution);
122 if (status == KDL::ChainIkSolverPos_NR_JL::E_DEGRADED)
124 CONSOLE_BRIDGE_logDebug(
"KDL NR_JL Failed to calculate IK, solution converged to <eps in maxiter, but solution "
125 "is degraded in quality (e.g. pseudo-inverse in iksolver is singular)");
127 else if (status == KDL::ChainIkSolverPos_NR_JL::E_IKSOLVERVEL_FAILED)
129 CONSOLE_BRIDGE_logDebug(
"KDL NR_JL Failed to calculate IK, velocity IK solver failed");
131 else if (status == KDL::ChainIkSolverPos_NR_JL::E_FKSOLVERPOS_FAILED)
133 CONSOLE_BRIDGE_logDebug(
"KDL NR_JL Failed to calculate IK, position FK solver failed");
135 else if (status == KDL::ChainIkSolverPos_NR_JL::E_NO_CONVERGE)
137 CONSOLE_BRIDGE_logDebug(
"KDL NR_JL Failed to calculate IK, no solution found");
139 #ifndef KDL_LESS_1_4_0
140 else if (status == KDL::ChainIkSolverPos_NR_JL::E_MAX_ITERATIONS_EXCEEDED)
142 CONSOLE_BRIDGE_logDebug(
"KDL NR_JL Failed to calculate IK, max iteration exceeded");
147 CONSOLE_BRIDGE_logDebug(
"KDL NR_JL Failed to calculate IK");
159 const Eigen::Ref<const Eigen::VectorXd>& seed)
const
KDLChainData kdl_data_
KDL data parsed from Scene Graph.
std::unique_ptr< KDL::ChainFkSolverPos_recursive > fk_solver_
KDL Forward Kinematic Solver.
std::unique_ptr< KDL::ChainIkSolverPos_NR > ik_solver_
KDL Inverse kinematic solver.
std::unique_ptr< KDL::ChainIkSolverVel_pinv > ik_vel_solver_
KDL Inverse kinematic velocity solver.
std::string base_link_name
Link name of first link in the kinematic object.
Config kdl_config_
KDL configuration data parsed from YAML.
KDL::JntArray q_min
Lower joint limits.
std::mutex mutex_
KDL is not thread safe due to mutable variables in Joint Class.
KDLInvKinChainNR_JL(const KDLInvKinChainNR_JL &other)
std::string tip_link_name
Link name of last kink in the kinematic object.
AlignedMap< std::string, Eigen::Isometry3d > TransformMap
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
KDLInvKinChainNR_JL & operator=(const KDLInvKinChainNR_JL &other)
std::string solver_name_
Name of this solver.
std::unique_ptr< KDL::ChainIkSolverVel_pinv > ik_vel_solver_
KDL Inverse kinematic velocity solver.
std::unique_ptr< InverseKinematics > UPtr
std::vector< std::string > getJointNames() const override final
Get list of joint names for kinematic object.
std::unique_ptr< KDL::ChainIkSolverPos_NR_JL > ik_solver_
KDL Inverse kinematic solver.
Eigen::Index numJoints() const override final
Number of joints in robot.
IKSolutions calcInvKin(const tesseract_common::TransformMap &tip_link_poses, const Eigen::Ref< const Eigen::VectorXd > &seed) const override final
Calculates joint solutions given a pose for each tip link.
std::unique_ptr< KDL::ChainFkSolverPos_recursive > fk_solver_
KDL Forward Kinematic Solver.
std::vector< std::string > joint_names
List of joint names.
Config kdl_config_
KDL configuration data parsed from YAML.
KDLChainData kdl_data_
KDL data parsed from Scene Graph.
KDL Inverse kinematic chain implementation.
std::string getSolverName() const override final
Get the name of the solver. Recommend using the name of the class.
std::string getBaseLinkName() const override final
Get the robot base link name.
void EigenToKDL(const Eigen::Isometry3d &transform, KDL::Frame &frame)
Convert Eigen::Isometry3d to KDL::Frame.
#define TESSERACT_COMMON_IGNORE_WARNINGS_POP
const std::string & getRoot() const
std::shared_ptr< const Link > getLink(const std::string &name) const
IKSolutions calcInvKinHelper(const Eigen::Isometry3d &pose, const Eigen::Ref< const Eigen::VectorXd > &seed, int segment_num=-1) const
calcFwdKin helper function
KDL::JntArray q_max
Upper joint limits.
std::vector< Eigen::VectorXd > IKSolutions
The inverse kinematics solutions container.
std::vector< std::string > getTipLinkNames() const override final
Get the names of the tip links of the kinematics group.
KDL::Chain robot_chain
KDL Chain object.
InverseKinematics::UPtr clone() const override final
Clone the forward kinematics object.
std::string getWorkingFrame() const override final
Get the inverse kinematics working frame.
bool parseSceneGraph(KDLChainData &results, const tesseract_scene_graph::SceneGraph &scene_graph, const std::vector< std::pair< std::string, std::string >> &chains)
Parse KDL chain data from the scene graph.
void KDLToEigen(const KDL::Frame &frame, Eigen::Isometry3d &transform)
Convert KDL::Frame to Eigen::Isometry3d.