Ask Your Question
0

KDL parser: URDF parsing issue

asked 2020-01-30 17:26:44 -0600

AnandGeorge gravatar image

updated 2020-01-31 04:04:55 -0600

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

edit retag flag offensive close merge delete

Comments

Hey, Maybe check this out Error document empty

pmuthu2s gravatar image pmuthu2s  ( 2020-01-31 02:37:01 -0600 )edit

Added some more details in the question. Still the same error.

AnandGeorge gravatar image AnandGeorge  ( 2020-01-31 04:04:42 -0600 )edit

Have you checked whether lumi_robot actually contains anything?

And does cat $(rospack find exercise2)/model/robots/sim.urdf show the expected content?

gvdhoorn gravatar image gvdhoorn  ( 2020-01-31 04:30:50 -0600 )edit

@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());

AnandGeorge gravatar image AnandGeorge  ( 2020-01-31 05:14:58 -0600 )edit

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.

AnandGeorge gravatar image AnandGeorge  ( 2020-01-31 05:39:21 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-01-31 08:11:28 -0600

AnandGeorge gravatar image

updated 2020-01-31 08:37:00 -0600

As mentioned in the question, I was trying to get the KDL tree of the robot by loading the URDF using treeFromFile() function with taking the URDF from the params server. I changed it to treeFromString() as the URDF is stored as a string after getting it from the params server. Below is the modified code.

KDL::Tree lumi_tree;
std::string lumi_robot;
node.param("/robot_description", lumi_robot, std::string());
if (!kdl_parser::treeFromString(lumi_robot, lumi_tree)){
    ROS_ERROR("Failed to construct kdl tree");
    return false;
}

Now the KDL tree is formed and is used for further calculations.

Thanks @pmuthu2s and @gvdhoorn for their inputs.

edit flag offensive delete link more

Comments

No problem

pmuthu2s gravatar image pmuthu2s  ( 2020-02-03 10:45:38 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2020-01-30 17:26:44 -0600

Seen: 232 times

Last updated: Jan 31 '20