0
$\begingroup$

Rosanswers logo

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>

Originally posted by patrchri on ROS Answers with karma: 354 on 2016-07-09

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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


Originally posted by David Lu with karma: 10932 on 2016-07-10

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by patrchri on 2016-07-10:
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".

Comment by patrchri on 2016-07-10:
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.

Comment by gvdhoorn on 2016-07-11:
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.

Comment by patrchri on 2016-07-11:
Thank you for your answer!

$\endgroup$

Your Answer

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