URDF model does not appear in Gazebo: no errors

asked 2022-01-20 14:14:45 -0500

LEANLALA gravatar image

updated 2022-01-20 15:41:20 -0500

I am using ROS noetic on Ubuntu 20.04. Gazebo version 11.9.0. PC specifications: Intel core I7-7700H, 4GB Nvidia 940MX, 16 GB DDR4 RAM


This is my main file:

<?xml version="1.0"?>
<robot xmlns:xacro="http://ros.org/wiki/xarco" name="robot_base">
  <xacro:include filename="$(find robot_description)/urdf/robot_base_essentials.xacro"/>
  <xacro:include filename="$(find robot_description)/urdf/gazebo_essentials_base.xacro" />

  <link name="base_link">
    <visual>
      <origin xyz="0 0 0" rpy="1.5707963267949 0 3.14"/>
      <geometry>
        <mesh filename="file:///robot_description/meshes/robot_base.stl"/>
      </geometry>
      <material name="">
        <color rgba="0.79216 0.81961 0.93333 1"/>
      </material>
    </visual>
    <collsion>
      <origin xyz="0 0 0" rpy="1.5707963267949 0 3.14"/>
      <geometry>
        <mesh filename="file:///robot_description/meshes/robot_base.stl"/>
      </geometry>
    </collsion>
    <inertial> 
      <origin xyz="0.0030946 4.78250032638821E-11 0.053305" rpy="0 0 0"/>
      <mass value="47.873"/>
      <inertia ixx="0.774276574699151" ixy="-1.03781944357671E-10" ixz="0.00763014265820928" iyy="1.64933255189991" iyz="1.09578155845563E-12" izz="2.1239326987473" />
    </inertial>
  </link>
  <xacro:robot_wheel prefix="front_left"/>
  <xacro:robot_wheel prefix="front_right"/>
  <xacro:robot_wheel prefix="rear_left"/>
  <xacro:robot_wheel prefix="rear_right"/>

  <xacro:wheel_joint prefix="front_left" origin="0.220 0.250 0"/>
  <xacro:wheel_joint prefix="front_right" origin="0.220 -0.250 0"/>
  <xacro:wheel_joint prefix="rear_left" origin="-0.220 0.250 0"/>
  <xacro:wheel_joint prefix="rear_right" origin="-0.220 -0.250 0"/>

  <xacro:base_transmission prefix="front_left"/>
  <xacro:base_transmission prefix="front_right"/>
  <xacro:base_transmission prefix="rear_left"/>
  <xacro:base_transmission prefix="rear_right"/>

  <xacro:wheel_friction prefix="front_left"/>
  <xacro:wheel_friction prefix="front_right"/>
  <xacro:wheel_friction prefix="rear_left"/>
  <xacro:wheel_friction prefix="rear_right"/>

</robot>

This is my xacro file:

<?xml version="1.0"?>
<robot xmlns:xacro="http://ros.org/wiki/xacro" name="robot_essentials">
  <xacro:macro name="robot_wheel" params="prefix">
    <link name="${prefix}_wheel">
      <visual>
        <origin xyz="0 0 0" rpy="1.5707963267949 0 0"/>
        <geometry>
          <mesh filename="file:///robot_description/meshes/wheel.stl"/>
        </geometry>
        <material name="">
          <color rgba="0.79216 0.81961 0.93333 1"/>
        </material>
      </visual>
      <collision>
        <origin xyz= "0 0 0" rpy="1.5707963267949"/>
        <geometry>
          <mesh filename="file:///robot_description/meshes/wheel.stl"/>
        </geometry>
      </collision>
      <inertial>
        <origin xyz="-4.1867E-18 0.0068085 -1.65658661799998E-18" rpy="0 0 0"/>
        <mass value="2.6578"/>
        <inertia ixx="0.00856502765719703" ixy="1.5074118157338E-19" ixz="-4.78150098725052E-19" iyy="0.013670640432096" iyz="-2.68136447099727E-19" izz="0.00856502765719703" />
      </inertial>
    </link>
  </xacro:macro>
  <xacro:macro name="wheel_joint" params="prefix origin">
    <joint name="${prefix}_wheel_joint" type="continuous">
      <axis xyz="0 1 0"/>
      <parent link="base_link"/>
      <child link="${prefix}_wheel"/>
      <origin rpy="0 0 0" xyz="${origin}"/>
    </joint>
  </xacro:macro>
  <xacro:macro name="base_transmission" params="prefix">
    <transmission name="${prefix}_wheel_trans" type="SimpleTransmission">
      <type>transmission_interface/SimpleTransmission</type>
      <actuator name="${prefix}_wheel_motor">
        <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
        <mechanicalReduction>1</mechanicalReduction>
      < ...
(more)
edit retag flag offensive close merge delete

Comments

1

First of all, if model is spawning in gazebo it should have following INFO in your terminal which I found missing.

[INFO] [1642762444.445428, 0.203000]: Spawn status: SpawnModel: Successfully spawned entity

you can try editing your launch file something like this, not sure if it was an issue but you can give it a try,

<arg name="urdf_path" default="path/to/file.urdf"/>
<node name="spawn_model" pkg="gazebo_ros" type="spawn_model" 
    args=" -file $(arg urdf_path) -urdf 
    -x 0 -y 0 -z 0 -model Robot_name" 
    respawn="false" output="screen"/>
aarsh_t gravatar image aarsh_t  ( 2022-01-20 23:35:06 -0500 )edit

I had a similar problem with correct URDF not displaying in Gazebo, with no errors being reported. The issue was a missing <link name="world"/> connected to my robot base, and the mesh files not being visible to Gazebo due to not being listed in GAZEBO_MODEL_PATH. Not sure if latter is the problem for you since you are using the absolute file:// URL, but those seem wrong anyway (assuming you aren't really storing the model directory under the system root.

You can confirm that it's just meshes that aren't loading if you switch to "Inertial" view in Gazebo.

kvik gravatar image kvik  ( 2022-01-21 01:14:00 -0500 )edit

@aarsh_t I tried your fix and now I can see Spawn status: SpawnModel: Successfully spawned entity on the terminal but the model is still not visible.

LEANLALA gravatar image LEANLALA  ( 2022-01-21 06:09:15 -0500 )edit

@kvik I switched to inertial view and I still see nothing. I know that my model has spawned as it was confirmed on the terminal and I can also see the model details on the left panel. It seems that my meshes aren't loading. How can i fix this?

LEANLALA gravatar image LEANLALA  ( 2022-01-21 06:16:52 -0500 )edit

Try using the package://your_package/model.stl path or specify correct absolute paths to meshes in file:// paths. Currently, your URDF is pointing at /robot_description/meshes/*.stl, which are unlikely to be correct. I'm not sure why Gazebo isn't complaining about not finding the meshes.

kvik gravatar image kvik  ( 2022-01-21 06:47:09 -0500 )edit

This could happen when the stl files are not mapping correctly. Under View menu, select the Joints option, if the joints appear, then your urdf file is ok but it's not adding the stl files.

osilva gravatar image osilva  ( 2022-01-21 08:20:17 -0500 )edit

@kvik The mesh files are in the meshes folder only that is inside my packacge. I have tried using the package://my_package method and it did not work.

LEANLALA gravatar image LEANLALA  ( 2022-01-23 03:41:57 -0500 )edit

@osilva No I cannot see the joints either

LEANLALA gravatar image LEANLALA  ( 2022-01-23 03:45:08 -0500 )edit