Ask Your Question
2

How to visualize URDF model in rviz?

asked 2014-05-11 06:54:31 -0500

sam gravatar image

updated 2014-05-11 07:06:27 -0500

I can detect base_link in rviz, but failed to visualize it.

Here is my process:

catkin_create_pkg sam_load_urdf_into_rviz
cd sam_load_urdf_into_rviz
mkdir urdf
vim urdf/robot1.urdf
<?xml version="1.0"?>
  <robot name="Robot1">
    <link name="base_link">
      <visual>
        <geometry>
          <box size="0.2 .3 .1"/>
        </geometry>
        <origin rpy="0 0 0" xyz="0 0 0.05"/>
        <material name="white">
          <color rgba="1 1 1 1"/>
        </material>
      </visual>
    </link>

    <link name="wheel_1">
      <visual>
        <geometry>
          <cylinder length="0.05" radius="0.05"/>
        </geometry>
        <origin rpy="0 1.5 0" xyz="0.1 0.1 0"/>
          <material name="black">
            <color rgba="0 0 0 1"/>
          </material>
      </visual>
    </link>

    <link name="wheel_2">
      <visual>
        <geometry>
          <cylinder length="0.05" radius="0.05"/>
        </geometry>
        <origin rpy="0 1.5 0" xyz="-0.1 0.1 0"/>
        <material name="black"/>
      </visual>
    </link>
    <link name="wheel_3">
      <visual>
        <geometry>
          <cylinder length="0.05" radius="0.05"/>
        </geometry>
        <origin rpy="0 1.5 0" xyz="0.1 -0.1 0"/>
        <material name="black"/>
      </visual>
    </link>

    <link name="wheel_4">
      <visual>
        <geometry>
          <cylinder length="0.05" radius="0.05"/>
        </geometry>
        <origin rpy="0 1.5 0" xyz="-0.1 -0.1 0"/>
        <material name="black"/>
      </visual>
    </link>

    <joint name="base_to_wheel1" type="fixed">
      <parent link="base_link"/>
      <child link="wheel_1"/>
      <origin xyz="0 0 0"/>
    </joint>

    <joint name="base_to_wheel2" type="fixed">
      <parent link="base_link"/>
      <child link="wheel_2"/>
      <origin xyz="0 0 0"/>
    </joint>

    <joint name="base_to_wheel3" type="fixed">
      <parent link="base_link"/>
      <child link="wheel_3"/>
      <origin xyz="0 0 0"/>
    </joint>

    <joint name="base_to_wheel4" type="fixed">
      <parent link="base_link"/>
      <child link="wheel_4"/>
      <origin xyz="0 0 0"/>
    </joint>
  </robot>
mkdir launch
vim launch/load_urdf_into_rviz.launch
<launch>
      <arg name="model" />
      <arg name="gui" default="False" />
      <param name="robot_description" textfile="$(find sam_load_urdf_into_rviz)/urdf/robot1.urdf" />
      <param name="use_gui" value="$(arg gui)"/>
      <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" ></node>
      <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
      <node name="rviz" pkg="rviz" type="rviz" args="-d $(find sam_load_urdf_into_rviz)/urdf.rviz" />
</launch>

Then I open new terminal to catkin_make successfully. Then I run:

sam@sam:~/code/ros_hydro_overlay/src/sam_code/sam_load_urdf_into_rviz$ optirun roslaunch sam_load_urdf_into_rviz load_urdf_into_rviz.launch
... logging to /home/sam/.ros/log/4406b7d4-d92e-11e3-afd5-a64105f7a087/roslaunch-sam-12875.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://sam:57964/

SUMMARY
========

PARAMETERS
 * /robot_description
 * /rosdistro
 * /rosversion
 * /use_gui

NODES
  /
    joint_state_publisher (joint_state_publisher/joint_state_publisher)
    robot_state_publisher (robot_state_publisher/state_publisher)
    rviz (rviz/rviz)

auto-starting new master
process[master]: started with pid [12899]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to 4406b7d4-d92e-11e3-afd5-a64105f7a087
process[rosout-1]: started with pid [12912]
started core service [/rosout]
process[joint_state_publisher-2]: started with pid [12924]
process[robot_state_publisher-3]: started with pid [12925]
process[rviz-4]: started with pid [12945]

image description

How to solve it?

Thank you~

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2014-05-11 07:23:24 -0500

sam gravatar image

Oh, sorry, I just forget to insert robot model...XD

After inserting it, it is succeed to visualize it.

image description

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-05-11 06:54:31 -0500

Seen: 5,963 times

Last updated: May 11 '14