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

Minimum requirement to view urdf in RViz?

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

Thang Nguyen gravatar image

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

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">

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

  <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"/>
  </joint>

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

  <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"/>
  </joint>

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

</robot>

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

ubuntu@tegra-ubuntu:~/Documents/WorkSpaceMasteringRosRobot/mastering_ros_robot_d
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

<launch>  
    <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" />
</launch>

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

ubuntu@tegra-ubuntu:~/Documents/WorkSpaceMasteringRosRobot/mastering_ros_robot_d
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

Comments

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 -0500 )edit

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

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

2 Answers

Sort by ยป oldest newest most voted
1

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

Shay gravatar image

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

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

Comments

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 -0500 )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 -0500 )edit

@gvdhoorn you are right.

Shay gravatar image Shay  ( 2016-09-12 10:25:09 -0500 )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 -0500 )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 -0500 )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 -0500 )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 -0500 )edit

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

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

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

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

Comments

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 -0500 )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 -0500 )edit

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

Abdul Mannan gravatar image Abdul Mannan  ( 2016-10-16 04:35:29 -0500 )edit

Question Tools

2 followers

Stats

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

Seen: 1,617 times

Last updated: Sep 14 '16