ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I thought the kdl_parser tutorial gave a fairly clear usage explanation:
#include <kdl_parser/kdl_parser.hpp>
KDL::Tree robot_kin;
kdl_parser::treeFromFile("my_robot.urdf", robot_kin);
(the tutorial also provides similar examples for initializing from a parameter or string)
Once you have a KDL::Tree, you probably want to calculate various sorts of kinematics. The KDL Documentation provides some good examples here:
KDL::Chain chain;
robot_kin.getChain("base_link", "tool", chain);
KDL::JntArray joint_pos(chain.getNrOfJoints());
KDL::Frame cart_pos;
KDL::ChainFkSolverPos_recursive fk_solver(chain);
fk_solver.JntToCart(joint_pos, cart_pos);
However, you might consider staying within the ROS framework for basic kinematics, rather than working in KDL directly. This allows you to use ROS functions to extract different kinematic groups, use robot-specific kinematics plugins, detect collisions, etc.
The approach differs between whether you are using arm_navigation or moveIt. Both are fairly well documented, with examples at the links given above.