0
$\begingroup$

Rosanswers logo

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]: error while executing command
[ INFO] [1434379501.633977236]: Running 'rosrun xacro xacro.py /opt/ros/indigo/share/schunk_modular_robotics/schunk_description/urdf/lwa/lwa.urdf.xacro'...
[ERROR] [1434379501.934726406]: No name given for the robot.

As you see, it seemingly tries to do what I try and fail: creating .urdf from .xacro. Then I do another experiment: I was able to create the urdf, when I copied the whole package in my "Documents", where probably permissions are not troublesome. In there the .urdf is created, but empty. This time, I browse that empty .urdf file to see the reaction of Moveit:

[rospack] Error: no package given
[librospack]: error while executing command
[ERROR] [1434379684.002977198]: No name given for the robot.

The same thing! Which possibly means, the problem is not Moveit. The problem is created .urdf file, and as you mentioned, maybe there is something wrong with schunk .xacro file. :(


Originally posted by Damon on ROS Answers with karma: 137 on 2015-06-15

Post score: 0


Original comments

Comment by gvdhoorn on 2015-06-15:
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.

Comment by gvdhoorn on 2015-06-15:
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.

Comment by gvdhoorn on 2015-06-15:
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.

Comment by Damon on 2015-06-15:
Ow thanks. Sorry, today is my first day in this forum! Need to learn how to post things and format them properly.

Comment by Damon on 2015-06-15:
HaHa! I was wondering how my writing turned to be so nicely formatted! Automatically?! So you had done it! :D

Comment by gvdhoorn on 2015-06-15:
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).

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by gvdhoorn with karma: 86574 on 2015-06-15

This answer was ACCEPTED on the original site

Post score: 4


Original comments

Comment by Damon on 2015-06-15:
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"...

Comment by Damon on 2015-06-15:
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! :)

Comment by tengfei on 2017-10-24:
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

Comment by gvdhoorn on 2017-10-24:
@tengfei: are you not running into the same problem as in #q273819? Is your entire workspace owned by root or just some pkgs?

Comment by tengfei on 2017-10-24:
oh, yes. Sorry to ask again.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.