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

Tutorial: Parse a urdf file

asked 2014-04-04 03:10:47 -0500

ROSnewbie11 gravatar image

updated 2014-04-06 21:47:22 -0500

The question is: In which directory am I supposed to be during the various steps ?

This question has confused me again and probably made me do some mistakes along the way.

I'm trying to follow the tutorial Parse a urdf file.

Below is a desription on how i guess where to be in the steps of the tutorial.

From the beginning of the tutorial:

$ cd ~/catkin_ws/src
$ catkin_create_pkg testbot_description urdf
$ cd testbot_description
$ mkdir urdf

(well, this is straight forward. Here we are placed in

~/catkin_ws/src/testbot_description        creating the subdirectory
~/catkin_ws/src/testbot_description/urdf  )

Next step:

cp /path/to/.../testbot_description/urdf/my_robot.urdf .

is a bit confusing since the file "my_robot.urdf" created in the previous tutorial Create your own urdf file was createde in a entirly different directory than indicated in the suggested command since the directory:

 ~/catkin_ws/src/testbot_description/urdf

did not exist at all at the time.


Next step:

In the next step you are in directory

 ~/catkin_ws/src/testbot_description/urdf

Now you create a subdirectory "src"

> ~/catkin_ws/src/testbot_description/urdf/src
                                           ^^^
                                           ^^^

but you create parser.cpp when still being in:

> ~/catkin_ws/src/testbot_description/urdf
                                      ^^^^
                                      ^^^^
                                      ^^^^

but saving parser.cpp into directory

~/catkin_ws/src/testbot_description/urdf/src

(here I think i made a mistake by saving parser.cpp into:

~/catkin_ws/src/testbot_description/urdf       I.E.   not into:
~/catkin_ws/src/testbot_description/urdf/src )

Next step

I'm quoting:

...First add the following lines to your CMakeList.txt file: ...

This leads to the question: which "CMakeList.txt" ?

Just by following the general tutorial (and rosserial) I have:

~/ros/src/agitr/CMakeLists.txt
~/ros/src/CMakeLists.txt
~/catkin_ws/build/catkin_generated/metapackages/rosserial/CMakeLists.txt
~/catkin_ws/src/beginner_tutorials/CMakeLists.txt
~/catkin_ws/src/CMakeLists.txt
~/catkin_ws/src/rosserial/rosserial/CMakeLists.txt
~/catkin_ws/src/rosserial/rosserial_embeddedlinux/CMakeLists.txt
~/catkin_ws/src/rosserial/rosserial_client/CMakeLists.txt
~/catkin_ws/src/rosserial/rosserial_msgs/CMakeLists.txt
~/catkin_ws/src/rosserial/rosserial_arduino/CMakeLists.txt
~/catkin_ws/src/rosserial/rosserial_xbee/CMakeLists.txt
~/catkin_ws/src/rosserial/rosserial_python/CMakeLists.txt
~/catkin_ws/src/rosserial/rosserial_server/CMakeLists.txt
~/catkin_ws/src/testbot_description/urdf/src/CMakeLists.txt
~/catkin_ws/src/testbot_description/CMakeLists.txt
~/ROStest/build/catkin_generated/metapackages/rosserial/CMakeLists.txt
~/ROStest/src/CMakeLists.txt
~/ROStest/src/rosserial/rosserial/CMakeLists.txt
~/ROStest/src/rosserial/rosserial_embeddedlinux/CMakeLists.txt
~/ROStest/src/rosserial/rosserial_client/CMakeLists.txt
~/ROStest/src/rosserial/rosserial_msgs/CMakeLists.txt
~/ROStest/src/rosserial/rosserial_arduino/CMakeLists.txt
~/ROStest/src/rosserial/rosserial_xbee/CMakeLists.txt
~/ROStest/src/rosserial/rosserial_python/CMakeLists.txt
~/ROStest/src/rosserial/rosserial_server/CMakeLists.txt

I guess it's either of these two:

~/catkin_ws/src/testbot_description/urdf/src/CMakeLists.txt
~/catkin_ws/src/testbot_description/CMakeLists.txt

Most probably

~/catkin_ws/src/testbot_description/CMakeLists.txt

since the other CMakeLists.txt has the following text at the top:

   "#toplevel CMakeLists.txt for a catkin workspace"

Next step

I asume where still in directory:

~/catkin_ws/src/testbot_description/urdf

so running catkin_make yields as follows:

~/catkin_ws/src/testbot_description/urdf$ 
~/catkin_ws/src/testbot_description/urdf$ 
~/catkin_ws/src/testbot_description/urdf$ catkin_make

