0
$\begingroup$

Rosanswers logo

Hi, I'm new to ROS and am trying to follow this tutorial: https://github.com/Apress/Robot-Operating-System-Abs-Begs/tree/master/chapter_6/mobile_robot_description

I am running Ubuntu 20.04 + ROS noetic.

When I try to launch my xacro in Rviz I get this error:`

[ERROR] [1632711304.025022765]: No link el

ements found in urdf file
    [robot_state_publisher-2] process has died [pid 3129, exit code 1, cmd /opt/ros/noetic/lib/robot_state_publisher/robot_state_publisher __name:=robot_state_publisher __log:=/home/randal/.ros/log/5000ceae-1f3e-11ec-b087-5fe0994d9aa9/robot_state_publisher-2.log].
    log file: /home/randal/.ros/log/5000ceae-1f3e-11ec-b087-5fe0994d9aa9/robot_state_publisher-2*.log
    [ERROR] [1632711304.485687357]: No link elements found in urdf file`

How I'm attempting to launch Rviz:

roslaunch mobile_robot_description view_robot.launch

Rviz does launch, but I'm not able to see the model

My xacro:

<?xml version="1.0" ?>
<!-- 
 This is a standalone URDF model of 2WD smart car robot 
 -->


<robot name="mobile_robot" xmlns:xacro="http://ros.org/wiki/xacro">


  <property name="M_PI" value="3.1415926535897931" />
  <property name="M_PI_2" value="1.570796327" />
  <property name="DEG_TO_RAD" value="0.017453293" />

  <xacro:macro name="mobile_robot">

    <link name="base_footprint"/>
    <!--
   Base link is set at the bottom of the base mould.
   This is done to be compatible with the way base link
   was configured for turtlebot 1. Refer to
   
   https://github.com/turtlebot/turtlebot/issues/40
   
   To put the base link at the more oft used wheel
   axis, set the z-distance from the base_footprint
   to 0.352.
  -->
<joint name="base_joint" type="fixed">
  <origin xyz="0 0 0.0102" rpy="0 0 -${M_PI/2}" />
  <parent link="base_footprint"/>
  <child link="base_link" />
</joint>

<link name="base_link">
  <visual>
    <geometry>
      <!-- new mesh -->
      <mesh filename="package://mobile_robot_description/meshes/chassis.dae" scale="0.001 0.001 0.001"/> 

    </geometry>

 <origin xyz="-0.07 -0.12 0.352" rpy="0 0 0"/>

  </visual>

  <collision>
    <geometry>
    <box size="0.14 0.23 0.1" />
    </geometry>
    <origin xyz="0.0 -0.02 0" rpy="0 0 0"/>
  </collision>

  <inertial>
    <!-- COM experimentally determined -->
    <origin xyz="-0.07 -0.12 0"/>
    <mass value="2.4"/> <!-- 2.4/2.6 kg for small/big battery pack -->

    <inertia ixx="0.019995" ixy="0.0" ixz="0.0"
             iyy="0.019995" iyz="0.0" 
             izz="0.03675" />
      </inertial>
    </link>

<!-- Wheel and caster wheel link  -->


        <!-- NOTE This may prevent gazebo from working with this model -->
      <joint name="left_wheel_joint" type="fixed">
        <origin xyz="-0.06 0 0" rpy="0 0 0"/>
        <parent link="base_link"/>
        <child link="left_wheel_link"/>
        <axis xyz="1 0 0"/>

            <limit effort="100" velocity="100"/>
            <joint_properties damping="0.0" friction="0.0"/>
      </joint>
    

  <link name="left_wheel_link">
    <inertial>
      <origin xyz="0 0 0"/>
      <mass value="0.01" />
      <inertia ixx="0.001" ixy="0.0" ixz="0.0"
        iyy="0.001" iyz="0.0" izz="0.001" />
    </inertial>

    <visual>
      <origin xyz="0 0 0" rpy="0 ${M_PI/2} 0" />
      <geometry>
                <cylinder radius="0.0325" length = "0.02"/>
      </geometry>
         <material name ="black" />
    </visual>

    <collision>
      <origin xyz="0 0 0" rpy="0 ${M_PI/2} 0" />
      <geometry>
                <cylinder radius="0.0325" length = "0.02"/>
      </geometry>
    </collision>
  </link>


  <link name="right_wheel_link">
    <inertial>
      <origin xyz="0 0 0"/>
      <mass value="0.01" />
      <inertia ixx="0.001" ixy="0.0" ixz="0.0"
        iyy="0.001" iyz="0.0" izz="0.001" />
    </inertial>

    <visual>
      <origin xyz="0 0 0" rpy="0 ${M_PI/2} 0" />
      <geometry>
                <cylinder radius="0.0325" length = "0.02"/>
      </geometry>
        <material name ="black" />
    </visual>

    <collision>
      <origin xyz="0 0 0" rpy="0 ${M_PI/2} 0" />
      <geometry>
                <cylinder radius="0.0325" length = "0.02"/>
      </geometry>
    </collision>
  </link>

    <!-- Fixed because we never rotate it anyway, it is just for show -->
    <!-- NOTE This may prevent gazebo from working with this model -->
  <joint name="right_wheel_joint" type="fixed">
    <origin xyz="0.06 0 0" rpy="0 0 0"/>
    <parent link="base_link"/>
    <child link="right_wheel_link"/>
    <axis xyz="1 0 0"/>
  </joint>


