While running xacro on a ros urdf.xacro file, had an error "redefining global symbol: pi". The steps to reproduce are below.
<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">
<!-- transmission -->
<xacro:include filename="$(find tm_grasp_description)/urdf/tm.transmission.xacro" />
<!-- Mass parameters -->
<xacro:property name="pi" value="3.14159265" />
<xacro:macro name="tm700_robot" params="prefix joint_limited">
<!-- transmission prefix -->
<xacro:tm_arm_transmission prefix="${prefix}" />
<joint name="${prefix}shoulder_1_joint" type="revolute">
<parent link="${prefix}base_link" />
<child link = "${prefix}shoulder_1_link" />
<origin xyz="0.0 0.0 ${shoulder_height}" rpy="${-0.5 * pi} 0.0 0.0" />
<axis xyz="0 -1 0" />
<xacro:unless value="${joint_limited}">
<limit lower="${-2.0 * pi}" upper="${2.0 * pi}" effort="150.0" velocity="3.15"/>
</xacro:unless>
<xacro:if value="${joint_limited}">
<limit lower="${-pi}" upper="${pi}" effort="150.0" velocity="3.15"/>
</xacro:if>
<dynamics damping="0.0" friction="0.0"/>
</joint>
...
</xacro:macro>
</robot>
i was trying to add the robot to the xacro file
<?xml version="1.0" ?>
<robot name="hrwros" xmlns:xacro="http://www.ros.org/wiki/xacro">
<!-- world -->
<link name="world" />
<!-- workcell -->
<xacro:include filename="$(find hrwros_support)/urdf/workcell/workcell.urdf.xacro"/>
<xacro:workcell_urdf workcell_parent="world_interface"/>
<!-- Robot1 Pedestal -->
<xacro:include filename="$(find hrwros_support)/urdf/robot_pedestal/robot_pedestal.urdf.xacro"/>
<xacro:robot_pedestal_urdf pedestal_prefix="robot1_" pedestal_parent="world_interface" pedestal_height="0.95">
<origin xyz="0.5 1.8 0.0" rpy="0 0 0"/>
</xacro:robot_pedestal_urdf>
<!-- Robot1 -->
<xacro:include filename="$(find tm_grasp_description)/urdf/tm700.urdf.xacro"/>
<xacro:tm700_robot prefix="robot1_" joint_limited="true"/>
<!-- bins -->
<xacro:include filename="$(find hrwros_support)/urdf/bin/bin.urdf.xacro"/>
<xacro:bin_urdf prefix="bin_1_"/>
<!-- logical camera 1 collision model -->
<xacro:include filename="$(find hrwros_support)/urdf/logical_camera/logical_camera.urdf.xacro"/>
<xacro:logical_camera_urdf prefix="logical_camera1_" logical_camera_parent="world_interface">
<origin xyz="1.2 1.8 2.0" rpy="0 1.5708 0"/>
</xacro:logical_camera_urdf>
<!-- logical camera 2 collision model -->
<xacro:include filename="$(find hrwros_support)/urdf/logical_camera/logical_camera.urdf.xacro"/>
<xacro:logical_camera_urdf prefix="logical_camera2_" logical_camera_parent="world_interface">
<origin xyz="-8.3 -1.23 1.8" rpy="0 1.5708 0"/>
</xacro:logical_camera_urdf>
<!-- break beam -->
<xacro:include filename="$(find hrwros_support)/urdf/break_beam/break_beam.urdf.xacro"/>
<xacro:break_beam_urdf prefix="break_beam_"/>
but when I try to run
rosrun xacro xacro --inorder hrwros.xacro > hrwros.urdf
it shows the following error saying the redefine the symbol pi. And the robot I am trying to add is techman robot.
xacro: in-order processing became default in ROS Melodic. You can drop the option.
redefining global symbol: pi
when processing file: /home/akash/project/src/techman_robot_ros-master/tm_grasp_description/urdf/tm700.urdf.xacro
included from: hrwros.xacro
So when you have the same xacro property defined at global scope, having another with the same name redefines it.
Looking at the error report, you have it defined first in the top file, and possibly elsewhere. In math operations, pi is defined already, since the math operations use python and pi is defined there. If you delete your global pi definition, it should now work.