ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

From URDF to forward kinematics and modifying the urdf

asked 2017-02-02 08:42:25 -0600

Beaucay gravatar image

In python I was able to read in a urdf calculate the end effector pose coming from joint angles and later manipulating the urdf by accessing the urdf.joints directly:

urdf = URDF.from_xml_file(PATH)
kdl_kin = KDLKinematics(urdf, urdf.links[0].name, urdf.links[-1].name)
pose = kdl_kin.forward(joints.position)

urdf.joints[0] = [1, 2, 3]

Now I would like to achieve the same in C++. I am currently trying to use the KDL library to do this:

KDL::Tree tree;

As I see it, I should extract the chain from the tree and then use the ChainFkSolverPos to get a pose. But for extracting the chain I need the names of segments, which I can not as easily access as I did in Python. How do you get the first and last sections' names? Or is my approach totally wrong?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-02-03 02:39:08 -0600

Beaucay gravatar image

updated 2017-02-03 02:40:35 -0600

I found a solution, but I doubt it's the right one. It looks more like a workaround to me. Anyway:

    KDL::SegmentMap::const_iterator current_segment = tree.getRootSegment();
    std::vector<KDL::SegmentMap::const_iterator> children_vector = current_segment->second.children;

        current_segment = current_segment->second.children[0];
        children_vector = current_segment->second.children;

This means, I build up the Chain elementwise instead of using the getChain-function from tree.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2017-02-02 08:42:25 -0600

Seen: 578 times

Last updated: Feb 03 '17