<!--   
    <joint name="caster_front_joint" type="fixed">
      <parent link="base_link"/>
      <child link="chefbot_caster_front_link"/>
      <origin xyz="0.115 0.0 0.007" rpy="${-M_PI/2} 0 0"/>
    </joint>
    <link name="chefbot_caster_front_link">
      <collision>
        <geometry>
          <cylinder length="0.0176" radius="0.017"/>
        </geometry>
        <origin rpy="0 0 0" xyz="0 0 0"/>
      </collision>      
      <inertial>
        <mass value="0.01" />
        <origin xyz="0 0 0" />
        <inertia ixx="0.001" ixy="0.0" ixz="0.0"
                 iyy="0.001" iyz="0.0" 
                 izz="0.001" />
      </inertial>
    </link>
-->    
    <joint name="robot_caster_back_joint" type="fixed">
      <parent link="base_link"/>
      <child link="robot_caster_back_link"/>
      <origin xyz="0 -0.1 0" rpy="0 0 0"/>
    </joint>


<link name="robot_caster_back_link">
    <inertial>
      <origin xyz="0 0 0"/>
      <mass value="0.01" />
      <inertia ixx="0.001" ixy="0.0" ixz="0.0"
        iyy="0.001" iyz="0.0" izz="0.001" />
    </inertial>

    <visual>
      <origin xyz="0 0 -0.01" rpy="0 0 0" />
      <geometry>
                <cylinder radius="0.01" length = "0.035"/>
      </geometry>
        <material name ="black" />
    </visual>

    <collision>
      <origin xyz="0 0 0" rpy="0 ${M_PI/2} 0" />
      <geometry>
                <cylinder radius="0.01" length = "0.1"/>
      </geometry>
    </collision>
  </link>

</xacro:macro>

My launch file:

<launch>

    <arg name="model" />

    <!-- Parsing xacro and setting robot_description parameter -->
    <param name="robot_description" command="$(find xacro)/xacro '$(find mobile_robot_description)/urdf/robot_model.xacro'" />

    <!-- Starting robot state publish which will publish tf -->
    <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"/>

    <!-- Launch visualization in rviz -->
    <node name="rviz" pkg="rviz" type="rviz" args="-d $(find mobile_robot_description)/config/robot.rviz" required="true" />

</launch>

RVIZ settings file:

Panels:
  - Class: rviz/Displays
    Help Height: 78
    Name: Displays
    Property Tree Widget:
      Expanded:
        - /Global Options1
        - /Status1
        - /TF1
        - /TF1/Frames1
        - /RobotModel1
        - /RobotModel1/Links1
        - /Axes1
        - /Pose1
      Splitter Ratio: 0.5
    Tree Height: 747
  - Class: rviz/Selection
    Name: Selection
  - Class: rviz/Tool Properties
    Expanded:
      - /2D Pose Estimate1
      - /2D Nav Goal1
      - /Publish Point1
    Name: Tool Properties
    Splitter Ratio: 0.588679
  - Class: rviz/Views
    Expanded:
      - /Current View1
    Name: Views
    Splitter Ratio: 0.5
  - Class: rviz/Time
    Experimental: false
    Name: Time
    SyncMode: 0
    SyncSource: ""
