name 'joint' is not defined (Xacro)
I'm basically trying to run a robot self filter package (https://github.com/blodow/realtime_ur...) with a robot urdf.xacro file (https://github.com/ToyotaResearchInst...).
This is the launch file I changed to run the filter with the specific urdf.xacro:
<launch>
<!-- args -->
<arg name="robot" default="hsrb4s"/>
<node pkg="realtime_urdf_filter" type="realtime_urdf_filter" name="$(anon realtime_urdf_filter)" output="screen">
<remap from="~input_depth" to="/hsrb/head_rgbd_sensor/depth_registered/image_rect_raw"/>
<remap from="~output_depth" to="/hsrb/head_rgbd_sensor/depth_registered_filtered/image_rect" />
<remap from="~output_mask" to="/urdf_filtered_mask" />
<rosparam command="load" file="$(find realtime_urdf_filter)/launch/filter_parameters.yaml"/>
</node>
<!-- Load an example URDF -->
<param name="robot_description" command="$(find xacro)/xacro '$(find realtime_urdf_filter)/robots/$(arg robot).urdf.xacro'"/>
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" />
</launch>
I also changed the name of the package in the original xarco files so that it fits to the robot self filter package. And when I ran this launch file, I get the following error:
name 'joint' is not defined
when evaluating expression 'joint'
when processing file: /home/user/catkin_ws/src/realtime_urdf_filter/urdf/common.xacro
included from: /home/user/catkin_ws/src/realtime_urdf_filter/robots/hsrb4s.urdf.xacro
RLException: Invalid <param> tag: Cannot load command parameter [robot_description]: command [['/opt/ros/noetic/lib/xacro/xacro', '/home/user/catkin_ws/src/realtime_urdf_filter/robots/hsrb4s.urdf.xacro']] returned with code [2].
Param xml is <param name="robot_description" command="$(find xacro)/xacro '$(find realtime_urdf_filter)/robots/$(arg robot).urdf.xacro'"/>
The traceback for the exception was written to the log file
This is the file which the error message is directing:
<?xml version="1.0"?>
<robot xmlns:xacro="http://ros.org/wiki/xacro">
<xacro:arg name="implicit_damping" default="false" />
<xacro:property name="pi" value="3.14159265359"/>
<macro name="hsrb_position_joint_transmission" params="joint reduction">
<transmission name="${joint}_transmission">
<type>transmission_interface/SimpleTransmission</type>
<joint name="${joint}">
<hardwareInterface>PositionJointInterface</hardwareInterface>
</joint>
<actuator name="${joint}_actuator">
<hardwareInterface>PositionJointInterface</hardwareInterface>
<mechanicalReduction>${reduction}</mechanicalReduction>
</actuator>
</transmission>
</macro>
<macro name="hsrb_effort_joint_transmission" params="joint reduction">
<transmission name="${joint}_transmission">
<type>transmission_interface/SimpleTransmission</type>
<joint name="${joint}">
<hardwareInterface>EffortJointInterface</hardwareInterface>
</joint>
<actuator name="${joint}_actuator">
<hardwareInterface>EffortJointInterface</hardwareInterface>
<mechanicalReduction>${reduction}</mechanicalReduction>
</actuator>
</transmission>
</macro>
<macro name="hsrb_velocity_joint_transmission" params="joint reduction">
<transmission name="${prefix}_transmission">
<type>transmission_interface/SimpleTransmission</type>
<joint name="${joint}">
<hardwareInterface>VelocityJointInterface</hardwareInterface>
</joint>
<actuator name="${joint}_actuator">
<hardwareInterface>VelocityJointInterface</hardwareInterface>
<mechanicalReduction>${reduction}</mechanicalReduction>
</actuator>
</transmission>
</macro>
.......etc
</robot>
Can somebody help me understand what the error is indicating and how to tweak things to resolve this issue?
I wonder whether version matters here since I'm using Noetic while the robot description was generated several years ago.
Yes to your last question. I worked on this as a hobby: https://github.com/robogeekcanada/noe...
You can get some ideas how it is addressed. My suggestion is to start commenting sections of the urdf or launch file to see where is the issue.
I'm going to guess that the problem is how the macro is called i.e. the
joint="xyz"
parameter is missing. Allxacro
files I've read use a tag name ofxacro:macro
(not simplymacro
), but maybe both forms are still supported. The xacro syntax is described here.Thank you for the valuable comments! I figured out why I'm having the current problem. It's basically because I was missing some files (.urdf & .obj.urdf). Somehow those files disappear after I did catkin_make.
@kidpaul it's ok to provide your own answer to your question.