Ask Your Question

Minimum requirement to view urdf in RViz?

asked 2016-09-12 01:03:53 -0600

Thang Nguyen gravatar image

updated 2016-09-14 01:11:57 -0600

Hi, I am learning build 3D model with urdf. I am following the book "Mastering ROS for robotics programming". I am confused since all of tutorials relating to urdf, I found online, require to start with a built package. I would like to know if I have a good urdf file, what is the minimum requirement to view this file in RViz? I did the steps below: I started with creating a package folder

$catkin_create_pkg mastering_ros_robot_description_pkg roscpp tf geometry_msgs urdf rviz xacro

I created a sub-folder name urdf and created this pan_tilt.urdf file:

<?xml version="1.0"?>
<robot name="pan_tilt">

  <link name="base_link">

    <cylinder length="0.01" radius="0.2"/>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <material name="yellow">
        <color rgba="1 1 0 1"/>

  <joint name="pan_joint" type="revolute">
    <parent link="base_link"/>
    <child link="pan_link"/>
    <origin xyz="0 0 0.1"/>
    <axis xyz="0 0 1" />
    <limit effort="300" velocity="0.1" lower="-3.14" upper="3.14"/>

  <link name="pan_link">
    <cylinder length="0.4" radius="0.04"/>
      <origin rpy="0 0 0" xyz="0 0 0.09"/>
      <material name="red">
        <color rgba="0 0 1 1"/>

  <joint name="tilt_joint" type="revolute">
    <parent link="pan_link"/>
    <child link="tilt_link"/>
    <origin xyz="0 0 0.2"/>
    <axis xyz="0 1 0" />
    <limit effort="300" velocity="0.1" lower="-4.64" upper="-1.5"/>

  <link name="tilt_link">
    <cylinder length="0.4" radius="0.04"/>
      <origin rpy="0 1.5 0" xyz="0 0 0"/>
      <material name="green">
        <color rgba="1 0 0 1"/>


I checked that the urdf file does not contain any error:

escription_pkg/urdf$ check_urdf pan_tilt.urdf
robot name is: pan_tilt
---------- Successfully Parsed XML ---------------
root Link: base_link has 1 child(ren)
    child(1):  pan_link
        child(1):  tilt_link

I created another folder same level with urdf folder name launch. I created view_demo.launch file

    <arg name="model" />  
    <param name="robot_description" textfile="$(find mastering_ros_robot_description_pkg)/urdf/pan_tilt.urdf" />  

    <param name="use_gui" value="true"/>
    <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />  
    <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
    <node name="rviz" pkg="rviz" type="rviz" args="-d $(find mastering_ros_robot_description_pkg)/urdf.rviz" required="true" />

From package folder, I ran this launch file and I got below error:

escription_pkg$ roslaunch mastering_ros_robot_description_pkg view_demo.launch
[view_demo.launch] is neither a launch file in package [mastering_ros_robot_description_pkg] nor is [mastering_ros_robot_description_pkg] a launch file name
The traceback for the exception was written to the log file

Please tell me what I am missing and how to solve the problem. Thank you for your time reading and answering my question.

Regards, Thang Nguyen

Edit 1: Sorry, the code format does not work with my edit.

Thanks for your help I ran catkin_make to compile the package then I try to ran the view_demo.launch file again. I got an error with rviz. I am not ... (more)

edit retag flag offensive close merge delete


Did you build the package after creating it? Also have you checked the $ROS_PACKAGE_PATH ?

bhavyadoshi26 gravatar image bhavyadoshi26  ( 2016-09-12 05:11:13 -0600 )edit

I have not done this yet. Thank you for reminding me.

Thang Nguyen gravatar image Thang Nguyen  ( 2016-09-12 10:11:09 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2016-09-12 08:36:35 -0600

Shay gravatar image

updated 2016-09-13 04:37:51 -0600

You can go to the directory where view_demo.launch belongs and run roslaunch view_demo.launch directly.

If you want to run roslaunch mastering_ros_robot_description_pkg view_demo.launch, you need to do catkin_make first.

Your edit1 is confusing, I don't know what is going on, but let me answer your 3rd question.

.rviz and .vcg file are both RViz configuration file, but since ROS Groovy the configuration file format has changed, from .vcg to .rviz. For detail, you can see RViz User Guide - configurations.

To display the robot URDF, you need to add a RobotModel in RViz. Like this: image description

urdf.rviz is just a configuration file for your RViz, when you open the RViz with urdf.rviz, and add or remove some items in the Displays, and save config, then your urdf.rviz will be modified. Next time you open RViz with urdf.rviz, the configuration will be same as what you had saved.

edit flag offensive delete link more


Note that your first option will only work if view_demo.launch does not refer to any resources in mastering_ros_robot_description_pkg, or if mastering_ros_robot_description_pkg is on the package path. But to get it there, you might as well catkin_make the workspace.

gvdhoorn gravatar image gvdhoorn  ( 2016-09-12 09:18:20 -0600 )edit

Thank you for helping me. I will try this tonight and confirm it.

Thang Nguyen gravatar image Thang Nguyen  ( 2016-09-12 10:11:48 -0600 )edit

@gvdhoorn you are right.

Shay gravatar image Shay  ( 2016-09-12 10:25:09 -0600 )edit

I do catkin_make but I still cannot run rviz. I updated my question to include more detail information.

Thang Nguyen gravatar image Thang Nguyen  ( 2016-09-13 00:26:25 -0600 )edit

In edit 1, the error is below ==== line. I can manage to run the rviz tool independently with launch file but I don't know how to load the urdf from inside rviz. Should I suppose to use the urdf.rviz in this case? but how these file is created from my urdf file?

Thang Nguyen gravatar image Thang Nguyen  ( 2016-09-13 01:49:42 -0600 )edit

What I tried so far is remove the last line of my launch file which is the line to run rviz. I then run rviz manually. After rviz is launched, I select to load the urdf.rviz file from menu toolbar. With this sequence of steps, I can control the model manually with slide bar.

Thang Nguyen gravatar image Thang Nguyen  ( 2016-09-13 10:04:32 -0600 )edit

I ran catkin make but it still return same error. If I ran launch file directly from launch folder, I also got an error

Thang Nguyen gravatar image Thang Nguyen  ( 2016-09-14 01:10:39 -0600 )edit

At this point, I believe it's a hardware related issue.

Thang Nguyen gravatar image Thang Nguyen  ( 2016-09-14 09:46:27 -0600 )edit

answered 2016-09-12 09:31:47 -0600

There is a problem with this book and particularly in Chapter 2 & 3. Here is the solution for that. From the tutorials, I believe you have the soft codes of this book, there will be file in the main pkg file named urdf.rviz and urdf.vcg. Copy these files into your created package file. After that, try what you are doing currently and let me know the problem if it occurs. In case, if you don't have codes for the tutorials download it from here (Link). Best of luck.

edit flag offensive delete link more


Thanks Dr Abdul Mannan. I would like to understand what actually is happening. I believe since I have not built the package so ROS don't understand my files.

Thang Nguyen gravatar image Thang Nguyen  ( 2016-09-12 12:21:53 -0600 )edit

@Dr Abdul Mannan: I understand more about your answer now. I include these two files in the package folder but it still not run.

Thang Nguyen gravatar image Thang Nguyen  ( 2016-09-13 09:15:32 -0600 )edit

Oh, I just read it. I guess, problem is already solved.

Dr Abdul Mannan gravatar image Dr Abdul Mannan  ( 2016-10-16 04:35:29 -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



Asked: 2016-09-12 01:03:53 -0600

Seen: 1,229 times

Last updated: Sep 14 '16