Visualization Manager:
  Class: ""
  Displays:
    - Alpha: 0.5
      Cell Size: 1
      Class: rviz/Grid
      Color: 160; 160; 164
      Enabled: true
      Line Style:
        Line Width: 0.03
        Value: Lines
      Name: Grid
      Normal Cell Count: 0
      Offset:
        X: 0
        Y: 0
        Z: 0
      Plane: XY
      Plane Cell Count: 10
      Reference Frame: odom
      Value: true
    - Class: rviz/TF
      Enabled: true
      Frame Timeout: 15
      Frames:
        All Enabled: false
        base_footprint:
          Value: false
        base_link:
          Value: false
        left_wheel_link:
          Value: false
        odom:
          Value: true
        right_wheel_link:
          Value: false
        robot_caster_back_link:
          Value: false
      Marker Scale: 1
      Name: TF
      Show Arrows: true
      Show Axes: true
      Show Names: false
      Tree:
        odom:
          base_footprint:
            base_link:
              left_wheel_link:
                {}
              right_wheel_link:
                {}
              robot_caster_back_link:
                {}
      Update Interval: 0
      Value: true
    - Alpha: 1
      Class: rviz/RobotModel
      Collision Enabled: false
      Enabled: true
      Links:
        All Links Enabled: true
        Expand Joint Details: false
        Expand Link Details: false
        Expand Tree: false
        Link Tree Style: ""
        base_footprint:
          Alpha: 1
          Show Axes: false
          Show Trail: false
        base_link:
          Alpha: 1
          Show Axes: false
          Show Trail: false
          Value: true
        left_wheel_link:
          Alpha: 1
          Show Axes: false
          Show Trail: false
          Value: true
        right_wheel_link:
          Alpha: 1
          Show Axes: false
          Show Trail: false
          Value: true
        robot_caster_back_link:
          Alpha: 1
          Show Axes: false
          Show Trail: false
          Value: true
      Name: RobotModel
      Robot Description: robot_description
      TF Prefix: ""
      Update Interval: 0
      Value: true
      Visual Enabled: true
    - Class: rviz/Axes
      Enabled: true
      Length: 1
      Name: Axes
      Radius: 0.01
      Reference Frame: <Fixed Frame>
      Value: true
    - Alpha: 1
      Axes Length: 1
      Axes Radius: 0.1
      Class: rviz/Pose
      Color: 255; 25; 0
      Enabled: true
      Head Length: 0.3
      Head Radius: 0.1
      Name: Pose
      Shaft Length: 1
      Shaft Radius: 0.05
      Shape: Arrow
      Topic: /move_base_simple/goal
      Unreliable: false
      Value: true
  Enabled: true
  Global Options:
    Background Color: 48; 48; 48
    Fixed Frame: odom
    Frame Rate: 30
  Name: root
  Tools:
    - Class: rviz/Interact
      Hide Inactive Objects: true
    - Class: rviz/MoveCamera
    - Class: rviz/Select
    - Class: rviz/FocusCamera
    - Class: rviz/Measure
    - Class: rviz/SetInitialPose
      Topic: /initialpose
    - Class: rviz/SetGoal
      Topic: /move_base_simple/goal
    - Class: rviz/PublishPoint
      Single click: true
      Topic: /clicked_point
  Value: true
  Views:
    Current:
      Class: rviz/ThirdPersonFollower
      Distance: 8.81253
      Enable Stereo Rendering:
        Stereo Eye Separation: 0.06
        Stereo Focal Distance: 1
        Swap Stereo Eyes: false
        Value: false
      Focal Point:
        X: 0.210075
        Y: 1.75923
        Z: -1.01328e-06
      Name: Current View
      Near Clip Distance: 0.01
      Pitch: 1.5698
      Target Frame: <Fixed Frame>
      Value: ThirdPersonFollower (rviz)
      Yaw: 1.54041
    Saved: ~
Window Geometry:
  Displays:
    collapsed: false
  Height: 1028
  Hide Left Dock: false
  Hide Right Dock: true
  QMainWindow State: 000000ff00000000fd00000004000000000000017a0000037afc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000006400fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c00610079007301000000280000037a000000dd00fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f0000037afc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a0056006900650077007300000000280000037a000000b000fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000003a80000003efc0100000002fb0000000800540069006d00650100000000000003a8000002f600fffffffb0000000800540069006d00650100000000000004500000000000000000000002280000037a00000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
  Selection:
    collapsed: false
  Time:
    collapsed: false
  Tool Properties:
    collapsed: false
  Views:
    collapsed: true
  Width: 936
  X: 963
  Y: 14

Originally posted by Acehomie on ROS Answers with karma: 3 on 2021-09-26

Post score: 0


Original comments

Comment by osilva on 2021-09-27:
Can you send a snapshot of your RVIZ settings. Make sure Fixed Frame and Robot Model are selected.

Comment by Acehomie on 2021-09-27:
I added to the main post above. When RVIZ launches my Robot Model is selected but gives me error "Failed to parse URDF model" The Fixed Frame seems to be set to "odom"?

Comment by gvdhoorn on 2021-09-27:
Pedantic, but:

When I try to launch my xacro in Rviz

you cannot "launch a xacro in RViz". RViz just visualises whatever you give it. It's an observer, it's not an active entity which loads .xacro files. That's an important difference.

RViz (or really: the "robot model display") tries to load + parse whatever the contents is of the /robot_description parameter, then renders that.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

