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

Failed to costruct kdl tree

asked 2016-06-02 11:42:50 -0500

g.paulo gravatar image

Hi all,

I was able to make a c++ code in directory1 inside catkin_ws/src, I include in the code urdf/model.h,kdl/chain.hpp, eigen3/Eigen/Core,kdl_parser/kdl_parser.hpp. I made catkin_make and all goes right.

In another directory, always inside catkin_ws/src, (catkin_ws/src/my_arm/my_arm_description/urdf) I have the description of a gazebo arm. The description of this object is in .xacro file. I want to obtain some information of this arm through KDL and kdl_parser, like jacobian and dynamic matrix. I tried to do this in the code said previously. This is the code:

#include "ros/ros.h"
#include "std_msgs/String.h"
#include <sstream>
#include <eigen3/Eigen/Core>
#include <kdl_parser/kdl_parser.hpp>
#include <kdl/chainiksolvervel_wdls.hpp>
#include <kdl/chainfksolverpos_recursive.hpp>
#include <urdf/model.h>
#include <kdl/chain.hpp>

int main(int argc, char **argv)
{
    ros::init(argc, argv, "node");
        if (!ros::isInitialized()) //check if ros is initialized properly
            {
              ROS_FATAL("ROS has not been initialized!");
              return -1;
            }   
     KDL::Tree tree;
    KDL::Chain chain;
    ros::NodeHandle node;

   if (!kdl_parser::treeFromFile("my_arm.xacro", tree)){
      ROS_ERROR("Failed to construct kdl tree");
      return 0;
   }
}

When I run roscore and in another terminal

rosun directory1 mycode

I have these errors :

[ERROR] [1464884148.468038102]: Error document empty.
[ERROR] [1464884148.468221642]: Could not generate robot model
[ERROR] [1464884148.468281356]: Failed to construct kdl tree

It seems that the code isn't able to read the xacro file. Is it true? For create this code I followed the structure in this link, in particular in the section "From a file".

What am I doing wrong?

Have I to follow another section (like "from a URDF")? If it is so, how have I to introduce the .xacro file in the code?

Thank you!

edit retag flag offensive close merge delete

Comments

did you resolve it I have same issue

ZainMehdi gravatar image ZainMehdi  ( 2016-11-13 13:04:25 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-11-08 07:36:18 -0500

KARIM gravatar image

I have posted here how it worked for me, you can have a look at the last answer by using param name="robot_description"
kdl_parser::treeFromString(robot_desc_string, tree)

link gazebo_forum

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-06-02 11:42:50 -0500

Seen: 530 times

Last updated: Nov 08 '18