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");
56 Eigen::Matrix<double, 6, 1>{ kdl_config_.task_weights.data() },
58 kdl_config_.max_iterations,
59 kdl_config_.eps_joints);
63 const std::string& base_link,
64 const std::string& tip_link,
66 std::string solver_name)
67 :
KDLInvKinChainLMA(scene_graph, { std::make_pair(base_link, tip_link) }, kdl_config, std::move(solver_name))
81 Eigen::Matrix<double, 6, 1>{ kdl_config_.task_weights.data() },
91 const Eigen::Ref<const Eigen::VectorXd>& seed,
94 assert(std::abs(1.0 - pose.matrix().determinant()) < 1e-6);
95 KDL::JntArray kdl_seed;
96 KDL::JntArray kdl_solution;
98 kdl_solution.resize(
static_cast<unsigned>(seed.size()));
99 Eigen::VectorXd solution(seed.size());
106 std::lock_guard<std::mutex> guard(
mutex_);
107 status =
ik_solver_->CartToJnt(kdl_seed, kdl_pose, kdl_solution);
112 #ifndef KDL_LESS_1_4_0
113 if (status == KDL::ChainIkSolverPos_LMA::E_GRADIENT_JOINTS_TOO_SMALL)
115 CONSOLE_BRIDGE_logDebug(
"KDL LMA Failed to calculate IK, gradient joints are tool small");
117 else if (status == KDL::ChainIkSolverPos_LMA::E_INCREMENT_JOINTS_TOO_SMALL)
119 CONSOLE_BRIDGE_logDebug(
"KDL LMA Failed to calculate IK, increment joints are tool small");
121 else if (status == KDL::ChainIkSolverPos_LMA::E_MAX_ITERATIONS_EXCEEDED)
123 CONSOLE_BRIDGE_logDebug(
"KDL LMA Failed to calculate IK, max iteration exceeded");
126 CONSOLE_BRIDGE_logDebug(
"KDL LMA Failed to calculate IK");
138 const Eigen::Ref<const Eigen::VectorXd>& seed)
const
KDLInvKinChainLMA(const KDLInvKinChainLMA &other)
Config kdl_config_
KDL configuration data parsed from YAML.
std::string base_link_name
Link name of first link in the kinematic object.
std::string tip_link_name
Link name of last kink in the kinematic object.
std::vector< std::string > getTipLinkNames() const override final
Get the names of the tip links of the kinematics group.
AlignedMap< std::string, Eigen::Isometry3d > TransformMap
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
std::string getSolverName() const override final
Get the name of the solver. Recommend using the name of the class.
std::string getWorkingFrame() const override final
Get the inverse kinematics working frame.
std::unique_ptr< InverseKinematics > UPtr
Eigen::Index numJoints() const override final
Number of joints in robot.
std::vector< std::string > joint_names
List of joint names.
IKSolutions calcInvKinHelper(const Eigen::Isometry3d &pose, const Eigen::Ref< const Eigen::VectorXd > &seed, int segment_num=-1) const
calcFwdKin helper function
KDL Inverse kinematic chain implementation.
KDLChainData kdl_data_
KDL data parsed from Scene Graph.
void EigenToKDL(const Eigen::Isometry3d &transform, KDL::Frame &frame)
Convert Eigen::Isometry3d to KDL::Frame.
#define TESSERACT_COMMON_IGNORE_WARNINGS_POP
std::mutex mutex_
KDL is not thread safe due to mutable variables in Joint Class.
const std::string & getRoot() const
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.
InverseKinematics::UPtr clone() const override final
Clone the forward kinematics object.
std::unique_ptr< KDL::ChainIkSolverPos_LMA > ik_solver_
KDL Inverse kinematic solver.
std::shared_ptr< const Link > getLink(const std::string &name) const
std::string solver_name_
Name of this solver.
std::vector< std::string > getJointNames() const override final
Get list of joint names for kinematic object.
KDLInvKinChainLMA & operator=(const KDLInvKinChainLMA &other)
std::vector< Eigen::VectorXd > IKSolutions
The inverse kinematics solutions container.
KDL::Chain robot_chain
KDL Chain object.
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.
std::string getBaseLinkName() const override final
Get the robot base link name.
Tesseract KDL Inverse kinematics chain Levenberg-Marquardt implementation.
void KDLToEigen(const KDL::Frame &frame, Eigen::Isometry3d &transform)
Convert KDL::Frame to Eigen::Isometry3d.