robot_model.xacro only defines a xacro:macro, but that macro is never called (or: the model is never instantiated).

You only have <xacro:macro name="mobile_robot"> [..] </xacro:macro>, but nowhere a <xacro:mobile_robot />.

It's like creating a C++ / Python class, but then ever instantiating it, so there is no object.

This is a classical mistake when using xacro.

The original file (here) doesn't appear to be a xacro:macro (notice how that line is commented, just as line 202, which would close the xacro:macro).


Originally posted by gvdhoorn with karma: 86574 on 2021-09-27

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by Acehomie on 2021-09-27:
Yeah, I removed the comments to get RVIZ to open. If I try to use the original file RVIZ won't load and I get :

name 'M_PI' is not defined 
when evaluating expression 'M_PI/2'
when processing file: /home/randal/catkin_ws/src/mobile_robot_description/urdf/robot_model.xacro
RLException: Invalid <param> tag: Cannot load command parameter [robot_description]: command [['/opt/ros/noetic/lib/xacro/xacro', '/home/randal/catkin_ws/src/mobile_robot_description/urdf/robot_model.xacro']] returned with code [2]. 

Param xml is <param name="robot_description" command="$(find xacro)/xacro '$(find mobile_robot_description)/urdf/robot_model.xacro'"/>
The traceback for the exception was written to the log file

Comment by gvdhoorn on 2021-09-27:\

Yeah, I removed the comments to get RVIZ to open

ah, ok. And you did not believe that to be important information to mention?

Comment by Acehomie on 2021-09-27:
Hi, I'm new to ROS

I tried to provide as much info as I though was relevant. I provided both what I was using and the original file. I figured that getting RVIZ to open was a step in the right direction and maybe there was something small I was missing.

Comment by gvdhoorn on 2021-09-27:
Changing files without explicitly telling the people you ask for help what you changed is not a good idea. This is independent of whether you're new to ROS or not.

In any case: the problem you show is likely caused by the fact that the .xacro you're trying to load is incompatible with the Noetic version of xacro. As a first step, prefix things like property with xacro:. It might start to work then.

You'll probably still get warnings about black not being defined, but things should at least load.

I'm not sure it's worth it trying to fix that .xacro/URDF. There seem to be many problems with it, and the book author doesn't seem too active there.

Perhaps the regular URDF tutorials would be easier?

Comment by Acehomie on 2021-09-27:
Ok, dually noted.

This seems to at least get RVIZ to open again, but still can't see the model. But this unblocks my current issue and at least gives me some more error codes I can start googling.

I was hoping to be able to use this as I've already built the model.

Yes, I've tried the regular tutorial, but was also getting errors. So, I figured if I'm going to spend time debugging something maybe better to work with the actual model in lieu of trying to model this from scratch + try to debug the tutorial. I appreciate the help though, thank you.

Comment by gvdhoorn on 2021-09-27:\

Yes, I've tried the regular tutorial, but was also getting errors

have you posted a question about that?

Those tutorials should work. If they don't, either something is not working on your end, or there is a problem with the tutorial and that should be fixed.

Without people reporting issues, they cannot be fixed.

This seems to at least get RVIZ to open again, but still can't see the model. [..] [This] at least gives me some more error codes [..]

What sort of errors? I just ran the resulting urdf through check_urdf, and that only complained about the materials not being defined (as I already mentioned). But those are not errors, just warnings.

Comment by Acehomie on 2021-09-27:
I haven't posted a question, I will try to.

The errors don't show in the terminal they only show in RVIZ, there are only warns in the terminal. Kind of weird to copy from RVIZ so forgive my formatting here, but I'm getting what look to be some transform errors:

No transform from [robot_caster_back_link] to [odom]
No transform from [right_wheel_link] to [odom]
No transform from [left_wheel_link] to [odom]
No transform from [base_link] to [odom]
No transform from [base_footprint] to [odom]
  • one for the chassis DAE

    package://mobile_robot_description/meshes/body/chasis.daeetries: • for link 'base_link': Could not load mesh resource 'package://mobile_robot_description/meshes/body/chasis.dae'

Comment by gvdhoorn on 2021-09-27:
These are errors with the robot_model.xacro? Not with the main tutorials?

These are all things that have been discussed before here on ROS Answers. In general: use Google to search, make sure to append site:answers.ros.org to your query string.

For RViz: make sure to change the Fixed Frame setting to an existing TF frame (it's a drop down, pick one).

For the mesh error: make sure that file exists, in the directory specified in your URDF.

Comment by Acehomie on 2021-09-27:
Sorry, yeah, those were with the robot_model.xacro. I didn't want to post errors from an unrelated tutorial in this thread. I will search around for these errors. Thank you.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.