Failed to costruct kdl tree
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!
did you resolve it I have same issue