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

Why isn't my URDF able to show sensor in rviz, but does show in Gazebo11?

asked 2021-08-17 20:11:03 -0500

kak13 gravatar image

updated 2021-08-19 22:39:15 -0500

Hi everyone,

TL;DR How to load ultrasonic in rviz/gazebo11 using Foxy? How to place the robot on the floor properly without flip it in Gazebo11 or crash it in rviz? UDRF code is at bottom.

Full post

I fail to see why can't I load sensor in rviz. I'm using Ros2 Foxy, rviz2, and gazebo11.

So, my ultrasonic sensor should be on joint called ultrasonic. It's attached with one link cylinder called head2 and the board link called sensor.

Somehow, the topic isn't appear on rviz.

Here is the screenshot:

image description

So basically, my URDF look like this:

<?xml version="1.0"?>
<robot name="my_robot" xmlns:xacro="">

    <!--INCLUDE FILES-->
<!--    <xacro:include filename="$(find description)/my_robot.gazebo" />-->

  <!-- Define robot constants -->
  <xacro:property name="base_width" value="0.2159"/>
  <xacro:property name="base_length" value="0.1524"/>
  <xacro:property name="base_height" value="0.10795"/>

  <xacro:property name="wheel_radius" value="0.0325"/>
  <xacro:property name="wheel_width" value="0.02"/>
  <xacro:property name="wheel_ygap" value="0.088"/>
  <xacro:property name="wheel_zoff" value="0.05"/>
  <xacro:property name="wheel_xoff" value="0.1"/>

  <xacro:property name="caster_xoff" value="0.14"/>

  <!-- Define some commonly used intertial properties  -->
  <xacro:macro name="box_inertia" params="m w h d">
      <origin xyz="0 0 0" rpy="${pi/2} 0 ${pi/2}"/>
      <mass value="${m}"/>
      <inertia ixx="${(m/12) * (h*h + d*d)}" ixy="0.0" ixz="0.0" iyy="${(m/12) * (w*w + d*d)}" iyz="0.0" izz="${(m/12) * (w*w + h*h)}"/>

  <xacro:macro name="cylinder_inertia" params="m r h">
      <origin xyz="0 0 0" rpy="${pi/2} 0 0" />
      <mass value="${m}"/>
      <inertia ixx="${(m/12) * (3*r*r + h*h)}" ixy = "0" ixz = "0" iyy="${(m/12) * (3*r*r + h*h)}" iyz = "0" izz="${(m/2) * (r*r)}"/>

 <!-- Robot Base -->
  <link name="base_link">
    <box size="0.2159 0.1524 0.10795"/>
      <material name="Cyan">
    <color rgba="0 1.0 1.0 1.0"/>
        <box size="0.2159 0.1524 0.10795"/>

    <xacro:box_inertia m="15" w="0.2159" d="0.1524" h="0.10795"/>

  <!-- Robot Footprint -->
  <link name="base_footprint"/>

  <joint name="base_joint" type="fixed">
    <parent link="base_link"/>
    <child link="base_footprint"/>
    <origin xyz="0.0 0.0 ${-(wheel_radius+wheel_zoff)}" rpy="0 0 0"/>

    <!-- Servos -->
    <link name ="head">
            <cylinder radius="0.01" length="0.02"/>
        <material name="white"/>
        <cylinder radius="0.01" length="0.02"/>
    <xacro:cylinder_inertia m="0.5" r="0.01" h="0.02"/>
    < ...
edit retag flag offensive close merge delete



I'm working on something similar and would like to know how you got the gazebo view in your Update #2. I can't find this anywhere.

Darkproduct gravatar image Darkproduct  ( 2021-08-24 04:59:41 -0500 )edit

Hey! Show me your launch file

kak13 gravatar image kak13  ( 2021-08-24 10:58:54 -0500 )edit


This is under return launch.LaunchDescription([

launch.actions.ExecuteProcess(cmd=['gazebo', '--verbose', '-s', ''], output='screen'),

This will opens gazebo. To respawn your model in gazebo, use this one under def generate_launch_description():

spawn_entity = launch_ros.actions.Node(
arguments=['-entity', 'my_robot', '-topic', 'robot_description'],

then add this under return launch.LaunchDescription([


They are in my launch file above. Use the ctrl F to find them as well!

Please let me know if you encounter any issue with this

kak13 gravatar image kak13  ( 2021-08-24 15:15:07 -0500 )edit

I can open Gazebo and spawn my model just fine. The only thing I can't find is this nice view where you can see and possibly modify the speed and the PID values in Gazebo.

Darkproduct gravatar image Darkproduct  ( 2021-08-24 18:19:28 -0500 )edit

image description

Here, I made the picture for you. You click and hold then pull it to left :)

kak13 gravatar image kak13  ( 2021-08-24 18:28:26 -0500 )edit

Thanks. I can't believe I never noticed this.

Darkproduct gravatar image Darkproduct  ( 2021-08-24 18:34:18 -0500 )edit

For you actual question: Launch gazebo in verbose mode with --verbose. This will help finding any problems with your configuration. I looked at your gazebo tag for the sensor link and it looks good. Look at the bottem launch file in Update 2 from my answer here to see an example on how to launch gazebo in verbose mode.

Darkproduct gravatar image Darkproduct  ( 2021-08-24 18:43:24 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2021-08-24 22:29:49 -0500

kak13 gravatar image

answer from DarkProduct fixed this one

edit flag offensive delete link more

Question Tools



Asked: 2021-08-17 20:11:03 -0500

Seen: 186 times

Last updated: Aug 24 '21