How to call macro with *origin and default params
I am working on a xacro model and attempting to call a macro in a different xacro file, the contents of which are just below:
<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="robot_name">
<!-- LIDAR -->
<xacro:macro name="VLP16" params="*origin parent:=base_link name:=velodyne topic:=/velodyne_points hz:=10 lasers:=16 samples:=1875 collision_range:=0.3 min_range:=0.9 max_range:=130.0 noise:=0.008 min_angle:=-${M_PI} max_angle:=${M_PI} gpu:=false">
<joint name="${name}_base_mount_joint" type="fixed">
<xacro:insert_block name="origin" />
<parent link="${parent}"/>
<child link="${name}_base_link"/>
</joint>
<link name="${name}_base_link">
<inertial>
<mass value="0.83"/>
<origin xyz="0 0 0.03585"/>
<inertia ixx="${(0.83 * (3.0*0.0516*0.0516 + 0.0717*0.0717)) / 12.0}" ixy="0" ixz="0" iyy="${(0.83 * (3.0*0.0516*0.0516 + 0.0717*0.0717)) / 12.0}" iyz="0" izz="${0.5 * 0.83 * (0.0516*0.0516)}"/>
</inertial>
<visual>
<geometry>
<mesh filename="package://velodyne_description/meshes/VLP16_base_1.dae" />
</geometry>
</visual>
<visual>
<geometry>
<mesh filename="package://velodyne_description/meshes/VLP16_base_2.dae" />
</geometry>
</visual>
<collision>
<origin rpy="0 0 0" xyz="0 0 0.03585"/>
<geometry>
<cylinder radius="0.0516" length="0.0717"/>
</geometry>
</collision>
</link>
.
.
.
.
</xacro:macro>
</robot>
That xacro code creates a lidar and I copied it from the velodyn-simulator package into my own.
My problem is I'm having difficulty calling the macro from my xacro file. The parameters are all default values and unlikely to change so I set them as xacro properties so I can call the xacro without parameter. So, I added the following in at the beging of the xacro and removed all the params after the xacro name :
<xacro:property name="M_PI" value="3.1415926535897931" />
<xacro:property name="parent" value="chasis"/>
<xacro:property name="name" value="velodyne"/>
<xacro:property name="topic" value="/velodyne_points"/>
<xacro:property name="hz" value="10"/>
<xacro:property name="lasers" value="16"/>
<xacro:property name="samples" value="1875"/>
<xacro:property name="collision_range" value="0.3"/>
<xacro:property name="min_range" value="0.9"/>
<xacro:property name="max_range" value="130.0"/>
<xacro:property name="noise" value="0.008"/>
<xacro:property name="min_angle" value="-${M_PI}"/>
<xacro:property name="max_angle" value="${M_PI}"/>
<xacro:property name="gpu" value="false"/>
Then in my xacro file, I use <xacro:VLP16 />
in my attempt to call the xacro but I get an error saying :
Not enough blocks when instantiating macro: VLP16 (/home/sisko/catkin_ws/src/sweep_bot/urdf/macros.xacro) in file: /home/sisko/catkin_ws/src/sweep_bot/urdf/cleaner.xacro RLException: Invalid tag: Cannot load command parameter [robot_description]: command [['/opt/ros/melodic/lib/xacro/xacro', '/home/sisko/catkin_ws/src/sweep_bot/urdf/cleaner.xacro']] returned with code [2].
Param xml is The traceback for the exception was written to the ...