Robotics StackExchange | Archived questions

Define KDL tree from URDF file outside ROS

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.

Asked by ravijoshi on 2019-02-21 05:23:45 UTC

Comments

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.

Asked by gvdhoorn on 2019-02-21 05:27:53 UTC

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.

Asked by gvdhoorn on 2019-02-21 05:29:41 UTC

@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.

Asked by ravijoshi on 2019-02-21 08:57:59 UTC

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.

Asked by ravijoshi on 2019-02-21 09:19:35 UTC

Answers

Hey,

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);
  file_xml.LoadFile();
  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;
   }
}

Asked by pmuthu2s on 2019-08-26 04:24:31 UTC

Comments

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

Asked by ravijoshi on 2019-08-26 06:27:06 UTC