ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Define KDL tree from URDF file outside ROS

asked 2019-02-21 04:23:45 -0600

ravijoshi gravatar image

I have a URDF file of my robot, I am trying to define KDL tree inside C++ something like following:

KDL::Tree my_tree;
if (!kdl_parser::treeFromFile("robot.urdf", my_tree)){
    std::cout << "Failed to construct kdl tree"<< std::endl;
    return false;

The above code works with ROS. However, in another project, which is not a ROS project, I need to construct this KDL tree. This computer doesn't have ROS and sadly the OS is Windows.

How to install kdl_parser without using ROS.

_PS: I do not want to install ROS on Windows for this task._

edit retag flag offensive close merge delete


So as this is Windows, KDL is ROS agnostic and you state you don't want to install ROS, I'm thinking this is no longer a question suitable for ROS Answers.

If you feel otherwise, please clarify.

gvdhoorn gravatar image gvdhoorn  ( 2019-02-21 04:27:53 -0600 )edit

For the non-ROS integrated version of KDL, see orocos/orocos_kinematics_dynamics.

Note: parsing URDFs is possible "without ROS", but things like package:// URIs and substitution args will most likely not work, limiting you signficantly.

gvdhoorn gravatar image gvdhoorn  ( 2019-02-21 04:29:41 -0600 )edit

@gvdhoorn: Thank you very much. I am looking into the GitHub you shared. However, I am still not able to find out the API to parse URDF without ROS. Can you please once again explain how to parse URDF without ROS"? Maybe you can write down this as an answer! It can solve my issue! Thanks again.

ravijoshi gravatar image ravijoshi  ( 2019-02-21 07:57:59 -0600 )edit

Please note that all the joints are revolute and I am only interested in performing forward Kinematics. I am not interested in any graphics and just a skeleton (line) model is fine for me.

ravijoshi gravatar image ravijoshi  ( 2019-02-21 08:19:35 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2019-08-26 04:24:31 -0600

pmuthu2s gravatar image


I know it is very late!

But here is the solution for the same ! May be it will be helpful to others!

#include <kdl_parser/kdl_parser.hpp>
#include <urdf/model.h>
#include <iostream>

int main(int argc, char** argv)
  std::string filename = "PATH to URDF";
  TiXmlDocument file_xml(filename);
  KDL::Tree my_tree;
  urdf::Model my_model;
    if (!my_model.initXml(&file_xml))
             std::cout<<"Failed to parse urdf robot model";
            return false;
    if (!kdl_parser::treeFromFile(filename, my_tree)){
      std::cout<<"Failed to construct kdl tree";
      return false;
edit flag offensive delete link more


Can you tell me how do you install kdl_parser and urdf without installing ROS?

ravijoshi gravatar image ravijoshi  ( 2019-08-26 06:27:06 -0600 )edit

Question Tools

1 follower


Asked: 2019-02-21 04:23:45 -0600

Seen: 643 times

Last updated: Aug 26 '19