Robotics StackExchange | Archived questions

stl files are not showing in rvis

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} ${imu_yoff} ${imu_zoff}" rpy="0 0 0"/>
  </joint>

  <!-- Laserscan -->
  <link name="lidar_link">
    <visual>
      <origin xyz="0 0 0" rpy="0 0 0"/>
      <geometry>
        <cylinder radius="0.0508" length="0.055"/>
      </geometry>
    </visual>
  </link>

  <joint name="lidar_joint" type="fixed">
    <parent link="base_link"/>
    <child link="lidar_link"/>
    <origin xyz="${rplidar_xoff} ${rplidar_yoff} ${rplidar_zoff}" rpy="0 0 0"/>
    <axis xyz="0 0 1"/>
  </joint>


</robot>

when I try to change the geometry of any link to mesh file using this code

<geometry>
  <mesh filename="package://basic_mobile_robot/meshes/robot_base.stl" />
</geometry>

I got this warning

The STL file 'package://basicmobilerobot/meshes/robot_base.stl' is malformed. It starts with the word 'solid', indicating that it's an ASCII STL file, but it does not contain the word 'endsolid' soit is either a malformed ASCII STL file or it is actually a binary STL file. Trying to interpret it as a binary STL file instead.

the stl file exported afrom cad model built in solidwork. does anyone know how to solve this ?

Asked by Husam on 2022-05-15 14:24:50 UTC

Comments

Answers

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 element inside . 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>

Asked by LuisEFA1998 on 2022-05-15 22:22:13 UTC

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

Asked by Husam on 2022-05-16 03:58:09 UTC