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

Problem in creating .urdf files

asked 2015-06-15 08:38:45 -0500

Damon gravatar image

updated 2015-06-15 09:55:19 -0500

gvdhoorn gravatar image

Hello everyone. I want to create .urdf file from the file lwa.urdf.xacro. My OS is Ubuntu 14.04 and ROS distribution is indigo.

In the folder: opt/ros/indigo/stacks/schunk_description/urdf/lwa

There are 3 files:

  • lwa.gazebo.xacro
  • lwa.transmission.xacro
  • lwa.urdf.xacro

In terminal, I direct to this directory and command:

ros@ros:~$ rosrun xacro xacro.py lwa.urdf.xacro > lwa.urdf

ros@ros:/opt/ros/indigo/stacks/schunk_modular_robotics/schunk_description/urdf/lwa$ rosrun xacro xacro.py lwa.urdf.xacro > lwa.urdf
bash: lwa.urdf: Permission denied

I know that my question might be somehow silly. I am sorry but it probably refers to my lack of proper knowledge, esp. with Linux. I just guess it must have something to do with permissions. I would appreciate if someone help me or share his/her experience in creating .urdf files with me.

Thanks a lot,

Damon

P.S. Why do I need .urdf file? Gazebo works with .xacro files smoothly and I already can load the robot in gazebo or send the commands to it. The point is that I want to use Moveit! Moveit has an "assistant" which helps you make Moveit recognize your robot. When I load xacro file of PR2 robot in Moveit, the assistant works fine and seemingly creates a .urdf file for itself. But this doesn't work when I load xacro file of schunk. And the reason is that Moveit tries to build .urdf file and fails. This makes me feel if I want moveit work, I should first be able to create .urdf files.


Edit:

First of all, thanks for your time and attention. :) xacro has been introduced to replace urdf. Basically we should be able to create urdf from xacro. My schunk package (schunk_description) is in: opt/ros/indigo/stacks/schunk_modular_robotics

I thought if the problem is permissions, what if I try to make a copy of the package somewhere else and try again. So I copied the package to /Documents. And:

ros@ros:~$ cd Documents

ros@ros:~/Documents$ cd schunk_modular_robotics/schunk_description/urdf/lwa

ros@ros:~/Documents/schunk_modular_robotics/schunk_description/urdf/lwa$ rosrun xacro xacro.py lwa.urdf.xacro > lwa.urdf

This created an empty .urdf file. Here is the contents:

<?xml version="1.0" ?>
<!-- =================================================================================== -->
<!-- |    This document was autogenerated by xacro from lwa.urdf.xacro                 | -->
<!-- |    EDITING THIS FILE BY HAND IS NOT RECOMMENDED                                 | -->
<!-- =================================================================================== -->
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">
</robot>

Moveit used to use .urdf file. But recently, they say the user can also browse to .xacro file as well. I think this is exactly what Moveit tries to do automatically, and probably the urdf file is also created. But since it is empty, Moveit fails. Here is when I try to browse the lwa.urdf.xacro file in Moveit:

An error message shown by setup assistant in a small window: "URDF/COLLADA file is not a valid robot model."

And when I look at the terminal, I see this:

