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

stl files are not showing in rvis

asked 2022-05-15 14:24:50 -0500

Husam gravatar image

updated 2022-05-15 19:41:07 -0500

Hi! I'm using ros2 galactic I built a urdf file for my robot as showing here

using this URDF file

<?xml version="1.0"?>
<robot name="uiabot" xmlns:xacro="http://ros.org/wiki/xacro">

  <!-- Define robot constants -->
  <xacro:property name="base_width" value="0.315"/>
  <xacro:property name="base_length" value="0.325"/>
  <xacro:property name="base_height" value="0.075"/>

  <xacro:property name="wheel_radius" value="0.055"/>
  <xacro:property name="wheel_width" value="0.047"/>
  <xacro:property name="wheel_ygap" value="0.03"/>
  <xacro:property name="wheel_zoff" value="0.00"/>
  <xacro:property name="wheel_xoff" value="0.1"/>

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

  <xacro:property name="imu_width" value="0.02"/>
  <xacro:property name="imu_length" value="0.03"/>
  <xacro:property name="imu_height" value="0.01"/>
  <xacro:property name="imu_yoff" value="-0.095"/>
  <xacro:property name="imu_xoff" value="-0.095"/>
  <xacro:property name="imu_zoff" value="0.0475"/>

  <xacro:property name="rplidar_yoff" value="0.0"/>
  <xacro:property name="rplidar_xoff" value="0.1"/>
  <xacro:property name="rplidar_zoff" value="0.1375"/>

  <!-- Robot Base -->
  <link name="base_link">
    <visual>
      <geometry>
        <box size="${base_length} ${base_width} ${base_height}"/>
      </geometry>
      <material name="Cyan">
        <color rgba="0 1.0 1.0 1.0"/>
      </material>
    </visual>
  </link>

  <!-- 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"/>
  </joint>

    <!-- Wheels -->
  <xacro:macro name="wheel" params="prefix x_reflect y_reflect">
    <link name="${prefix}_link">
      <visual>
        <origin xyz="0 0 0" rpy="${pi/2} 0 0"/>
        <geometry>
            <cylinder radius="${wheel_radius}" length="${wheel_width}"/>
        </geometry>
        <material name="Gray">
          <color rgba="0.5 0.5 0.5 1.0"/>
        </material>
      </visual>
    </link>

    <joint name="${prefix}_joint" type="continuous">
      <parent link="base_link"/>
      <child link="${prefix}_link"/>
      <origin xyz="${x_reflect*wheel_xoff} ${y_reflect*(base_width/2+wheel_ygap)} ${-wheel_zoff}" rpy="0 0 0"/>
      <axis xyz="0 1 0"/>
    </joint>
  </xacro:macro>

  <xacro:wheel prefix="drivewhl_l" x_reflect="-1" y_reflect="1" />
  <xacro:wheel prefix="drivewhl_r" x_reflect="-1" y_reflect="-1" />

  <!-- Caster Wheel -->
  <link name="front_caster">
    <visual>
      <geometry>
        <sphere radius="${(wheel_radius+wheel_zoff-(base_height/2))}"/>
      </geometry>
      <material name="Cyan">
        <color rgba="0 1.0 1.0 1.0"/>
      </material>
    </visual>
  </link>

  <joint name="caster_joint" type="fixed">
    <parent link="base_link"/>
    <child link="front_caster"/>
    <origin xyz="${caster_xoff} 0.0 ${-(base_height/2)}" rpy="0 0 0"/>
  </joint>

  <!-- IMU -->
  <link name="imu_link">
    <visual>
      <geometry>
        <box size="${imu_length} ${imu_width} ${imu_height}"/>
      </geometry>
      <material name="Red">
        <color rgba="1.0 0 0 1.0"/>
      </material>
    </visual>
  </link>

  <joint name="imu_joint" type="fixed">
    <parent link="base_link"/>
    <child link="imu_link"/>
    <origin xyz="${imu_xoff ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-05-15 22:22:13 -0500

LuisEFA1998 gravatar image

updated 2022-05-15 22:24:04 -0500

Hello friend, what I can see in your URDF model is that nowhere in the links are you including the STL file that you want to use visual or collision element of your robot. In order to use an STL or DAE file it is necessary to add the <mesh> element inside <geometry>. I show you an example of how I created a link for a manipulator I built. In my case I have a couple of directoriesinside my kuka_kr5_support package where I keep the STL and DAE files that I used to define the geometry and collisions of the links of my robot.

<link name="base_link">
    <inertial>
      <origin xyz="-0.0331971453529796 -0.00735744808688106 0.373139405530063" rpy="0 0 0" />
      <mass value="50.6046948460142" />
      <inertia
        ixx="2.77257784651358"
        ixy="7.67629560675021E-06"
        ixz="-0.00208627280739474"
        iyy="2.76884597798142"
        iyz="8.80255253566934E-05"
        izz="3.95328857327015" />
    </inertial>

    <visual>
      <origin xyz="0 0 0" rpy="0 0 0" />
      <geometry>
        <mesh filename="package://kuka_kr5_support/meshes/collada_files/base_link.dae" />
      </geometry>
      <material name="">
        <color rgba="0.0196078431372549 0.0196078431372549 0.0196078431372549 1" />
      </material>
    </visual>

    <collision>
      <origin xyz="0 0 0" rpy="0 0 0" />
      <geometry>
        <mesh filename="package://kuka_kr5_support/meshes/stl_files/base_link.STL" />
      </geometry>
    </collision>

  </link>
edit flag offensive delete link more

Comments

Thank for your comment, but if you check at the end of my question I mention that I used mesh inside the geometry that includes the stl files

Husam gravatar image Husam  ( 2022-05-16 03:58:09 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2022-05-15 14:24:50 -0500

Seen: 124 times

Last updated: May 15 '22