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

Cannot display the urdf model in rviz (launch file)

asked 2016-07-09 19:55:26 -0600

patrchri gravatar image

updated 2016-07-10 21:58:08 -0600

Hello,

I am new to ROS and today I attempted to write a simple code for a launch file just to display my urdf model in rviz. I wrote this for a start:

<launch>
  <param name="robot_description" textfile="$(find labrob_description)/urdf/labrob.urdf" />
  <node name="rviz" pkg="rviz" type="rviz" required="true" />
</launch>

What I get is an empty rviz grid. Could you please explain me what I am doing wrong ? I saw some ready codes and they work fine for me when I roslaunch them (they display my model correctly in rviz) and from what I got, these are the lines to display a urdf model. Am I right ?

Thanks for your time and your answer in advance, Chris

I am adding also the urdf model code:

<robot name="labrob">
  <!-- Base link -->
  <link name="base_link">
    <visual>
      <origin xyz="0 0 0" rpy="0 0 0" />
      <geometry>
          <box size="1 0.5 0.25"/>
      </geometry>
      <material name="yellow">
        <color rgba="0.8 0.8 0 1"/>
      </material>
    </visual>
  </link>
  <!-- Front Right Wheel -->
  <link name="f_r_wheel">
    <visual>
      <origin xyz="0 0 0" rpy="1.570795 0 0" />
      <geometry>
          <cylinder length="0.1" radius="0.2" />
      </geometry>
      <material name="black">
        <color rgba="0.05 0.05 0.05 1"/>
      </material>
    </visual>
  </link>
  <joint name="joint_f_r_wheel" type="continuous">
    <parent link="base_link"/>
    <child link="f_r_wheel"/>
    <origin xyz="0.25 -0.30 0" rpy="0 0 0" /> 
    <axis xyz="0 1 0" rpy="0 0 0" />
  </joint>  
  <!-- Back Right Wheel -->
  <link name="b_r_wheel">
    <visual>
      <origin xyz="0 0 0" rpy="1.570795 0 0" />
      <geometry>
          <cylinder length="0.1" radius="0.2" />
      </geometry>
      <material name="black"/>
    </visual>
  </link>
  <joint name="joint_b_r_wheel" type="continuous">
    <parent link="base_link"/>
    <child link="b_r_wheel"/>
    <origin xyz="-0.25 -0.30 0" rpy="0 0 0" /> 
    <axis xyz="0 1 0" rpy="0 0 0" />
  </joint>  
  <!-- Front Left Wheel -->
  <link name="f_l_wheel">
    <visual>
      <origin xyz="0 0 0" rpy="1.570795 0 0" />
      <geometry>
          <cylinder length="0.1" radius="0.2" />
      </geometry>
      <material name="black"/>
    </visual>
  </link>
  <joint name="joint_f_l_wheel" type="continuous">
    <parent link="base_link"/>
    <child link="f_l_wheel"/>
    <origin xyz="0.25 0.30 0" rpy="0 0 0" /> 
    <axis xyz="0 1 0" rpy="0 0 0" />
  </joint>
  <!-- Back Left Wheel -->
  <link name="b_l_wheel">
    <visual>
      <origin xyz="0 0 0" rpy="1.570795 0 0" />
      <geometry>
          <cylinder length="0.1" radius="0.2" />
      </geometry>
      <material name="black"/>
    </visual>
  </link>
  <joint name="joint_b_l_wheel" type="continuous">
    <parent link="base_link"/>
    <child link="b_l_wheel"/>
    <origin xyz="-0.25 0.30 0" rpy="0 0 0" /> 
    <axis xyz="0 1 0" rpy="0 0 0" />
  </joint>
</robot>
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2016-07-10 11:34:31 -0600

David Lu gravatar image

To show the URDF, press the ADD button in the bottom left of Rviz and add a RobotModel to your configuration.

edit flag offensive delete link more

Comments

Thank you for the tip (I didn't notice the add button, because from the roslaunching of the display.launch code from the urdf_tutorial I could see the urdf model instantly). It worked for me partially, since now I can see some errors the rviz pops regarding "No transform from the links to the map".

patrchri gravatar image patrchri  ( 2016-07-10 21:57:23 -0600 )edit

Before I mark your answer as correct, I would like to ask you why the launch code I wrote doesn't present the urdf model instantly in rviz and I have to add it manually ? From some ready .launch files I read, these 2 lines refer to robot visualization. Correct ? Thank you for your time answering.

patrchri gravatar image patrchri  ( 2016-07-10 22:12:48 -0600 )edit
1

The "ready .launch files [you] read" make RViz use a configuration file (.rviz) that already includes the RobotModel display that @David Lu suggested you add. The default configuration doesn't.

gvdhoorn gravatar image gvdhoorn  ( 2016-07-11 03:09:17 -0600 )edit

Thank you for your answer!

patrchri gravatar image patrchri  ( 2016-07-11 07:58:25 -0600 )edit
0

answered 2016-07-10 08:35:22 -0600

130s gravatar image

If you just want to see your model on RViz and do nothing else, follow this urdf tutorial and replace with your urdf file. As you see, use urdf_tutorial to spawn your model into RViz. What display.launch that's used in the tutorial can be seen here.

edit flag offensive delete link more

Comments

I have tried that and it worked for me. What I am really asking is if this sample of code that I present above can display a model or I need something more ?

I also checked the code of the tutorial's launch files and from what I understand these 4 lines of launch code should work. Correct ?

patrchri gravatar image patrchri  ( 2016-07-10 21:44:42 -0600 )edit
1

I guess so. Make sure you choose robot_description on RobotModel plugin. If this still doesn't work you better update your question to include rosparam get robot_description output.

130s gravatar image 130s  ( 2016-07-11 00:54:02 -0600 )edit

Thank you for your answer.

patrchri gravatar image patrchri  ( 2016-07-11 08:01:47 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-07-09 19:55:26 -0600

Seen: 4,036 times

Last updated: Jul 10 '16