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,
43 std::string solver_name)
44 : solver_name_(std::move(solver_name))
47 throw std::runtime_error(
"The scene graph has an invalid root.");
50 throw std::runtime_error(
"Failed to parse KDL data from Scene Graph");
52 fk_solver_ = std::make_unique<KDL::ChainFkSolverPos_recursive>(kdl_data_.robot_chain);
53 jac_solver_ = std::make_unique<KDL::ChainJntToJacSolver>(kdl_data_.robot_chain);
57 const std::string& base_link,
58 const std::string& tip_link,
59 std::string solver_name)
60 :
KDLFwdKinChain(scene_graph, { std::make_pair(base_link, tip_link) }, std::move(solver_name))
81 throw std::runtime_error(
"kdl_joints size is not correct!");
83 KDL::JntArray kdl_joints;
88 std::lock_guard<std::mutex> guard(
mutex_);
92 Eigen::Isometry3d pose;
103 assert(joint_angles.size() ==
numJoints());
109 const Eigen::Ref<const Eigen::VectorXd>& joint_angles,
110 int segment_num)
const
112 KDL::JntArray kdl_joints;
116 jacobian.resize(
static_cast<unsigned>(joint_angles.size()));
119 std::lock_guard<std::mutex> guard(
mutex_);
120 success =
jac_solver_->JntToJac(kdl_joints, jacobian, segment_num);
125 CONSOLE_BRIDGE_logError(
"Failed to calculate jacobian");
133 const std::string& link_name)
const
135 assert(joint_angles.size() ==
numJoints());
138 KDL::Jacobian kdl_jacobian;
142 Eigen::MatrixXd jacobian(6,
numJoints());
147 throw std::runtime_error(
"KDLFwdKinChain: Failed to calculate jacobian.");
tesseract_common::TransformMap calcFwdKinHelperAll(const Eigen::Ref< const Eigen::VectorXd > &joint_angles) const
calcFwdKin helper function
Tesseract KDL forward kinematics chain implementation.
KDLFwdKinChain & operator=(const KDLFwdKinChain &other)
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::string getBaseLinkName() const override final
Get the robot base link name.
AlignedMap< std::string, Eigen::Isometry3d > TransformMap
std::map< std::string, int > segment_index
A map from chain link name to kdl chain segment number.
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
std::unique_ptr< KDL::ChainFkSolverPos_recursive > fk_solver_
std::string getSolverName() const override final
Get the name of the solver. Recommend using the name of the class.
std::mutex mutex_
KDL is not thread safe due to mutable variables in Joint Class.
std::vector< std::string > joint_names
List of joint names.
std::string solver_name_
Name of this solver.
std::vector< std::string > getTipLinkNames() const override final
Get list of tip link names for kinematic object.
KDLFwdKinChain(const KDLFwdKinChain &other)
KDL kinematic chain implementation.
ForwardKinematics::UPtr clone() const override final
Clone the forward kinematics object.
std::vector< std::string > getJointNames() const override final
Get list of joint names for kinematic object.
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::unique_ptr< ForwardKinematics > UPtr
Tesseract KDL utility functions.
std::shared_ptr< const Link > getLink(const std::string &name) const
Eigen::MatrixXd calcJacobian(const Eigen::Ref< const Eigen::VectorXd > &joint_angles, const std::string &joint_link_name) const override final
Calculates the Jacobian matrix for a given joint state in the reference frame of the specified link.
KDL::Chain robot_chain
KDL Chain object.
bool calcJacobianHelper(KDL::Jacobian &jacobian, const Eigen::Ref< const Eigen::VectorXd > &joint_angles, int segment_num=-1) const
calcJacobian helper function
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::unique_ptr< KDL::ChainJntToJacSolver > jac_solver_
Eigen::Index numJoints() const override final
Number of joints in robot.
void KDLToEigen(const KDL::Frame &frame, Eigen::Isometry3d &transform)
Convert KDL::Frame to Eigen::Isometry3d.
tesseract_common::TransformMap calcFwdKin(const Eigen::Ref< const Eigen::VectorXd > &joint_angles) const override final
Calculates the transform for each tip link in the kinematic group.