Robotics StackExchange | Archived questions

errors running robot_state_publisher

When I run ros2 run robot_state_publisher robot_state_publisher neato.urdf.xacro I get these errors

[WARN] [1677644097.206220187] [robot_state_publisher]: No robot_description parameter, but command-line argument available.  Assuming argument is name of URDF file.  This backwards compatibility fallback will be removed in the future.
Parsing robot urdf xml string.
Error:   Unable to parse component [${bodyRadius/2}] to a double (while parsing a vector value)
         at line 102 in /tmp/binarydeb/ros-foxy-urdfdom-2.3.3/urdf_parser/src/pose.cpp
Error:   Could not parse visual element for Link [body]
         at line 495 in /tmp/binarydeb/ros-foxy-urdfdom-2.3.3/urdf_parser/src/link.cpp
Error:   length [${laserHeight}] is not a valid float
         at line 183 in /tmp/binarydeb/ros-foxy-urdfdom-2.3.3/urdf_parser/src/link.cpp
Error:   Could not parse visual element for Link [sensor_laser]
         at line 495 in /tmp/binarydeb/ros-foxy-urdfdom-2.3.3/urdf_parser/src/link.cpp
Error:   Unable to parse component [${bodyHeight/2}] to a double (while parsing a vector value)
         at line 102 in /tmp/binarydeb/ros-foxy-urdfdom-2.3.3/urdf_parser/src/pose.cpp
Error:   Malformed parent origin element for joint [body_joint]
         at line 473 in /tmp/binarydeb/ros-foxy-urdfdom-2.3.3/urdf_parser/src/joint.cpp
Error:   joint xml is not initialized correctly
         at line 206 in /tmp/binarydeb/ros-foxy-urdfdom-2.3.3/urdf_parser/src/model.cpp
terminate called after throwing an instance of 'std::runtime_error'
  what():  Unable to initialize urdf::model from robot description

URDF:

<?xml version="1.0" encoding="UTF-8"?>
<robot xmlns:xacro="http://ros.org/wiki/xacro" name="neato">
   <!-- bodyRadius: half of body width -->
   <!-- bodyHeight: body height from base to top, excluding casters and wheels -->
   <!-- laserRadius: radius of outermost laser body -->
   <!-- laserHeight: distance from of top of body to top of laser body -->
   <!-- laserRearOffset: distance from rear of body to rear of laser -->
   <!-- groundClearance: body to ground at rest -->
   <!-- wheelTrack: distance between wheel centerline -->
   <!-- wheelZOffset: distance from bottom of body to center of wheel at rest -->
   <xacro:property name="bodyRadius" value="0.165" />
   <xacro:property name="bodyRadius2" value="0.0825" />
   <xacro:property name="bodyHeight" value="0.074" />
   <xacro:property name="laserRadius" value="0.048" />
   <xacro:property name="laserHeight" value="0.016" />
   <xacro:property name="laserRearOffset" value="0.024" />
   <xacro:property name="groundClearance" value="0.0095" />
   <xacro:property name="wheelRadius" value="${0.075/2}" />
   <xacro:property name="wheelWidth" value="0.015" />
   <xacro:property name="wheelTrack" value="0.238" />
   <xacro:property name="wheelZOffset" value="${wheelRadius-groundClearance}" />
   <material name="black">
      <color rgba="0 0 0 1" />
   </material>
   <material name="grey">
      <color rgba=".5 .5 .5 1" />
   </material>
   <link name="base_link" />
   <link name="body">
      <visual>
         <!--actual: <origin xyz="0 .060 0" rpy="0 0 0" /> -->
         <origin xyz="0 ${bodyRadius/2} 0" rpy="0 0 0" />
         <geometry>
            <!--actual: <box size="0.330 0.135 0.074"/> -->
            <box size="${bodyRadius*2} ${bodyRadius} ${bodyHeight}" />
         </geometry>
         <material name="black" />
      </visual>
      <visual>
         <geometry>
            <cylinder length="${bodyHeight}" radius="${bodyRadius}" />
         </geometry>
         <material name="black" />
      </visual>
   </link>
   <joint name="body_joint" type="fixed">
      <origin xyz="0 0 ${bodyHeight/2}" rpy="0 0 ${pi/2}" />
      <child link="body" />
      <parent link="base_link" />
   </joint>
   <link name="sensor_laser">
      <visual>
         <geometry>
            <cylinder radius="${laserRadius}" length="${laserHeight}" />
         </geometry>
         <material name="grey" />
      </visual>
      <collision>
         <geometry>
            <cylinder radius="${laserRadius}" length="${laserHeight}" />
         </geometry>
      </collision>
   </link>
   <joint name="sensor_laser_joint" type="fixed">
      <origin xyz="${-(bodyRadius - laserRearOffset - laserRadius)} 0 ${(laserHeight/2) + bodyHeight}" rpy="0 0 0" />
      <parent link="base_link" />
      <child link="sensor_laser" />
   </joint>
   <xacro:macro name="wheel" params="prefix reflect">
      <link name="wheel_${prefix}">
         <visual>
            <origin xyz="0 0 0" rpy="${pi/2} 0 0" />
            <geometry>
               <cylinder length="${wheelWidth}" radius="${wheelRadius}" />
            </geometry>
            <material name="grey" />
         </visual>
         <collision>
            <origin xyz="0 0 0" rpy="${pi/2} 0 0" />
            <geometry>
               <cylinder length="${wheelWidth}" radius="${wheelRadius}" />
            </geometry>
         </collision>
      </link>
      <joint name="wheel_${prefix}_joint" type="fixed">
         <axis xyz="0 1 0" rpy="0 0 0" />
         <parent link="base_link" />
         <child link="wheel_${prefix}" />
         <origin xyz="0 ${reflect * wheelTrack/2} ${wheelZOffset}" rpy="0 0 0" />
      </joint>
   </xacro:macro>
   <xacro:wheel prefix="left" reflect="-1" />
   <xacro:wheel prefix="right" reflect="1" />
</robot>

Asked by bribri123 on 2023-02-28 23:20:41 UTC

Comments

Answers

Hello there,

This is not a urdf file you need to first convert your xacro file to urdf file

xacro model.xacro > model.urdf

You can check urdf file via below command.

check_urdf _path_to_urdf_file_

Asked by Ranjit Kathiriya on 2023-03-01 06:51:09 UTC

Comments