Base path:     ~/catkin_ws/src/testbot_description/urdf
Source space:  ~/catkin_ws/src/testbot_description/urdf/src
Build space:   ~/catkin_ws/src/testbot_description/urdf/build
Devel ...
(more)
edit retag flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted
3

answered 2014-04-04 05:26:33 -0500

dornhege gravatar image

The tutorials beyond the beginner tutorials might assume some basic knowledge about package layout, catkin usage, rosrun, etc. Therefore they might not be suited to blindly follow commands as common steps might be left out, although ideally they are. You would need this knowledge anyways to apply the solution to your package. Going through the fixes one by one should hopefully clear those things up.

  1. The idea is to copy the URDF created before "whereever" to the new urdf directory you created, i.e. to ~/catkin_ws/src/testbot_description/urdf.
  2. Sources are usually put in the src directory of a package, so you should end up with parser.cpp in ~/catkin_ws/src/testbot_description/src and nothing else created anywhere.
  3. The only CMakeLists.txt that makes sense is the one in your package. After all that's what you're working on. That would be ~/catkin_ws/src/testbot_description/CMakeLists.txt. The other one ~/catkin_ws/src/testbot_description/urdf/src/CMakeLists.txt should not be there at all. You might have generated that accidentally by calling catkin_make here.
  4. catkin_make has to be called from the workspace root, i.e. from ~/catkin_ws/src/.
  5. The binary being built will be called parser like the cmake target name, not parser.cpp. As there was nothing build, it's also not there yet. The canonical way to run this would be by calling rosrun <PKG> <NAME>. I don't know why the tutorial uses a fixed path like ./devel/....
edit flag offensive delete link more

Comments

Thanks a lot ! This was the information I wanted. I'm trying to understand what I'm doing, not just blindly following the tutorial, just to be able to avoid getting stuck as you suggest. This tutorial is marked as as a beginners level tutorial. 1. Got that. 2. So I guessed. 3. I think I have a general understanding of this from previous tutorials but as a newcommer you tend to follow the lead (at first), it might be some new trick or quirk thaugt. 4. I have that in the back of my head and I guess I have to read some more on the subject. But previous comment applies here to. 5. You can understand my confusion. Textual communication is difficult. Again, thank you for taking your time to answer.

ROSnewbie11 gravatar image ROSnewbie11  ( 2014-04-06 22:55:54 -0500 )edit
1

The command "catkin_make" don't like to be run from "~/catkin_ws/src/" but from ~/catkin_ws/. In the file "~/catkin_ws/src/testbot_description/CMakeLists.txt" when the row: "add_executable(parser src/parser.cpp)" is changed to: "add_executable(parser urdf/src/parser.cpp)" catkin_make succeds and generate a file named "./devel/lib/testbot_description/parser" (run from ~/catkin_ws) and the command " ./devel/lib/testbot_description/parser ./src/testbot_description/urdf/my_robot.urdf [ INFO] [1396869719.552512138]: Successfully parsed urdf file" is happy.

ROSnewbie11 gravatar image ROSnewbie11  ( 2014-04-07 01:30:19 -0500 )edit
0

answered 2014-09-25 07:34:24 -0500

Can anybody help me about parsing the urdf files? I followed tyhe tutorials about urdf parsing but could not achieve to parse my_robot urdf file. I used the codes of the tutorial below;

serkancaska@serkancaska:~/catkin_ws/src/testbot_description/urdf/sfrc$ ./devel/lib/robot_description/parser /src/robot_description/urdf/my_robot.urdf

The output of terminal is:

./devel/lib/robot_description/parser: No such file or directory , even if i created directories named "robot_description" and "parser". Kindly help me.

edit flag offensive delete link more

Comments

should run the pkg in the root folder try user@user:~/catkin_ws$ ./devel/lib/robot_description/parser /src/robot_description/urdf/my_robot.urdf

alei7 gravatar image alei7  ( 2014-12-06 21:30:49 -0500 )edit
0

answered 2018-05-25 08:47:44 -0500

Marta gravatar image

Hello to all! Thanks to your clarification regarding the tutorial I could run the executable file parse. Unfortunately, it gives me this error to this command:

$ rosrun testbot_description parser

/home/user/catkin_ws/src/testbot_description/src/parser: line 4: syntax error near unexpected token ('/ home/user/catkin_ws/src/testbot_description/src/parser: line 4:int main(int argc, char** argv){'

What should I do? It seems strange because I copied the file ¨parser¨ from the tutorial.

thank you fro your help, Bye

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-04-04 03:10:47 -0500

Seen: 1,052 times

Last updated: Apr 06 '14