[rospack] Error: no package given
[librospack ...
(more)
edit retag flag offensive close merge delete

Comments

It is a permission error: you (as a regular user) cannot write in that directory. But (and this will sound a bit pedantic) a better approach would be to figure out what is wrong with the schunk xacros. The Setup Assistant should be able to load it just fine.

gvdhoorn gravatar image gvdhoorn  ( 2015-06-15 09:10:22 -0500 )edit

Could you update (edit) your question with what "it doesn't work" actually means? If you get any error output on the console, please copy/paste that into your question as well.

gvdhoorn gravatar image gvdhoorn  ( 2015-06-15 09:11:05 -0500 )edit

Again a bit pedantic, but: please don't use answers to post updates. Either use a comment, or edit your original post. I've moved the content of your answer as an edit to your original question.

gvdhoorn gravatar image gvdhoorn  ( 2015-06-15 09:56:36 -0500 )edit

Ow thanks. Sorry, today is my first day in this forum! Need to learn how to post things and format them properly.

Damon gravatar image Damon  ( 2015-06-15 10:20:40 -0500 )edit

HaHa! I was wondering how my writing turned to be so nicely formatted! Automatically?! So you had done it! :D

Damon gravatar image Damon  ( 2015-06-15 10:24:47 -0500 )edit

No problem. Formatting isn't too hard: just use the buttons on the formatting bar above the text area. For console copy/paste, use the preformatted text button (the one with 101010 on it).

gvdhoorn gravatar image gvdhoorn  ( 2015-06-15 10:43:20 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
4

answered 2015-06-15 09:49:32 -0500

gvdhoorn gravatar image

updated 2015-06-15 09:54:10 -0500

As you can read on the schunk_description wiki page:

This package contains the description (mechanical, kinematic, visual, etc.) of different schunk components. The files in this package are parsed and used by a variety of other components. Most users will not interact directly with this package.

One of the consequences of this setup seems to be that the package only contains xacro macros and no top-level entities that would invoke those macros to create a valid urdf file (you probably got a "URDF/COLLADA file is not a valid robot model" together with a "No name given for the robot" error from the Setup Assistant).

This makes me feel if I want moveit work, I should first be able to create .urdf files.

That is partly true: the Setup Assistant needs a valid urdf, and you'll only get that if you create a top-level xacro that invokes the schunk_lwa macro. Something like the following should work:

<?xml version="1.0" ?>
<robot name="my_robot" xmlns:xacro="http://ros.org/wiki/xacro">

  <!-- we 'import' the macro definition from that file -->
  <xacro:include filename="$(find schunk_description)/urdf/lwa/lwa.urdf.xacro"/>

  <!-- this could be anything, but you need a 'parent' link -->
  <link name="world" />

  <!-- here we 'call' the macro and supply it with the required arguments -->
  <xacro:schunk_lwa parent="world" name="my_lwa">
    <origin rpy="0 0 0" xyz="0 0 0" />
  </xacro:schunk_lwa>
</robot>

Call this my_lwa.xacro (or something), place it in a package that is on your ROS_PACKAGE_PATH (basically, it should be in your ROS workspace) and load it in the Setup Assistant. It should then be able to load your LWA.

Note: I use the term top-level xacro file to refer to any xacro that doesn't (only) declare xacro macros itself. All files that can be converted to a valid urdf using rosrun xacro xacro .. I consider top-level.

So just to conclude: there is nothing wrong with the xacros in schunk_description, they are just not top-level xacros, meaning you cannot use them directly, but only as building blocks in other xacros.

edit flag offensive delete link more

Comments

Thanks again for your time and helps gvdhoom. I was writing some additional notes related to my question that I saw your answer right after I posted my writing. Your guesses are so true! Please take a look at my update: Exactly as you guessed: invalid urdf error. And "no name given for the robot"...

Damon gravatar image Damon  ( 2015-06-15 10:02:56 -0500 )edit

Second update: Thanks for the answer gvdhoom. I tried your approach and what I'm seeing for now is that the robot is loaded in Moveit! :)

Damon gravatar image Damon  ( 2015-06-15 10:18:47 -0500 )edit

I also met the same question when I changed some thing in the jaka.urdf.xacro and shantengfei@shantengfei-pc:~/catkin_ws/src/jaka/urdf$ rosrun xacro xacro.py jaka.urdf.xacro > jakA.urdf then it ouput bash: jakA.urdf: Permission denied I don't understand the Note. Could you give more detail

tengfei gravatar image tengfei  ( 2017-10-24 01:47:47 -0500 )edit

@tengfei: are you not running into the same problem as in #q273819? Is your entire workspace owned by root or just some pkgs?

gvdhoorn gravatar image gvdhoorn  ( 2017-10-24 02:49:51 -0500 )edit

oh, yes. Sorry to ask again.

tengfei gravatar image tengfei  ( 2017-10-24 03:17:54 -0500 )edit

Question Tools

Stats

Asked: 2015-06-15 08:38:45 -0500

Seen: 3,169 times

Last updated: Jun 15 '15