Xacro macro is not getting expanded/ substituted
Hi,
I am using Ubuntu 20.04 focal with ROS noetic on amd64 (tried with arm64 as well) architecture. I have xacro file of husky robot by clearpath robotics from their official package and I am trying to add a ZED2 camera to the robot. I found ZED2's urdf from this package which works perfectly in their setup. I studied how the clearpath robotics has implemented arguments in xacro file to enable/ disable various sensors.
<!-- Intel Realsense camera related parameters or code-->
<xacro:arg name="realsense_enabled" default="$(optenv HUSKY_REALSENSE_ENABLED 0)" />
<xacro:arg name="realsense_xyz" default="$(optenv HUSKY_REALSENSE_XYZ 0 0.14 0)" />
<xacro:arg name="realsense_rpy" default="$(optenv HUSKY_REALSENSE_RPY 0 0 0)" />
<xacro:arg name="realsense_mount" default="$(optenv HUSKY_REALSENSE_MOUNT_FRAME sensor_arch_mount_link)" />
<xacro:include filename="$(find husky_description)/urdf/accessories/intel_realsense.urdf.xacro"/>
<!-- add the intel realsense to the sensor arch if needed -->
<xacro:if value="$(arg realsense_enabled)">
<link name="realsense_mountpoint"/>
<joint name="realsense_mountpoint_joint" type="fixed">
<origin xyz="$(arg realsense_xyz)" rpy="$(arg realsense_rpy)" />
<parent link="$(arg realsense_mount)"/>
<child link="realsense_mountpoint" />
</joint>
<xacro:intel_realsense_mount prefix="camera" topic="realsense" parent_link="realsense_mountpoint"/>
</xacro:if>
I did something similar to add a ZED2 camera in the "husky.urdf.xacro" file
<!-- Custom addition to xacro file to include ZED2 camera ; by Dev Vaibhav-->
<xacro:arg name="zed2_enabled" default="$(optenv HUSKY_ZED2_ENABLED 1)" />
<xacro:arg name="zed2_xyz" default="$(optenv HUSKY_ZED2_XYZ 0 0.14 0)" />
<xacro:arg name="zed2_rpy" default="$(optenv HUSKY_ZED2_RPY 0 0 0)" />
<xacro:arg name="zed2_mount" default="$(optenv HUSKY_ZED2_MOUNT_FRAME sensor_arch_mount_link)" />
<xacro:include filename="$(find husky_description)/urdf/accessories/zed2.xacro"/>
<xacro:property name="sensorbar_needed_zed2" value="$(arg zed2_enabled)" />
<xacro:if value="${sensorbar_needed_realsense or sensorbar_user_enabled or sensorbar_needed_lidar or sensorbar_needed_zed2}">
<xacro:sensor_arch prefix="" parent="top_plate_link" size="$(arg sensor_arch_height)">
<origin xyz="$(optenv HUSKY_SENSOR_ARCH_OFFSET 0 0 0)" rpy="$(optenv HUSKY_SENSOR_ARCH_RPY 0 0 0)"/>
</xacro:sensor_arch>
</xacro:if>
<!-- Custom addition to xacro file to include ZED2 camera ; by Dev Vaibhav-->
<!-- add the zed2 to the sensor arch if needed -->
<xacro:if value="$(arg zed2_enabled)">
<link name="zed2_mountpoint"/>
<joint name="zed2_mountpoint_joint" type="fixed">
<origin xyz="$(arg zed2_xyz)" rpy="$(arg zed2_rpy)" />
<parent link="$(arg zed2_mount)"/>
<child link="zed2_mountpoint" />
</joint>
<xacro:zed2_mount prefix="" topic="zed2" parent_link="zed2_mountpoint"/>
</xacro:if>
My "zed2.xacro" macro's look something like this. First is the parent macro <xacro:macro name="zed2_mount" params="prefix topic parent_link">
which I am calling through the line no. 256 in husky.urdf.xacro with no prefix; and inside that is the child macro <xacro:macro name="zed2" params="link_prefix:=${prefix} joint_prefix:=${prefix}">
With this code, I am trying to connect the ZED2 camera to robot with parent link as zed2_mountpoint (present on sensor arch on robot) and child link as zed2_camera_center (present on the sensor itself) but it is not working. I tried to visualize it in gazebo but I didn't see any ...