Hey,
This question seems a bit obvious/easy but I am not able to get the KDL parser working with URDF file for making a KDL tree. I am following this tutorial, section 2.1 - KDL parser: From a file. I am not able to pass the correct filename in the function kdl_parser::treeFromFile("filename", tree)
. I tried with the model urdf name, the relative path to that file, the absolute path; all of them gives the same error while running - Error document empty. Can anyone specify how to pass the URDF file to the function?
ROS: Melodic
Edit:
As mentioned by @pmuthu2s in the comment, I added below line in the launch file.
<param name="robot_description" textfile="$(find exercise2)/model/robots/sim.urdf"/>
Also the code for parsing looks like this:
KDL::Tree lumi_tree;
std::string lumi_robot;
node.param("robot_description", lumi_robot, std::string());
if (!kdl_parser::treeFromFile(lumi_robot, lumi_tree)){
ROS_ERROR("Failed to construct kdl tree");
return false;
}
Still getting the same error. Probably I am doing something wrong here. Anyone know how to fix this?
Regards,
Anand
Originally posted by AnandGeorge on ROS Answers with karma: 56 on 2020-01-30
Post score: 0
Original comments
Comment by pmuthu2s on 2020-01-31:
Hey,
Maybe check this out Error document empty
Comment by AnandGeorge on 2020-01-31:
Added some more details in the question. Still the same error.
Comment by gvdhoorn on 2020-01-31:
Have you checked whether lumi_robot
actually contains anything?
And does cat $(rospack find exercise2)/model/robots/sim.urdf
show the expected content?
Comment by AnandGeorge on 2020-01-31:
@gvdhoorn - I can see the urdf with that cat
command. But the problem here is lumi_robot
does not have any value. Thanks for pointing out that. The launch file just launches the robot and starts rviz. I run the executable separately. Is that the reason why it cannot get the URDF from rosparams? I am able to see the URDF with rosparam get /robot_description
. I am getting the URDF as std::string lumi_robot; node.param("robot_description", lumi_robot, std::string());
Comment by AnandGeorge on 2020-01-31:
I changed the it to /robot_description
as node.param("/robot_description", lumi_robot, std::string());
. Now lumi_robot
as the content of sim.urdf
. Still I am geting Error document empty.